Closed Bug 842521 Opened 12 years ago Closed 11 years ago

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

Categories

(Core :: Graphics, defect)

21 Branch
x86
Windows 8
defect
Not set
normal

Tracking

()

RESOLVED WONTFIX
Tracking Status
firefox21 - affected
firefox22 - affected

People

(Reporter: claritise, Assigned: mattwoodrow)

References

(Blocks 1 open bug)

Details

(Keywords: regression)

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 6.2; rv:21.0) Gecko/20130218 Firefox/21.0
Build ID: 20130218031106
Component: Untriaged → PDF Viewer
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)
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)
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
Ever confirmed: true
> gfx.direct2d.disabled = true
> gfx.font_rendering.directwrite.enabled = true

is this combination be common?
Not really, I think. ^^
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)
Yes, true, restart FF to apply HWA modifications. :)
Component: PDF Viewer → Graphics
Product: Firefox → Core
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)
Some PDF's still won't render properly with DirectWrite using Cairo.
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
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.
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.
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.
(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.
(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.
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 ?
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
Closed: 11 years ago
Flags: needinfo?(bas)
Resolution: --- → WONTFIX
Can we make it so that pref combinations which results in non-working configurations are ignored and perhaps report something to the error console?
Flags: needinfo?(jmuizelaar)
(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)
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.

Attachment

General

Created:
Updated:
Size: