Closed Bug 1831223 Opened 2 years ago Closed 2 years ago

GeckoView Window.Print Needs to Block Multiple Calls

Categories

(GeckoView :: General, defect, P1)

All
Android
defect

Tracking

(firefox112 unaffected, firefox113+ disabled, firefox114+ fixed, firefox115+ fixed)

RESOLVED FIXED
115 Branch
Tracking Status
firefox112 --- unaffected
firefox113 + disabled
firefox114 + fixed
firefox115 + fixed

People

(Reporter: olivia, Assigned: olivia)

References

Details

(Keywords: sec-low)

Attachments

(3 files, 2 obsolete files)

Attached file multi-print.html

Window.Print() on Android calls the Android Print Spooler to print.

This bug creates a trap where users cannot easily navigate away and can even lead to OOM.
To replicate, attach to a debugger on Android and call window.print() many times from the about:debugging content console or use the sample file.

The sample file calls window.print() ten times. Calling it 1000+ times by making the loop larger can lead to an out of memory condition in the print spooler and crash. (Tested using mozemulator and GeckoView Example.)

--------- beginning of crash
 2101  2101 E AndroidRuntime: FATAL EXCEPTION: main
 2101  2101 E AndroidRuntime: Process: com.android.printspooler, PID: 2101
 2101  2101 E AndroidRuntime: java.lang.OutOfMemoryError: Failed to allocate a 2134020 byte allocation with 1888304 free bytes and 1844KB until OOM
 2101  2101 E AndroidRuntime: 	at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
 2101  2101 E AndroidRuntime: 	at android.graphics.Bitmap.nativeCreate(Native Method)
...

A similar bug is this one. A condition to prevent continually adding static clones was added to prevent using the beforeprint to call for another print. However, this bug is occurring after window.print() releases the static clone, but while the dialog is still open and another window.print() call is made. A possible solution is to not release the static clone until the Android PrintJob resolves as completed by the PrintManager.

Users may also be trapped on Desktop (can't navigate back and previews appear until finished), but do not experience OOM as on Android.

Group: partner-confidential

This being an S1 severity issue suggests that it should be a release blocker for 113 and an RC respin driver. Is that accurate, Olivia? If so, I need a patch ASAP to either address this or disable the feature to avoid putting Tuesday's launch at risk.

Assignee: nobody → ohall
Blocks: 1659818

Added an additional print option to PrintDelegate to have more
infromation on print status.

Severity: S1 → S2
Keywords: sec-low
Priority: P1 → --
Priority: -- → P1
Flags: needinfo?(ohall)

Added an additional print option to PrintDelegate to have more
infromation on print status.

Attachment #9331630 - Attachment is obsolete: true

Per Slack discussion with the various stakeholders, we decided to slip the feature to 114 in order to allow for more bake time. The disabling has been landed for 113.0 RC2.
https://hg.mozilla.org/releases/mozilla-release/rev/484eaf4a9552

Comment on attachment 9331650 [details]
Bug 1831223 - Added GeckoView Print Status

Beta/Release Uplift Approval Request

  • User impact if declined: The print status information should ride the trains with the feature for window.print on Android.
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: No
  • Needs manual test from QE?: No
  • If yes, steps to reproduce: This feature can be tested via visiting a website that includes a print button. For example, many recipe websites include a print button.
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): This adds print status information for GeckoView window.print.
  • String changes made/needed: None
  • Is Android affected?: Yes
Attachment #9331650 - Flags: approval-mozilla-beta?

MC 115 patch. (Not sure why it didn't link as an attachment yet.)

Added an additional print option to the PrintDelegate to have more
information on print status.

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

Attachment #9332909 - Flags: approval-mozilla-beta?

Added an additional print option to the PrintDelegate to have more
information on print status.

(In reply to Sebastian Hengst [:aryx] (needinfo me if it's about an intermittent or backout) from comment #9)

Landed: https://hg.mozilla.org/integration/autoland/rev/06b409d9ea9549f2b9cdb4da4d4c96aaef295507

Backed out for causing linting failures for GeckoSession.java:
https://hg.mozilla.org/integration/autoland/rev/8e4e2a61e41e044d6ab484b435c8a01b3c604596

Apologies, I ran the wrong linter locally. Updated and resubmitted. I'll fix the lints for beta uplift here shortly too.

Flags: needinfo?(ohall)
Attachment #9331650 - Attachment is obsolete: true
Attachment #9331650 - Flags: approval-mozilla-beta?
Attachment #9332909 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Group: mobile-core-security → core-security-release
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 115 Branch
Attachment #9332909 - Flags: approval-mozilla-beta+ → approval-mozilla-beta?

Comment on attachment 9332909 [details]
Bug 1831223 - Added GeckoView Print Status

Approved for Desktop 114.0b6 and Fenix/Focus 114.0b6.

Attachment #9332909 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Group: core-security-release
Component: Web APIs → General
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: