Optimize Printing to Setup PDF File Resource in the Background
Categories
(GeckoView :: General, defect, P1)
Tracking
(firefox114 wontfix, firefox115 wontfix, firefox116 fixed)
People
(Reporter: olivia, Assigned: olivia)
References
(Blocks 1 open bug)
Details
(Whiteboard: [geckoview:m116][fxdroid][foundation])
Attachments
(1 file)
When printing on some large webpages or pages with lots of assets (which generate very large PDFs to print), printing can sometimes cause a ANR timeout.
STR: Using GeckoView Example, visit a larger PDF or webpage on a lower powered device such as moz-emulator. ... -> Print Page. Sometimes an ANR will appear. Trying to print a larger PDF with a lot of assets will sometimes reproduce the bug. Printing mozilla.org will occasionally reproduce as well. Reproducing is not consistent.
Too much work is happening in onStart in GeckoViewPrintDocumentAdapter, onStart runs on the main UI thread.
The work that is occurring on the main thread is making a copy of the PDF required for printing, so it is available for later use for resizing etc. in onWrite.
The code needs to be optimized to use mPdfInputStream for the first onWrite, but also makes a copy of the PDF for subsequent onWrites or else move the work into the background or similar.
(To demonstrate the requirement for needing a copy of the PDF, remove mPdfFile and use only mPdfInputStream in onWrite. Then print, which should work as expected initially, but then attempt to resize from the Android Print menu. Without the copy of the file, Android doesn’t have a reference PDF to adjust.)
Care also needs to be taken to ensure the correct loading UI is shown while the preview generates. This is one of the reasons the code was in onStart initially too.
| Assignee | ||
Updated•3 years ago
|
Updated•3 years ago
|
| Assignee | ||
Updated•3 years ago
|
| Assignee | ||
Comment 1•3 years ago
|
||
This patch updates the GeckoViewPrintDocumentAdapter to make the PDF
file required for printing in the background.
Comment 3•3 years ago
|
||
| bugherder | ||
Comment 4•3 years ago
|
||
The patch landed in nightly and beta is affected.
:olivia, is this bug important enough to require an uplift?
- If yes, please nominate the patch for beta approval.
- If no, please set
status-firefox115towontfix.
For more information, please visit BugBot documentation.
| Assignee | ||
Comment 5•3 years ago
|
||
I would like this fix to remain in Nightly a little longer. I don't have an impression that the issue happens frequently in earlier releases, which only have window.print. This bug is more an issue when it is possible to print any page from the menu, including very large documents.
Updated•3 years ago
|
Updated•2 years ago
|
Description
•