Closed Bug 2057444 Opened 2 months ago Closed 1 month ago

Printing of PDF attachments sometimes fails (preview ok, actually prints blank)

Categories

(Core :: Printing: Output, defect)

Firefox 153
defect

Tracking

()

RESOLVED FIXED
155 Branch
Tracking Status
thunderbird_esr153 --- fixed
firefox-esr140 --- unaffected
firefox-esr153 --- fixed
firefox153 --- unaffected
firefox154 --- wontfix
firefox155 --- fixed

People

(Reporter: mozilla, Assigned: emilio)

References

(Regression)

Details

(Keywords: regression)

Attachments

(2 files, 1 obsolete file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:152.0) Gecko/20100101 Firefox/152.0

Steps to reproduce:

Another long-term issue ...

In some rare cases, I can open a PDF attachment inside TB and it's shown completely properly. When printing the file, I end up in an empty sheet. Saving the PDF to a file, opening it with "Preview" or "Acrobat Reader" and printing it from there works fine. I couldn't find a pattern yet.

Actual results:

see above

Expected results:

The PDF file should be printed correctly.

Keywords: dupeme
Version: unspecified → Thunderbird 140

Bug 2047850 - Printing via system print dialog no longer works on Mac - fixed an issue for v152. But it's indicated as not affecting v140. :(

I don't know why v140 was added here. I've been seeing this issue - very sporadically - across many macOS and TB versions during the last years. And it applies to my HP LaserJet @home as well as to a Kyocera business printer in the office. And to my impressions, it doesn't depend on just the TB version as an other PDF prints well with the same TB. I assume there must be some race condition in the PDF processing.

(In reply to Frank Winkler from comment #2)

I don't know why v140 was added here. I've been seeing this issue - very sporadically - across many macOS and TB versions during the last years.

That does call into question whether bug 2047850 will fix it, but still possible.

See Also: → 2047850

BTW: I totally forgot to mention that printing the PDF just with lp also worked fine so there were many ways of printing which worked fine - just TB failed ;) ...

FWIW, I've had this recently... printing through another application worked.

Summary: Printing of PDF attachments sometimes fails → Printing of PDF attachments sometimes fails (preview ok, actually prints blank)
Duplicate of this bug: 2058989

After further investigation, I found at least the current problem is a regression from bug 2034406.
At least this one seems easy to reproduce - but a physical printer is needed.

Assignee: nobody → mkmelin+mozilla
Status: UNCONFIRMED → ASSIGNED
Component: Mail Window Front End → Printing: Output
Ever confirmed: true
Keywords: dupeme → regression
Product: Thunderbird → Core
Regressed by: 2034406
See Also: 2055412 →
Version: Thunderbird 140 → Firefox 153

Bug 2034406 changed nsPageSequenceFrame::PrePrintNextSheet to render every mozPrintCallback canvas into a recording DrawTarget instead of a real one:

RefPtr recorder = MakeAndAddRef<gfx::DrawEventRecorderMemory>(nullptr);
RefPtr<DrawTarget> canvasTarget = gfx::Factory::CreateRecordingDrawTarget(recorder, referenceDt, ...);

and made the paint side replay it (nsHTMLCanvasFrame.cpp):

if (presContext->Type() != nsPresContext::eContext_Print ||
!canvas-GetMozPrintCallback() ||
!dt.TryToReplaySurface(surface, destRect, srcRect)) {
dt.DrawSurface(surface, destRect, srcRect, ...);
}

TryToReplaySurface is only implemented by DrawTargetRecording (gfx/2d/DrawTargetRecording.cpp:555); the base returns false (gfx/2d/2D.h:1539). When it returns false the fallback draws the snapshot — but that snapshot is a SourceSurfaceRecording, which has no pixels. Result: nothing is painted.

The print destination is a recording DrawTarget only when the job is recorded in a content process for replay in the parent. So:

  • Firefox: PDFs always render in a content process → recording destination → replay works.
  • Thunderbird: a PDF attachment opens as a content tab on a mailbox:/imap: URL, which is parent-process only (browser.isRemoteBrowser == false). The print destination is a real DrawTarget → replay fails → every pdf.js page canvas paints nothing → blank sheets, while the viewer and the print preview both look correct (preview goes through HandlePrintCallback/on-screen painting, not this path.)

Assisted by Claude.

Set release status flags based on info from the regressing bug 2034406

Attachment #9625803 - Attachment is obsolete: true

D318194 seems alright in my testing

Assignee: mkmelin+mozilla → emilio
Flags: needinfo?(emilio)
Attachment #9625837 - Attachment description: WIP: Bug 2057444 - Make TryToReplaySurface work on arbitrary DrawTargets. r=lsalzman → Bug 2057444 - Make TryToReplaySurface work on arbitrary DrawTargets. r=lsalzman
Flags: needinfo?(emilio)
Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 155 Branch

Does this need a Release uplift request?

Flags: needinfo?(emilio)

This doesn't affect Firefox so no unless Thunderbird needs it.

Flags: needinfo?(emilio)

As 153 is esr, it would be good to uplift there, so Thunderbird ESR users don't run into this for the next year.

Flags: needinfo?(emilio)

Requested!

Flags: needinfo?(emilio)

firefox-esr153 Uplift Approval Request

  • User impact if declined/Reason for urgency: Affects Thunderbird.
  • Code covered by automated testing?: no
  • Fix verified in Nightly?: yes
  • Needs manual QE testing?: no
  • Steps to reproduce for manual QE testing:
  • Risk associated with taking this patch: low
  • Explanation of risk level: Relatively minimal change.
  • String changes made/needed?: none
  • Is Android affected?: yes
Attachment #9627249 - Flags: approval-mozilla-esr153?

The implementation living in DrawTargetRecording.cpp is slightly
annoying but makes things easier, wdyt?

Alternative would be to move this to a
SourceSurfaceRecording::TryToReplayInto(DrawTarget*) or so.

Original Revision: https://phabricator.services.mozilla.com/D318194

Attachment #9627249 - Flags: approval-mozilla-esr153? → approval-mozilla-esr153+
QA Whiteboard: [qa-triage-done-c156/b155]
Duplicate of this bug: 2066228
Duplicate of this bug: 2064721

Just out of curiosity: what was the actual problem and what triggered it? I'm not deep enough in the source code to figure out what the above snippets (should) do or don't.
And the reason for "won't fix in FF 154" is that it was just about to be replaced by 155?

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: