Closed Bug 1667557 Opened 4 months ago Closed 3 months ago

82.0B1 Print Preview is blank. (Print is OK)

Categories

(Thunderbird :: General, defect)

Thunderbird 82
x86_64
All
defect

Tracking

(thunderbird_esr78 unaffected, thunderbird82 affected, thunderbird83 affected)

RESOLVED FIXED
84 Branch
Tracking Status
thunderbird_esr78 --- unaffected
thunderbird82 --- affected
thunderbird83 --- affected

People

(Reporter: brantmercer, Assigned: rnons)

References

Details

(Keywords: regression, regressionwindow-wanted)

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0

Steps to reproduce:

Updated to 82.0B1.

Actual results:

Print Preview is blank. It actually shows multiple pages in page number field, but all screens are blank. I printed anyway and it seems to print ok. Appears to be solely a print preview display issue? Noted that it does allow changes such as scaling, but still shows no content of item being previewed.

Expected results:

Print Preview should have shown contents of e-mail being printed and allow editing, such as scaling.

Component: Untriaged → General
Summary: 82.0B1 Print Preview → 82.0B1 Print Preview is blank. (Print is OK)

I'll have to test again, but printing on Windows 10 came out blank for me when testing the release candidate.

Calendar printing also didn't work IIRC.

Agree, calendar does show preview in print settings pop-up (like the grid version myself), but does not print (Win 10). Does not cause crash as with 81.0B4, just simply does not print. Different than e-mail issue that does not show preview, but dose print. ??

Just tested this in TB 82.0b1 on Windows 10

Email printing works.
Email print preview doesn't open a preview window.
Calendar opens the preview window but doesn't print.

Does this have anything to do with the new redesign of printing for Firefox? bug 133187

Thunderbird doesn't appear to have adopted it.

Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Unspecified → All
Hardware: Unspecified → x86_64

Clarification Note: Print works direct from Print selection in menu, but prints blank page if Print is selected from Preview screen (in other words both preview and print-out are blank). As stated earlier, calendar simply does not print at all.

Duplicate of this bug: 1668032

10/2/20: Updated to 82.0b2 - same issues as noted above.

Duplicate of this bug: 1668752

10/17/20: Updated to 82.0b3 - same issues above continue.

Now, update to 82b3 32 bit. Preview window is blank or not opened
Error console:
NS_ERROR_FAILURE: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIWebBrowserPrint.printPreviewNumPages] PrintingChild.jsm:411
updatePageCount resource://gre/actors/PrintingChild.jsm:411
handleEvent resource://gre/actors/PrintingChild.jsm:75
handleActorEvent resource://gre/modules/ActorManagerChild.jsm:153
handleActorEvent self-hosted:1208
(Асинхронный: EventListener.handleEvent)
addEventListener resource://gre/modules/ActorManagerChild.jsm:102
init resource://gre/modules/ActorManagerChild.jsm:73
attach resource://gre/modules/ActorManagerChild.jsm:335
<анонимный> chrome://global/content/browser-content.js:16
getPrintPreviewBrowser chrome://messenger/content/msgPrintEngine.js:52
_enterPrintPreview chrome://global/content/printUtils.js:679
observe chrome://global/content/printUtils.js:637
(Асинхронный: setTimeout handler)
observe chrome://global/content/printUtils.js:636
doneIniting chrome://global/content/printPreviewProgress.js:151
(Асинхронный: setTimeout handler)
onLoad chrome://global/content/printPreviewProgress.js:123
onload chrome://global/content/printPreviewProgress.xhtml:1
[Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDocShell.exitPrintPreview]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: resource://gre/actors/PrintingChild.jsm :: exitPrintPreview :: line 404" data: no] PrintingChild.jsm:404:19
exitPrintPreview resource://gre/actors/PrintingChild.jsm:404
receiveMessage resource://gre/actors/PrintingChild.jsm:99
receiveMessage resource://gre/modules/ActorManagerChild.jsm:179
(Асинхронный: MessageListener.receiveMessage)
init resource://gre/modules/ActorManagerChild.jsm:67
attach resource://gre/modules/ActorManagerChild.jsm:335
<анонимный> chrome://global/content/browser-content.js:16
getPrintPreviewBrowser chrome://messenger/content/msgPrintEngine.js:52
_enterPrintPreview chrome://global/content/printUtils.js:679
observe chrome://global/content/printUtils.js:637
(Асинхронный: setTimeout handler)
observe chrome://global/content/printUtils.js:636
doneIniting chrome://global/content/printPreviewProgress.js:151
(Асинхронный: setTimeout handler)
onLoad chrome://global/content/printPreviewProgress.js:123
onload chrome://global/content/printPreviewProgress.xhtml:1

See Also: → 1671131

10/22/20 - Upgraded to 83.0b1. Same issues.

Assignee: nobody → remotenonsense

Here is what I found, after clicking File -> Print Preview, the print preview progress dialog shows up with Progress: Preparing..., then nothing happens. It's because windowGlobal is null at https://searchfox.org/mozilla-central/source/toolkit/content/widgets/browser-custom-element.js#1785. PrintingChild never receives Printing:Preview:Enter message.

I tried to write ppBrowser https://searchfox.org/comm-central/source/mailnews/base/content/msgPrintEngine.js#45-53 directly in msgPrintEngine.xhtml, then TB crashes at https://searchfox.org/mozilla-central/source/dom/base/nsGlobalWindowOuter.cpp#5349. If I comment out the MOZ_DIAGNOSTIC_ASSERT line, then print preview works as before.

:emilio can you give me some help? I can't find out why browsingContext.currentWindowGlobal is null in the first case. And in the second case, does it make sense if that assert is disabled for TB? Thanks.

Flags: needinfo?(emilio)

(In reply to Ping Chen (:rnons) from comment #11)

Here is what I found, after clicking File -> Print Preview, the print preview progress dialog shows up with Progress: Preparing..., then nothing happens. It's because windowGlobal is null at https://searchfox.org/mozilla-central/source/toolkit/content/widgets/browser-custom-element.js#1785. PrintingChild never receives Printing:Preview:Enter message.

That generally means that the browsing context is somehow detached or well, doesn't have a window to send the message to. What is the entry point for File -> Print Preview in Thunderbird? The printing setup looked really different from Firefox, for some reason I won't claim to understand.

I tried to write ppBrowser https://searchfox.org/comm-central/source/mailnews/base/content/msgPrintEngine.js#45-53 directly in msgPrintEngine.xhtml, then TB crashes at https://searchfox.org/mozilla-central/source/dom/base/nsGlobalWindowOuter.cpp#5349. If I comment out the MOZ_DIAGNOSTIC_ASSERT line, then print preview works as before.

What do you mean with "I tried to write ppBrowser in msgPrintEngine.xhtml?

:emilio can you give me some help? I can't find out why browsingContext.currentWindowGlobal is null in the first case. And in the second case, does it make sense if that assert is disabled for TB? Thanks.

No, that assertion needs to stay, if it breaks is that the original and preview browser could end up in different processes or doing other crazy stuff.

Flags: needinfo?(emilio) → needinfo?(remotenonsense)

Thanks.

What is the entry point for File -> Print Preview in Thunderbird?

The entry point is https://searchfox.org/comm-central/source/mailnews/base/content/msgPrintEngine.xhtml. Which is brought up by https://searchfox.org/comm-central/source/mail/base/content/mailWindowOverlay.js#2710-2711,2726-2727.

I tried to write ppBrowser https://searchfox.org/comm-central/source/mailnews/base/content/msgPrintEngine.js#45-53 directly in msgPrintEngine.xhtml, then TB crashes at https://searchfox.org/mozilla-central/source/dom/base/nsGlobalWindowOuter.cpp#5349. If I comment out the MOZ_DIAGNOSTIC_ASSERT line, then print preview works as before.

What do you mean with "I tried to write ppBrowser in msgPrintEngine.xhtml?

Currently the ppBrowser is created in msgPrintEngine.js with createXULElement. I tried to write it in msgPrintEngine.xhtml

  <browser id="ppBrowser"
           type="content"
           primary="true"
           name="content"
           src="about:blank"
           flex="1"
           disablehistory="true"
           disablesecurity="true"/>

With this change, browsingContext.currentWindowGlobal seems fine, but failed at the assert line. Is there any way I can ensure the two <browser> have the same group?

Flags: needinfo?(remotenonsense) → needinfo?(emilio)

Well, so you have a window global if you do that because you load about:blank.

But really you should create a browser that does something like this: https://searchfox.org/mozilla-central/rev/c938c7416c633639a5c8ce4412be586eefb48005/toolkit/components/printing/content/printUtils.js#147-152

So tldr the creation of the preview browser has to depend on the source browser (and you should set the initialBrowsingContextGroupId attribute correctly). That should help, let me know if it doesn't.

I'm still wondering why the print setup in TB is so bespoke. Maybe eventually TB can move to the nicer modal preview that Firefox has and remove a lot of that ugly code?

Flags: needinfo?(emilio)

After setting initialBrowsingContextGroupId, browsingContext.currentWindowGlobal is still null. I wonder what's the difference between document.documentElement.appendChild and put directly in the .xhtml.

(In reply to Emilio Cobos Álvarez (:emilio) from comment #14)

Well, so you have a window global if you do that because you load about:blank.

I tried browser.setAttribute("src", "about:blank"); in msgPrintEngine.js, but browsingContext.currentWindowGlobal is still null.

But really you should create a browser that does something like this: https://searchfox.org/mozilla-central/rev/c938c7416c633639a5c8ce4412be586eefb48005/toolkit/components/printing/content/printUtils.js#147-152

So tldr the creation of the preview browser has to depend on the source browser (and you should set the initialBrowsingContextGroupId attribute correctly). That should help, let me know if it doesn't.

I'm still wondering why the print setup in TB is so bespoke. Maybe eventually TB can move to the nicer modal preview that Firefox has and remove a lot of that ugly code?

Somehow, the gBrowser and tabbrowser.js are not available in TB.

I sent a patch so you can clearly see what I tried. Thanks.

What's the stack for the windowGlobal being null?

Flags: needinfo?(remotenonsense)
Flags: needinfo?(remotenonsense)
Attachment #9185875 - Attachment description: Bug 1667557 - Try to fix print preview. r=emilio → Bug 1667557 - Fix print preview by init ppBrowser first. r=mkmelin

Turns out to be a timing issue. browsingContext.currentWindowGlobal is created a few ms after appendChild, by init ppBrowser first, it works now. Thanks Emilio.

Status: NEW → ASSIGNED

(In reply to Ping Chen (:rnons) from comment #18)

You mean the <stack> element? No stack element, I tried to do something similar to https://searchfox.org/mozilla-central/rev/c938c7416c633639a5c8ce4412be586eefb48005/toolkit/components/printing/content/printUtils.js#173-178, still the same.

I meant the actual error stack yeah. Fwiw you can get them quite easily with new Error().stack or such.

Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/f9161d72406a
Fix print preview by init ppBrowser first. r=mkmelin

Status: ASSIGNED → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → 84 Branch

Comment on attachment 9185875 [details]
Bug 1667557 - Fix print preview by init ppBrowser first. r=mkmelin

[Approval Request Comment]
Regression caused by (bug #): Several m-c changes
User impact if declined: Print preview doesn't work
Testing completed (on c-c, etc.): Manually tested
Risk to taking this patch (and alternatives if risky): Low, print preview is already broken in beta

Attachment #9185875 - Flags: approval-comm-beta?

Comment on attachment 9185875 [details]
Bug 1667557 - Fix print preview by init ppBrowser first. r=mkmelin

[Triage Comment]
We aren't building another build for 83 beta, so this will appear in 84 beta

Attachment #9185875 - Flags: approval-comm-beta? → approval-comm-beta-

Print preview and email printing works in my test of 84.0b1 on Ubuntu 18.04.

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