Closed Bug 2036587 Opened 17 days ago Closed 11 days ago

Content missing when printing PDFs

Categories

(Core :: Graphics, defect)

defect

Tracking

()

RESOLVED FIXED
152 Branch
Tracking Status
firefox-esr115 --- unaffected
firefox-esr140 --- unaffected
firefox150 --- unaffected
firefox151 --- unaffected
firefox152 + fixed

People

(Reporter: RyanVM, Assigned: jfkthame)

References

(Regression)

Details

(Keywords: regression)

Attachments

(2 files, 1 obsolete file)

Attached file printed PDF

Bisected with mozregression to the Cairo update, naturally.

Attempting to print a PDF of sheet music, the lyrics and notes are completely missing, reproducible on paper and printed to PDF. Some kind of layering issue? I've attached a PDF of what the printed output looks like and will find a way to share the original copywritten PDF with whomever wants to investigate.

I should note that this was happening on Windows 11 in my case.

The printed PDF is also almost 4MB when the original file was only a bit over 200kB.

There's been a few upstream fixes landed in the win32 printing code since 1.18.4 was released, but a build with all them cherry-picked still reproduces the problem. A build with _cairo_dwrite_scaled_font_init_glyph_surface reverted back to it's previous state does fix the problem, however.
https://treeherder.mozilla.org/jobs?repo=try&revision=7beacf87e5f17392691bfca3dd299a07bc8c36d8

The bug is marked as tracked for firefox152 (nightly). However, the bug still isn't assigned.

:bhood, could you please find an assignee for this tracked bug? Given that it is a regression and we know the cause, we could also simply backout the regressor. If you disagree with the tracking decision, please talk with the release managers.

For more information, please visit BugBot documentation.

Flags: needinfo?(bhood)
See Also: → 2035492

Does skpdf fix this? (printing.experimental.skpdf=true)

Flags: needinfo?(ryanvm)

Still reproducible after setting that pref (doesn't exist by default in about:config) and restarting the browser.

Flags: needinfo?(ryanvm)
Flags: needinfo?(bhood)

Sorry, print.experimental.skpdf, ugh!

Still reproducible after flipping that pref in about:config and restarting.

Severity: -- → S2
Severity: S2 → S3

For clarity, I'm using the "Microsoft Print to PDF" printer rather than the "Save to PDF" option from the print dialog. The former matches what I see printed on my actual printer.

Ah yeah so this depends on rewriting PrintTargetWindows to use SkPdf.

The 1.18.4 rewrite of this function (using IDWriteGlyphRunAnalysis directly)
has multiple bugs that surface during PDF print rasterization fallback,
producing pages with all glyphs missing. Revert to the pre-1.18.4 GDI-based
implementation, which uses _dwrite_draw_glyphs_to_gdi_surface_gdi and
_cairo_compute_glyph_mask. Use the variations-aware scaled_font->dwriteface
field added in 1.18.4 so variable-font axis values are still honoured.

I'm not saying this is the patch we should take, but I'm attaching it for posterity at least. As mentioned in comment 4, this does fix the regression albeit at the cost of being yet another relatively heavy revert in our Cairo patch stack.

See Also: → 2036950

Interestingly, AFAICS it seems that _cairo_dwrite_scaled_font_init_glyph_surface is rasterizing the glyphs as expected; inspecting surface_data at the end of that function, I'm seeing the expected bitmaps. It's not clear to me why they're failing to appear in the output.

Ryan, the above patch seems to resolve the missing text in my testing, with your PDF as well as some other examples. I'll do a bit more testing tomorrow, but you might also like to give it a whirl.

This doesn't address the fact that we end up with the page rendered as a rasterized bitmap, so the text is not searchable/selectable; that's a separate issue (and I assume was also the case prior to the cairo update). Not all documents exhibit that issue; it depends on the particular graphics features used during the rendering.

Yeah, I can confirm that older Firefox versions also end up with a rasterized bitmap when printing that particular PDF.

Jonathan's patch also works on my machine.

Assignee: nobody → jfkthame
Attachment #9583420 - Attachment description: WIP: Bug 2036587 - Fixup _cairo_dwrite_scaled_font_init_glyph_surface → Bug 2036587 - Don't set the component-alpha flag when generating glyph surfaces. r=#gfx-reviewers
Status: NEW → ASSIGNED

Is it possible to create a test for this?

Flags: needinfo?(jfkthame)

(In reply to Ryan VanderMeulen [:RyanVM] from comment #20)

Is it possible to create a test for this?

Our "printing" tests normally use the Save as PDF backend, rather than an actual Windows printer driver, so they don't exercise the same code path. So I'm not sure how readily we can test this in CI, but I was intending to try and look into it.

(I'm going to go ahead and land the patch, even though we don't currently have test coverage for it, so that at least it's in Nightly for manual verification.)

Flags: needinfo?(jfkthame)
Pushed by jkew@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/9e0da8537f35 https://hg.mozilla.org/integration/autoland/rev/021232917efa Don't set the component-alpha flag when generating glyph surfaces. r=gfx-reviewers,lsalzman
Status: ASSIGNED → RESOLVED
Closed: 11 days ago
Resolution: --- → FIXED
Target Milestone: --- → 152 Branch
Attachment #9582976 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: