Closed Bug 1839456 Opened 1 year ago Closed 1 year ago

Optimize Printing to Setup PDF File Resource in the Background

Categories

(GeckoView :: General, defect, P1)

All
Android
defect

Tracking

(firefox114 wontfix, firefox115 wontfix, firefox116 fixed)

RESOLVED FIXED
116 Branch
Tracking Status
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: nobody → ohall
Severity: -- → S3
Has STR: --- → yes
Priority: -- → P1
Whiteboard: [geckoview:m116][fxdroid][foundation]
Blocks: 1808755
See Also: → 1836780

This patch updates the GeckoViewPrintDocumentAdapter to make the PDF
file required for printing in the background.

Pushed by ohall@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/d170b8ded504 GeckoView Setup Print Optimization r=geckoview-reviewers,amejiamarmol
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 116 Branch

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-firefox115 to wontfix.

For more information, please visit BugBot documentation.

Flags: needinfo?(ohall)

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.

Flags: needinfo?(ohall)
Component: Core → General
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: