Closed Bug 1809422 Opened 2 years ago Closed 1 year ago

"Unable to generate PDF"/"Unable to print" Error when the Content Frame is not Selected During Save to PDF/Printing

Categories

(GeckoView :: PDF Viewer, defect, P1)

Firefox 110
All
Android
defect

Tracking

(firefox110 wontfix, firefox113 wontfix, firefox114 wontfix, firefox116 wontfix, firefox117 wontfix, firefox118 fixed)

RESOLVED FIXED
118 Branch
Tracking Status
firefox110 --- wontfix
firefox113 --- wontfix
firefox114 --- wontfix
firefox116 --- wontfix
firefox117 --- wontfix
firefox118 --- fixed

People

(Reporter: dpop, Assigned: olivia)

References

Details

(Whiteboard: [PDF reader][geckoview:m113][geckoview:m114][geckoview:m115][geckoview:m117?][geckoview:m118][fxdroid][foundation])

Attachments

(4 files)

Attached video UnableToGeneratePDF.mp4

Steps to reproduce

  1. In about:config, set the pdfjs.disabled pref to false.
  2. Open a PDF file.
  3. Tap on the 3 dot-menu > Tap on the Share icon > Tap on "Save as PDF" option.
  4. Observe the error displayed at the bottom of the page.

Expected behavior

A download dialogue is displayed.

Actual behavior

The "Unable to generate PDF" error is sometimes displayed when attempting to save a PDF.

Device information

  • Firefox version: Nightly 110.0a1 from 01/10
  • Android device model: Google Pixel 6,
  • Android OS version: Android 13

Any additional information?

Clear STR could not be established since the error was only displayed on a several occasions, of different PDF files which could be downloaded in previous sessions.
Note that upon receiving the error, the PDF can be downloaded after performing some scrolling on the PDF before attempting to save the PDF again.

Blocks: 1803753

I was able to replicate this behavior on a regular website HTML page as well as a .pdf through:

  • Navigate to any website, I used www.mozilla.org
  • Avoid touching the content frame. (Works as expected if the content frame is touched.)
  • Dot menu -> Share -> Save as PDF
Summary: Intermittent "Unable to generate PDF" error displayed when attempting to save a PDF → "Unable to generate PDF" Error when the Content Frame is not Selected During Save to PDF
Severity: S3 → S2

Should we consider this bug for 111?

Whiteboard: [PDF reader] → [PDF reader] [geckoview:m111?]
Rank: 200
Priority: -- → P2
Whiteboard: [PDF reader] [geckoview:m111?] → [PDF reader]

Updating this to the GeckoView product just to prevent it from accidentally falling into Experience team backlog.

Product: Fenix → GeckoView
See Also: → 1814064

I looked a little more into this when looking at bug 1814064, which I think is related. It is erroring out around here for both bugs. Also, the InputStream stream needs to be explicitly closed before completing exceptionally - saw a log warning.

I had more issues reproducing this exactly in an emulator than I did when testing on a real device (still possible, but not as easy to replicate), just mentioning for future reference.

Removing this from blocking bug 1803753 because this is not specific to PDFs.

No longer blocks: 1803753

I'm looking into this primary attribute, which could be the main reason GetContentCanonicalBrowsingContext fails. Nika recommended looking into this attribute on the Fission Matrix channel, for more info.

primary is used on desktop to track tab state; however, GeckoView follows a one window = one tab pattern. It seems like it may be safely removed, but the removal requires more investigation. Early testing looked like it solves the "Unable to Generate PDF" issue in this case, but I need to test more on a real device.

Whiteboard: [PDF reader] → [PDF reader][geckoview:m113?]
Assignee: nobody → ohall
Priority: P2 → P1
Whiteboard: [PDF reader][geckoview:m113?] → [PDF reader][geckoview:m113]
Whiteboard: [PDF reader][geckoview:m113] → [PDF reader][geckoview:m113][geckoview:m114]
Component: General → PDF Viewer

Still investigating how best to solve the bug. Setting it as P2 for now, since I'm working on a few other bugs first. I can confirm the primary attribute state is a root cause of this bug and found a consistent reproduction of the bug.

How to Reproduce Consistently:

  • Open a tab, e.g. mozilla.org (Tab 1)
  • Make a new tab, e.g., getpocket.com (Tab 2), and quickly switch back to Tab 1 from Tab 2, before Tab 2 completes loading
  • After switching back to Tab 1, ... -> Share -> Save to PDF
    • Bug should reproduce at this point. If the bug doesn't reproduce, try loading a larger page in Tab 2 and switching back to Tab 1. May also need to avoid touching the browser frame (only touch toolbar).
    • Sometimes, after causing this state, the bug will consistently happen.

Items to continue investigating:

  • Investigate why non-primary/primary is set to begin with in GeckoView
  • Investigate setFocused callers
  • Investigate what is occurring in Fenix:
    • Is the app purposely unsetting focus?
    • Is the app not setting focus on a tab switch, if something else is loading in the background?
    • Is something else taking the focus on Android, which then causes the browser focus to be lost/unset? (i.e., the other tab or a menu?)
Priority: P1 → P2
Whiteboard: [PDF reader][geckoview:m113][geckoview:m114] → [PDF reader][geckoview:m113][geckoview:m114][geckoview:m115]
Duplicate of this bug: 1814064
Whiteboard: [PDF reader][geckoview:m113][geckoview:m114][geckoview:m115] → [PDF reader][geckoview:m113][geckoview:m114][geckoview:m115][geckoview:m117?]

I think this bug might impact bug 1808755 for printing too because they both get the browsing context similarly.

See Also: → 1808755
Whiteboard: [PDF reader][geckoview:m113][geckoview:m114][geckoview:m115][geckoview:m117?] → [PDF reader][geckoview:m113][geckoview:m114][geckoview:m115][geckoview:m117?][fxdroid][foundation]
Summary: "Unable to generate PDF" Error when the Content Frame is not Selected During Save to PDF → "Unable to generate PDF"/"Unable to print" Error when the Content Frame is not Selected During Save to PDF/Printing
Whiteboard: [PDF reader][geckoview:m113][geckoview:m114][geckoview:m115][geckoview:m117?][fxdroid][foundation] → [PDF reader][geckoview:m113][geckoview:m114][geckoview:m115][geckoview:m117?][geckoview:m118?][fxdroid][foundation]
Attached video UnabletoPrintContent

Steps to Reproduce Unable to Print:

  1. Open a page, e.g., wikipedia.org
  2. Touch empty content area to gain focus
  3. New tab, e.g., google.com (do not touch content)
  4. Return to first page, e.g. wikipedia.org
  5. Attempt to print, will receive "Unable to Print" error

The canonical browsing context is not available if the current window/tab
is not focused for printing or saving as a PDF.

This patch adds a call to setFocused before creating a Gecko PDF to
ensure the canonical browsing context can be used for generating a PDF
to save or print.

Has STR: --- → yes
Priority: P2 → P1
Whiteboard: [PDF reader][geckoview:m113][geckoview:m114][geckoview:m115][geckoview:m117?][geckoview:m118?][fxdroid][foundation] → [PDF reader][geckoview:m113][geckoview:m114][geckoview:m115][geckoview:m117?][geckoview:m118][fxdroid][foundation]
Pushed by ohall@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/c6ccd7f0c8b3 Android Unable to Print/Save PDF r=geckoview-reviewers,calu
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 118 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: