Skip to content

[Bug]: Cannot render some* PDFs with .jp2 embedded images #19517

@gsamokovarov

Description

@gsamokovarov

Attach (recommended) or Link to PDF file

pdf-with-jp2.pdf

Web browser and its version

Chrome, Arc, Firefox, Microsoft Edge

Operating system and its version

macOS 14.7.4

PDF.js version

4.10.38

Is the bug present in the latest PDF.js version?

Yes

Is a browser extension

No

Steps to reproduce the problem

  1. Upload the attached PDF to a pdf.js-based viewer.
  2. See a blank image instead of a red image spawning the whole document.

What is the expected behavior?

Display the .jp2 image embedded in the PDF document.

What went wrong?

No image was displayed in the document

Link to a viewer

No response

Additional context

I'm running into issues rendering PDFs with some embedded .jp2 images. The document is loaded, but the image is not rendered. I see that pdf.js has a WASM compiled openjpeg-based JPX decoder. However, it can not decode the picture embedded in the document and issues the following warning in the browser dev tools console:

Warning: Unable to decode image "img_p0_1": "JpxError: Size of tile data exceeds system limits

Failed to decode.

Failed to decode tile 1/1

Failed to decode the codestream in the JP2 file

Failed to decode the image".

My limited debugging leads me to believe that we are hitting some of the branches issuing this error (here is an example) because of the 32-bit memory model WASM compiled build. I may be wrong here, and I need help debugging the exact C code branch that is giving the warning and what we can do about it. I also see that browsers are starting to support 64bit WASM, again I'm not sure if compiling a 64-bit WASM openjpeg build is the proper solution as browsers are just starting to support this.

I am attaching a document for testing. The native Chrome PDF viewer (pdfium) and macOS Preview can display the document. Interestingly, pdfium also uses openjpeg to decode the image, but I guess the 64-bit native build handles such images.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions