Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: JPX image rendering regression after PR 18204 #18896

Closed
Snuffleupagus opened this issue Oct 13, 2024 · 1 comment · Fixed by #18899
Closed

[Bug]: JPX image rendering regression after PR 18204 #18896

Snuffleupagus opened this issue Oct 13, 2024 · 1 comment · Fixed by #18899
Assignees

Comments

@Snuffleupagus
Copy link
Collaborator

Snuffleupagus commented Oct 13, 2024

Attach (recommended) or Link to PDF file

https://sbc.org.pl/Content/403918/PDF/539_2671.pdf

Web browser and its version

N/A

Operating system and its version

N/A

PDF.js version

Any version after #18204

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

Yes

Is a browser extension

No

Steps to reproduce the problem

Load the linked PDF document in the viewer.

What is the expected behavior?

That the image is correctly rendered.

good

What went wrong?

The image doesn't render, with the following console output:

Warning: Unable to decode image "img_p0_2": "IndexSizeError: Index or size is negative or greater than the allowed amount". [pdf.worker.mjs:348:13](resource://pdf.js/build/pdf.worker.mjs)
Warning: Dependent image isn't ready yet [pdf.mjs:391:13](resource://pdf.js/build/pdf.mjs)

bad

Link to a viewer

No response

Additional context

196affd8e06148041b885ce63df260e4dab5f8e1 is the first bad commit
commit 196affd8e06148041b885ce63df260e4dab5f8e1
Author: Calixte Denizet <calixte.denizet@gmail.com>
Date:   Mon Jun 3 16:09:26 2024 +0200

    Fix decoding of JPX images having an alpha channel

    When an image has a non-zero SMaskInData it means that the image
    has an alpha channel.
    With JPX images, the colorspace isn't required (by spec) so when we
    don't have it, the JPX decoder will handle the conversion in RGBA
    format.

 external/openjpeg/openjpeg.js  |  2 +-
 src/core/base_stream.js        |  4 +--
 src/core/colorspace.js         | 22 ++++++++++++
 src/core/decode_stream.js      | 12 +++----
 src/core/flate_stream.js       |  2 +-
 src/core/image.js              | 82 ++++++++++++++++++++++++++++++------------
 src/core/jpx.js                |  5 +--
 src/core/jpx_stream.js         |  8 ++---
 test/pdfs/isssue18194.pdf.link |  1 +
 test/pdfs/issue11306.pdf.link  |  1 +
 test/pdfs/issue16782.pdf.link  |  1 +
 test/test_manifest.json        | 25 +++++++++++++
 12 files changed, 126 insertions(+), 39 deletions(-)
 create mode 100644 test/pdfs/isssue18194.pdf.link
 create mode 100644 test/pdfs/issue11306.pdf.link
 create mode 100644 test/pdfs/issue16782.pdf.link

Please note: The PDF document renders a bit slow, given the large images, however that's already tracked in #17427.

/cc @calixteman

@calixteman calixteman self-assigned this Oct 14, 2024
calixteman added a commit to calixteman/pdf.js that referenced this issue Oct 14, 2024
@calixteman
Copy link
Contributor

Here's a slightly simplified pdf: I just removed the layers:
issue18896.pdf

calixteman added a commit to calixteman/pdf.js that referenced this issue Oct 14, 2024
calixteman added a commit to calixteman/pdf.js that referenced this issue Oct 14, 2024
calixteman added a commit to calixteman/pdf.js that referenced this issue Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants