[macOS] mozPrintCallback produces rasterized text (unselectable and blurr-when-zoomed), e.g. for PDF.js and in "native" Google Docs printing flow
Categories
(Core :: Printing: Output, defect)
Tracking
()
People
(Reporter: dholbert, Assigned: jfkthame)
References
(Regressed 2 open bugs, Regression, )
Details
(Keywords: regression)
Attachments
(6 files)
|
19.62 KB,
application/pdf
|
Details | |
|
10.52 KB,
application/pdf
|
Details | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
phab-bot
:
approval-mozilla-beta+
|
Details | Review |
|
48 bytes,
text/x-phabricator-request
|
phab-bot
:
approval-mozilla-beta+
|
Details | Review |
STR (same as bug 1865200 basically):
- Be using a Google account that's opted in to the "native" print flow (which requires manual action from some Google folks for now), or using UA spoofing to pretend you're Chrome.
- Load a Google Doc with some text, e.g. this one
- Ctrl+P
(Hopefully this triggers a print-preview popup. If it doesn't, go back to step 1.) - Click through Firefox's print UI to choose the "Save to PDF" print target and go ahead and save it.
- Load the resulting PDF in a PDF viewer, and try to select the text, and try to zoom in.
ACTUAL RESULTS:
The text is selectable (this is what differs from bug 1865200), BUT it doesn't zoom crisply. The characters are blurry.
EDIT: Actually the text is not selectable if I view the PDF in Firefox. It is selectable in Preview.app, but that might be from some fancy OCR that Preview.app is doing? not sure.
EXPECTED RESULTS:
Text that zooms crisply.
Firefox Nightly 130.0a1 on macOS gives ACTUAL RESULTS.
Chrome on the same machine gives EXPECTED RESULTS.
Firefox Nightly 130.0a1 on Linux gives EXPECTED RESULTS.
(Haven't tested Windows yet)
So this might be macOS-specific?
This might be a general issue with mozPrintCallback, though I'm not sure (haven't tested yet).
| Reporter | ||
Updated•1 year ago
|
| Reporter | ||
Comment 1•1 year ago
|
||
| Reporter | ||
Updated•1 year ago
|
| Reporter | ||
Updated•1 year ago
|
| Reporter | ||
Comment 2•1 year ago
|
||
| Reporter | ||
Comment 3•1 year ago
|
||
Related historical bugs: bug 1487467, bug 1308259.
This mozPrintCallback testcase from bug 1308259 might be a useful testcase here. If I print that testcase to PDF from Nightly and then view the resulting PDF in Nightly:
- on macOS: the "Test" text ends up all rasterized/unselectable.
- on Ubuntu: the "Test" text under "data: loading print" and "api loading print" is nicely selectable.
So it seems like this is a regression of precisely bug 1308259 on macOS. (regression range TBD, but the bug itself seems to be as-described in bug 1308259.)
I can try to track down a regression range tomorrow [hence setting needinfo=me], if nobody else gets to it first. (I would guess maybe one of the cairo updates might've done it.)
| Assignee | ||
Comment 4•1 year ago
|
||
I haven't confirmed it yet, but my hunch is that the workaround in bug 1901043 may have regressed this.
| Assignee | ||
Comment 5•1 year ago
|
||
I just made a local build with bug 1901043 backed out, and I'm still getting blurry/rasterized text in a PDF from GDocs. So maybe it wasn't that after all.... further investigation needed.
| Assignee | ||
Comment 6•1 year ago
|
||
As far as I can see from running mozregression, this has been broken -- generating rasterized text when printing to PDF from GDocs on macOS -- ever since bug 1892913 (the cairo-1.18.0 update) landed. (Daniel, maybe you can double-check that?)
(Given this, I'm surprised -- and sad -- that it hasn't been noticed/reported until now.)
We probably need to revert patch 22 from the stack in that bug, which may also require fixing up some cairo-quartz API if it has changed such that the old thebes code no longer matches what cairo provides.
| Assignee | ||
Comment 7•1 year ago
|
||
Try push with an attempt to work around this, by restoring the pre-1.18.0 cairo-quartz code in its entirety:
https://treeherder.mozilla.org/jobs?repo=try&revision=12fbe88b16bb19f2b0d45e35e846cff2e47c74e3
| Reporter | ||
Comment 8•1 year ago
•
|
||
(In reply to Jonathan Kew [:jfkthame] from comment #6)
As far as I can see from running mozregression, this has been broken -- generating rasterized text when printing to PDF from GDocs on macOS -- ever since bug 1892913 (the cairo-1.18.0 update) landed. (Daniel, maybe you can double-check that?)
A quick spot-check confirms that as the regressor, at least using the mozPrintCallback testcase that I linked above.
2024-05-05 is "good" (matches description for Ubuntu on comment 3)
2024-05-08 is "bad" (matches description for macOS on comment 3)
(I chose those dates because the patches landed on autoland and then central on 5/6 and 5/7, so I spot-checked the Nightlies before & after those days)
| Reporter | ||
Comment 9•1 year ago
|
||
Alternate STR here, just using our PDF viewer (which uses mozPrintCallback to render text when printing a PDF):
- View any page with text, e.g.
data:text/html,This is some text - Print to PDF.
- View the PDF in Firefox, and notice that the text is selectable.
- Print the PDF to a new PDF.
- View that new PDF in Firefox.
ACTUAL RESULTS:
The final PDF (from printing PDF to PDF) has rasterized text -- blurry and unselectable.
| Reporter | ||
Comment 10•1 year ago
|
||
Confirmed the regressor with autoland builds before (good) and after (bad) bug 1892913's patch stack.
before: mozregression --repo autoland --launch 9daa351f875bf247036785e3559a9814ff5b25ad
after: mozregression --repo autoland --launch 2175f8e4c8c9ec62e4b331c21d0dc8e5855da0f8
| Reporter | ||
Comment 11•1 year ago
•
|
||
| Reporter | ||
Comment 12•1 year ago
|
||
Comment 13•1 year ago
|
||
Set release status flags based on info from the regressing bug 1892913
| Assignee | ||
Comment 14•1 year ago
|
||
The cairo-1.18.0 version of the cairo-quartz backend is resulting in unwanted
rasterization of the output when printing GDocs to PDF (or to a real printer,
presumably).
It's likely this would affect other canvas-based content as well.
The problem in the 1.18.0 backend probably relates to failing to use CGLayer-
backed surfaces in certain cases, but will require more extensive debugging
to fully understand and resolve.
Given that this worked better prior to the cairo-1.18.0 update (using the
old cairo-quartz backend that included a number of mozilla-specific adaptations,
including CGLayer support), the simplest/safest mitigation in the short term
seems to be reverting the entire quartz backend. Fortunately, it is sufficiently
isolated from the rest of cairo that this can be done without touching any
other cairo code outside the macOS-specific cairo-quartz-* files.
Updated•1 year ago
|
| Assignee | ||
Comment 15•1 year ago
|
||
| Reporter | ||
Comment 16•1 year ago
|
||
I have the makings of a test for this, I think, BTW (using mozPrintCallback in a canvas in a WPT-style print test).
It passes on linux and fails on macOS right now; I'm in the midst of rebuilding with the attached patches, and should know if they make the test pass later on today.
| Assignee | ||
Comment 17•1 year ago
|
||
(In reply to Daniel Holbert [:dholbert] from comment #16)
I have the makings of a test for this, I think, BTW (using mozPrintCallback in a canvas in a WPT-style print test).
It passes on linux and fails on macOS right now; I'm in the midst of rebuilding with the attached patches, and should know if they make the test pass later on today.
Thanks - we're sorely lacking automated test coverage here (obviously), so this would be awesome. I'm going to go ahead and lando the patches here, so that we can start getting Nightly testing, but adding a test to ensure we don't regress this again in the future would be hugely helpful.
Comment 18•1 year ago
|
||
| Assignee | ||
Comment 19•1 year ago
|
||
(In reply to Daniel Holbert [:dholbert] from comment #16)
I have the makings of a test for this, I think, BTW (using mozPrintCallback in a canvas in a WPT-style print test).
Another possible approach to testing this might be to generate a PDF that contains some text, then load it back into the browser as a pdf.js-viewer page, and then check that document.fonts is non-empty (because the PDF should contain embedded fonts that pdf.js loads as webfont resources to render them).
Comment 20•1 year ago
|
||
(In reply to Daniel Holbert [:dholbert] from comment #16)
I have the makings of a test for this, I think, BTW (using mozPrintCallback in a canvas in a WPT-style print test).
Does that work by scaling up the rendering or something?
Having the test(s) be WPT tests would definitely be preferable but if that doesn't work out maybe we can use our print reftests. They're supposed to support a <type> of print which should check that the same strings appear in the test and reference output.
Comment 21•1 year ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/05bf7d6afa7d
https://hg.mozilla.org/mozilla-central/rev/bd02e7030721
| Reporter | ||
Comment 22•1 year ago
•
|
||
(In reply to Jonathan Watt [:jwatt] from comment #20)
(In reply to Daniel Holbert [:dholbert] from comment #16)
I have the makings of a test for this, I think, BTW (using mozPrintCallback in a canvas in a WPT-style print test).
Does that work by scaling up the rendering or something?
Exactly, yeah; I'm just comparing Ahem X glyph, drawn-to-a-canvas in mozPrintCallback, vs. <div>X</div> essentially, under the influence of transform: scale(2) for example.
Interestingly: when the canvas isn't scaled, I do get a column of antialiased gray pixels at the right edge of the Ahem glyph (when drawn with mozPrintCallback). That only happens on macOS, and it happens even with the fix that landed here. But with scale(2) and scale(4), those gray pixels go away (in a build with the fix that landed here).
I agree that a "print reftest" of the flavor that checks-for-strings would be great, too, but I don't have cycles to add one of those right now.
Updated•1 year ago
|
| Assignee | ||
Comment 23•1 year ago
|
||
(In reply to Daniel Holbert [:dholbert] from comment #22)
Interestingly: when the canvas isn't scaled, I do get a column of antialiased gray pixels at the right edge of the Ahem glyph (when drawn with mozPrintCallback). That only happens on macOS, and it happens even with the fix that landed here.
I wonder if using a different font size (isn't 25px supposed to be good for Ahem in tests, IIRC?) might help avoid this?
| Reporter | ||
Comment 24•1 year ago
|
||
Indeed, yeah. I had tried 30px and 50px and 100px and IIRC those all resulted in a column of antialiased pixels in the test output (50px actually does on Linux too), but 60px seems to be reliably crisp, so that's that I'm using in the patches that I just posted in bug 1908969.
(I don't personally like using 25px Ahem because it's odd, which makes for off-by-one issues in some tests as discussed in bug 1808788. I think the only magic thing about 25px is that it's divisible by 5, so other similar-magnitude font-sizes that are also divisible-by-5 should be just as good.)
| Assignee | ||
Comment 25•1 year ago
|
||
As a heads-up, while I believe the patches (reversion of cairo changes) here will have resolved the rasterized-output problem, I'm concerned that this will likely have regressed other reported issues that were fixed by the cairo update, e.g. bug 1854094 and bug 1896915. So this probably isn't an entirely satisfactory way forward.
Comment 26•1 year ago
|
||
The patch landed in nightly and beta is affected.
:jfkthame, is this bug important enough to require an uplift?
- If yes, please nominate the patch for beta approval.
- If no, please set
status-firefox129towontfix.
For more information, please visit BugBot documentation.
| Assignee | ||
Comment 27•1 year ago
|
||
The cairo-1.18.0 version of the cairo-quartz backend is resulting in unwanted
rasterization of the output when printing GDocs to PDF (or to a real printer,
presumably).
It's likely this would affect other canvas-based content as well.
The problem in the 1.18.0 backend probably relates to failing to use CGLayer-
backed surfaces in certain cases, but will require more extensive debugging
to fully understand and resolve.
Given that this worked better prior to the cairo-1.18.0 update (using the
old cairo-quartz backend that included a number of mozilla-specific adaptations,
including CGLayer support), the simplest/safest mitigation in the short term
seems to be reverting the entire quartz backend. Fortunately, it is sufficiently
isolated from the rest of cairo that this can be done without touching any
other cairo code outside the macOS-specific cairo-quartz-* files.
Original Revision: https://phabricator.services.mozilla.com/D217012
Updated•1 year ago
|
| Assignee | ||
Comment 28•1 year ago
|
||
Original Revision: https://phabricator.services.mozilla.com/D217013
Updated•1 year ago
|
Comment 29•1 year ago
|
||
:jfkthame the uplift request is missing an uplift form. Could you add one in the Phabricator revision when you have a moment?
Comment 30•1 year ago
|
||
beta Uplift Approval Request
- User impact if declined: MacOS print/pdf output from Gsuite (and other canvas-based apps) is prematurely rasterized, resulting in poor rendering & non-selectable text
- Code covered by automated testing: yes
- Fix verified in Nightly: no
- Needs manual QE test: yes
- Steps to reproduce for manual QE testing: See STR in comment 9 and comment 3
- Risk associated with taking this patch: low-to-moderate
- Explanation of risk level: Reverting to previous version of the cairo-quartz backend, so the code is relatively well-tested, but this is expected to regress a couple of issues that were fixed by the cairo update (see comment 25)
- String changes made/needed: none
- Is Android affected?: no
| Assignee | ||
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Comment 31•1 year ago
|
||
| uplift | ||
| Reporter | ||
Comment 32•1 year ago
|
||
FWIW I just retested the STR in comment 0 here and confirmed that the rasterization issue is no longer present with Google Docs (using Nightly 130.0a1 2024-07-23 on macOS).
Updated•1 year ago
|
Comment 33•1 year ago
|
||
Updated•1 year ago
|
Updated•9 months ago
|
Description
•