Closed Bug 1729199 Opened 4 years ago Closed 3 years ago

Blank pages on some PDF files

Categories

(Firefox :: PDF Viewer, defect, P3)

Firefox 91
defect

Tracking

()

RESOLVED DUPLICATE of bug 1720282
Tracking Status
firefox93 --- affected

People

(Reporter: starline98, Unassigned)

Details

(Whiteboard: [pdfjs-canvas-size])

Attachments

(3 files)

Attached image 1.png

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0

Steps to reproduce:

Open PDF file with Firefox browser

Actual results:

PDF opens with blank pages

Expected results:

File must be opened not with blank pages

The Bugbug bot thinks this bug should belong to the 'Firefox::PDF Viewer' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.

Component: Untriaged → PDF Viewer

Reproduced on latest Nightly 93.0a1 2021-09-06 under Win 10 64-bit.
This particular pdf was blank also on older Fx versions, like 63.0a1.

Severity: -- → S4
Status: UNCONFIRMED → NEW
Ever confirmed: true

The console shows:

Message: 
Stack: putBinaryImageData@resource://pdf.js/build/pdf.js:4895:11
paintInlineImageXObject@resource://pdf.js/build/pdf.js:6638:25
paintImageXObject@resource://pdf.js/build/pdf.js:6589:10
executeOperatorList@resource://pdf.js/build/pdf.js:5241:20
....

I can reproduce the bug using pdf.js from upstream and a local server with Firefox nightly but it works well in chrome.
So it's likely a Firefox issue, the guilty line is:
https://github.com/mozilla/pdf.js/blob/d95f680d66dd46e2995a7784109a1b3af2b84bdd/src/display/canvas.js#L596

In checking stderr with a local build, I get this:
Crash Annotation GraphicsCriticalError: |[C0][GFX1-]: Failed to allocate a surface due to invalid size (CDT) Size(9927,14043) (t=38.0922) [GFX1-]: Failed to allocate a surface due to invalid size (CDT) Size(9927,14043)

It opens well in Edge too. Hope you guys can figure out what's wrong cause i don't understand all these codes 😀

Increasing gfx.max-alloc-size to 600000000 in about:config fixes the issue.
The default value for this pref is 500000000 and here we're requesting 9927 * 14043 * 4 = 557619444 bytes.
So we should likely find a way in pdf.js to split too big images into tiles.

Nice! 👍

Is pdf.js canvas2d-only, or does it have a webgl path too?

canvas2d only

:jgilbert, could we consider to increase the value of gfx.max-alloc-size to have the same as in Chrome ?

That would only be a bandaid, as some hardware/drivers cannot support higher values. (and therefore we're probably not robust to them failing, if we did raise this higher than they support) ~500MB is the lowest maximum allocation size that DirectX supports, though this scales upwards based on GPU RAM size. To avoid problems where this works on some devices and not others, it can be useful to have just one limit that's universal.

This is a constraint that we should be surfacing up the stack from the browser back to the application.
We may need a new API for this, if we don't have one already. (It doesn't look like we have one)
On WebGL this is handled by OUT_OF_MEMORY errors.

Therefore:

  1. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/canvas#maximum_canvas_size needs to be updated, and
  2. the web platform needs a way to tell apps that an allocation like this failed, and
  3. pfd.js will need to be able to deal with limits being too small for some allocations.

A fourth thing to consider is downgrading a gpu-accelerated canvas to cpu-accelerated, which lets us have basically arbitrarily large canvases (memory allowing) but is considerably slower for operations that touch large parts of the canvas. I'm unsure if we have code to handle this live-downgrading yet.

Could the difference with Chrome cause web compat issues other than pdf.js? Or is this mostly a corner case?

Possible web-compat for sure, but likely quite rare. Worth noting though that if it fails on Firefox, then there are machines for which it likely fails on Chrome.
The largest canvas sizes we expect from most content are full-screen resolution sizes, which plateaus around 4k (32MB) or so. "8k" is still only 128MB.

See Also: → 1492303
Whiteboard: [pdfjs-canvas-size]

The severity field for this bug is relatively low, S4. However, the bug has 3 duplicates.
:calixte, could you consider increasing the bug severity?

For more information, please visit auto_nag documentation.

Flags: needinfo?(cdenizet)
Severity: S4 → S2
Flags: needinfo?(cdenizet)
Priority: -- → P3
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: