PDF.js won't render text when DirectWrite is enabled with both Skia and Cairo backends

RESOLVED WONTFIX

Status

()

RESOLVED WONTFIX
6 years ago
3 years ago

People

(Reporter: claritise, Assigned: mattwoodrow)

Tracking

(Blocks: 1 bug, {regression})

21 Branch
x86
Windows 8
regression
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox21- affected, firefox22- affected)

Details

Attachments

(1 attachment)

(Reporter)

Description

6 years ago
User Agent: Mozilla/5.0 (Windows NT 6.2; rv:21.0) Gecko/20130218 Firefox/21.0
Build ID: 20130218031106
(Reporter)

Updated

6 years ago
Component: Untriaged → PDF Viewer

Comment 1

6 years ago
WFM here with the latest nightly:
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20130218 Firefox/21.0

Provide a PDF link where the issue is present.
Flags: needinfo?(claritise)
(Reporter)

Comment 2

6 years ago
It's basically any PDF with text.

http://www.selab.isti.cnr.it/ws-mate/example.pdf
This PDF for example will only load three horizontal lines in the first page. The images on page 7 are displayed also.

With a new profile DirectWrite is off by default. Loading this page will load the PDF fine. However when I toggle gfx.font_rendering.directwrite.enabled to true and restart Firefox, the PDF won't render.
Flags: needinfo?(claritise)

Comment 3

6 years ago
Thanks I'm able to reproduce it.

My STR:

1) Start Nightly with a fresh profile
2) In about:config, set:
gfx.direct2d.disabled = true
gfx.font_rendering.directwrite.enabled = true
3) Open the PDF http://www.selab.isti.cnr.it/ws-mate/example.pdf

Result:
Bad rendering: http://i.imgur.com/YDceW2n.jpg

Expected:
Good rendering: http://i.imgur.com/3TDmVme.jpg

Regression range:
m-c
good=2013-02-07
bad=2013-02-08
http://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=04e13fc9dbff&tochange=fcf79680a057
Status: UNCONFIRMED → NEW
status-firefox21: --- → affected
tracking-firefox21: --- → ?
Ever confirmed: true
Keywords: regression, regressionwindow-wanted

Comment 4

6 years ago
> gfx.direct2d.disabled = true
> gfx.font_rendering.directwrite.enabled = true

is this combination be common?

Comment 5

6 years ago
Not really, I think. ^^

Comment 6

6 years ago
Anyway, in this case ,setting gfx.canvas.azure.backends = cairo helps.
This behavior is introduced by Bug 831525.
(In reply to Loic from comment #3)
> Thanks I'm able to reproduce it.
> 
> My STR:
> 
> 1) Start Nightly with a fresh profile
> 2) In about:config, set:
> gfx.direct2d.disabled = true
> gfx.font_rendering.directwrite.enabled = true
> 3) Open the PDF http://www.selab.isti.cnr.it/ws-mate/example.pdf
> 
Loic, I think you are missing a step to restart Nightly after step 2)

Comment 8

6 years ago
Yes, true, restart FF to apply HWA modifications. :)

Updated

6 years ago
Blocks: 831525
Keywords: regressionwindow-wanted
Component: PDF Viewer → Graphics
Product: Firefox → Core
(Assignee)

Comment 9

6 years ago
Created attachment 715781 [details] [diff] [review]
Disable skia when we are using DirectWrite

Skia doesn't support DirectWrite fonts.

This patch should make us fall back to using cairo for canvas when DirectWrite is enabled.

Haven't tested it though, I would appreciate it if someone else could do so.
Attachment #715781 - Flags: review?(bas)

Updated

6 years ago
tracking-firefox22: --- → ?
(Reporter)

Comment 10

6 years ago
Some PDF's still won't render properly with DirectWrite using Cairo.
(Reporter)

Updated

6 years ago
Summary: PDF.js won't render text when DirectWrite is enabled → PDF.js won't render text when DirectWrite is enabled with both Skia and Cairo backends
(In reply to ... from comment #10)
> Some PDF's still won't render properly with DirectWrite using Cairo.

In that case this bug will probably cover only the skia case
(Reporter)

Comment 12

6 years ago
This patch makes a marginal difference, at the cost of performance.

If it does go ahead, I will be reverting back to Skia and will be using the Acrobat plugin which renders everything properly, quickly and looks much more legible.
(Assignee)

Comment 13

6 years ago
DirectWrite without D2D isn't currently a supported configuration.

My suggestion would be to look into why you aren't getting d2d enabled (old graphics drivers perhaps?), or to switch back to GDI fonts.

If you really believe that DirectWrite without D2D is a use-case worth spending resources on, then please file a new bug for that and we can consider it.

Fonts rendering incorrectly under cairo also should be a separate bug, since it's separate to the regression caused by enabling skia.
(Assignee)

Comment 14

6 years ago
Actually, it looks like skia does support DirectWrite fonts now, but doesn't expose what we need.

It wouldn't be too difficult to implement this though.
(Reporter)

Comment 15

6 years ago
(In reply to Matt Woodrow (:mattwoodrow) from comment #13)
> DirectWrite without D2D isn't currently a supported configuration.
> 
> My suggestion would be to look into why you aren't getting d2d enabled (old
> graphics drivers perhaps?), or to switch back to GDI fonts.
> 
> If you really believe that DirectWrite without D2D is a use-case worth
> spending resources on, then please file a new bug for that and we can
> consider it.
> 
> Fonts rendering incorrectly under cairo also should be a separate bug, since
> it's separate to the regression caused by enabling skia.

Yeah my graphics are blacklisted and has problems with HWA.

If I were to switch back to GDI fonts and reset the force GDI rendering list back to the most common fonts, I would actually rather be using Chrome. 
DirectWrite without the force GDI list would probably be one of the best features of Firefox to me.

I don't understand why PDF.js doesn't actually utilise DirectWrite considering it's not a plugin, the fonts are weak and brittle on the few PDF's it actually manages to render.
(Assignee)

Comment 16

6 years ago
(In reply to ... from comment #15)
> 
> Yeah my graphics are blacklisted and has problems with HWA.

That's a shame, Direct2D is a big win here :)

> 
> If I were to switch back to GDI fonts and reset the force GDI rendering list
> back to the most common fonts, I would actually rather be using Chrome. 
> DirectWrite without the force GDI list would probably be one of the best
> features of Firefox to me.
> 
> I don't understand why PDF.js doesn't actually utilise DirectWrite
> considering it's not a plugin, the fonts are weak and brittle on the few
> PDF's it actually manages to render.

It's not a problem with PDF.js, it's a problem with the backend code for the <canvas> element, which is what PDF.js uses to draw content.

Our skia backend has no support for DirectWrite fonts, and it would appear that the cairo backend doesn't support them very well.

As I said, feel free to file a bug for this and I can take a look at getting skia+DirectWrite working.

Updated

6 years ago
status-firefox22: --- → affected
tracking-firefox21: ? → +
tracking-firefox22: ? → +

Updated

6 years ago
Assignee: nobody → matt.woodrow
(In reply to Matt Woodrow (:mattwoodrow) from comment #16)
> (In reply to ... from comment #15)
> > 
> > Yeah my graphics are blacklisted and has problems with HWA.
> 
> That's a shame, Direct2D is a big win here :)
> 
> > 
> > If I were to switch back to GDI fonts and reset the force GDI rendering list
> > back to the most common fonts, I would actually rather be using Chrome. 
> > DirectWrite without the force GDI list would probably be one of the best
> > features of Firefox to me.
> > 
> > I don't understand why PDF.js doesn't actually utilise DirectWrite
> > considering it's not a plugin, the fonts are weak and brittle on the few
> > PDF's it actually manages to render.
> 
> It's not a problem with PDF.js, it's a problem with the backend code for the
> <canvas> element, which is what PDF.js uses to draw content.
> 
> Our skia backend has no support for DirectWrite fonts, and it would appear
> that the cairo backend doesn't support them very well.
> 
> As I said, feel free to file a bug for this and I can take a look at getting
> skia+DirectWrite working.

Hey Matt, can you please help understand if there is work being done in some other bug to help here ? What are the next steps for this issue in FX21 timeframe ?
(Assignee)

Comment 18

5 years ago
Hey Bhavana,

We currently need to get feedback from Bas to decide if DirectWrite without accelerated layers is a configuration we want to support. It's certainly not a default one, and this bug can only happen with custom prefs.

The two easy options are:

 - Forcibly disable skia if we have DirectWrite preffed on (this is the patch attached to this bug)

 - Forcibly disable DirectWrite if we are using skia

The 'best' solution would be to get skia to support DirectWrite.

However it appears that skia can only support DirectWrite *or* GDI, decided at compile time. We would really need to retain the ability to use GDI fonts, even if some users are getting DirectWrite.

George Wright is investigating this further in bug 856394
Flags: needinfo?(bas)
(In reply to Matt Woodrow (:mattwoodrow) from comment #18)
> Hey Bhavana,
> 
> We currently need to get feedback from Bas to decide if DirectWrite without
> accelerated layers is a configuration we want to support. It's certainly not
> a default one, and this bug can only happen with custom prefs.

DirectWrite is only supported with D2D. I don't think there's enough reason for us to want to support any additional configurations.
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Flags: needinfo?(bas)
Resolution: --- → WONTFIX

Comment 20

5 years ago
Can we make it so that pref combinations which results in non-working configurations are ignored and perhaps report something to the error console?

Updated

5 years ago
Flags: needinfo?(jmuizelaar)

Updated

5 years ago
tracking-firefox21: + → -
tracking-firefox22: + → -
(In reply to Benjamin Smedberg  [:bsmedberg] from comment #20)
> Can we make it so that pref combinations which results in non-working
> configurations are ignored and perhaps report something to the error console?

Being able to test this configuration is still helpful for development.
I'd definitely take a patch to report something to the error console.
Flags: needinfo?(jmuizelaar)
Blocks: 782226
Attachment #715781 - Flags: review?(bas)

Comment 22

3 years ago
I encountered this same problem. My PC has a Radeon R9 285. Somtimes, Firefox version 38-40 crashed the Radeon display driver (version 15.7.1).

So I turned off "Use hardware acceleration when available", and turn on “gfx.font_rendering.directwrite.enabled” so that font rendering was not affected. 

The result: the built-in PDF viewer failed to render PDF documents. Turning off gfx.font_rendering.directwrite.enabled fixed the problem.
You need to log in before you can comment on or make changes to this bug.