Blank print preview when two automated print preview windows are opened in Firefox 149.0.2
Categories
(Core :: DOM: Navigation, defect)
Tracking
()
People
(Reporter: sergiu.allx123, Assigned: vhilla)
References
(Regression)
Details
(Keywords: regression)
Attachments
(5 files)
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:149.0) Gecko/20100101 Firefox/149.0
Steps to reproduce:
- Open two Firefox windows or tabs with different content
- Trigger print preview programmatically for both pages in an automated workflow
- Each page opens its own print area / print preview
- Observe the rendering behavior
Additional observation:
One of the print preview windows sometimes loads as about:blank, while the other loads correctly. This suggests a possible issue with print preview initialization or race condition when triggered simultaneously.
Actual results:
In Firefox 149.0.2, when print preview is triggered in this dual-window automated workflow, the preview behaves incorrectly:
- blank white page appears
- two print preview views can remain open at the same time
- content is not rendered immediately
- after closing one preview with X, the content becomes visible or loads correctly
This did not happen in earlier Firefox versions.
Expected results:
Each print preview should render normally and independently, even when two automated print preview windows are opened for different pages. No blank white page should appear, and content should load immediately.
Comment 4•7 months ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::Printing: Output' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Comment 5•7 months ago
|
||
Would it be possible to get a reproducer for such a thing? The timing of operations likely matters a lot so reproducing it would be super helpful to diagnose this.
If this used to work in older versions of FF you could also run mozregression to figure out what change broke it.
I have attached a .txt file with a detailed description and the relevant code for reproducing the issue.
The file includes:
- exact steps to reproduce
- timing details
- the print-related code used in my workflow
Please let me know if you need a smaller or more minimal reproducible example.
Comment 8•7 months ago
|
||
Yep, reproducible.
In dark mode, only the dark background gets shown, even if the about:blank should be white.
Another observation of note: Initially, the popups get blocked, and allowing it in bad revisions cause both popup to display the dark background.
Was able to bisect down to: https://hg-edge.mozilla.org/integration/autoland/pushloghtml?fromchange=37f1c536fdb89cd69039774a87f3ad8a94b95328&tochange=86c4f03a43058ea62f76021ad5a50e6199c34567
Updated•7 months ago
|
Comment 9•7 months ago
|
||
:vhilla, since you are the author of the regressor, bug 543435, could you take a look? Also, could you set the severity field?
For more information, please visit BugBot documentation.
| Reporter | ||
Comment 10•7 months ago
|
||
Thanks for investigating and for identifying the regression.
I also tested a workaround on my side:
I modified my script so that it no longer triggers print() automatically for both windows.
Instead:
- the script only opens and prepares both windows
- printing is triggered manually afterwards (via a separate button)
With this approach, the issue does not occur (or happens much less frequently).
This seems to confirm that the problem is related to timing / initialization when two print previews are triggered automatically in quick succession.
Let me know if you need a more minimal reproducer.
| Assignee | ||
Comment 11•7 months ago
|
||
Some observations
- This issue reproduces in Chrome too
- I think it makes sense that browsers pause a page during printing. I'm looking into how we implement this. As mentioned, triggering print manually via two buttons makes it possible to have two print dialogs for the two same origin popups in Firefox. I've seen varying behavior around how active the opener stays while a print dialog is open in a popup - sometimes devtools won't open or buttons can't be clicked. Chrome is stricter, I couldn't get buttons or a second print dialog to work there.
| Assignee | ||
Updated•7 months ago
|
| Assignee | ||
Comment 12•7 months ago
|
||
function writeAndPrintPdfBlob(targetWin, blob) {
const blobUrl = URL.createObjectURL(blob);
const html = `
<iframe id="pdf" src="${blobUrl}" style="width:100vw;height:100vh;border:0"></iframe>
<script>
const f = document.getElementById('pdf');
function go() {
f.contentWindow.print();
}
if (f.contentDocument?.readyState === 'complete') go();
else f.addEventListener('load', go, { once: true });
<\/script>`;
targetWin.document.write(html);
targetWin.document.close();
}
The problem is in this method. window.print() blocks while the print preview is open. If readyState === 'complete', print is called synchronously, the <script> won't continue executing, parsing is blocked, document.write and writeAndPrintPdfBlob won't continue. So the task to run writeAndPrintScreen isn't scheduled till the first print dialog is closed.
Before bug 543435, the iframe loaded asynchronous, so readyState wasn't complete, go ran from an async event handler and didn't block the script block.
Things work fine for me if printing happens async.
:Sergiu, thanks for the report. Photo 3 shows a web page, if the bug occurs on that page, does it only occur in Firefox or also in other browsers like Chrome?
| Assignee | ||
Updated•7 months ago
|
| Reporter | ||
Comment 13•7 months ago
|
||
Thanks for the explanation.
I have already changed my script as a workaround:
- first I open and prepare both windows
- afterwards I use a separate command to trigger print for both tabs
With this modified flow, it works well enough for my use case.
If this can be fixed in Firefox, that would be great. If not, I can continue using this workaround.
I do not use Chrome for this workflow, so I cannot reliably compare the behavior there.
| Assignee | ||
Comment 14•7 months ago
|
||
Great if you have a workaround.
There's nothing for us to fix as window.print() is expected to block and bug 543435 was an intentional change.
Description
•