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]: v4.8.69 update to 3.x canvas - Cannot assign to read only property #19046

Closed
prescottprue opened this issue Nov 14, 2024 · 2 comments
Closed

Comments

@prescottprue
Copy link

prescottprue commented Nov 14, 2024

Attach (recommended) or Link to PDF file

N/A

Web browser and its version

JSDom 25.0.1, Chrome 131.0.6778.70

Operating system and its version

Ubuntu 22

PDF.js version

v4.8.69

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

Yes

Is a browser extension

No

Steps to reproduce the problem

  1. Install v4.8.69 of pdfjs-dist
  2. Attempt to use canvas API such as canvas.getContext (as described in Mozilla MDN docs):
    const canvasCtx = document.createElement('canvas').getContext('2d')
  3. See Cannot assign to read only property error such as Cannot assign to read only property 'createPattern' of object '#<CanvasRenderingContext2D'

What is the expected behavior?

Its expected that using the canvas API continues to work as as described in Mozilla MDN docs as it did in v4.7.76

What went wrong?

v4.8.69 of pdfjs-dist updates to canvas v3.0.0 RC which has a known issue in canvas with read only properties (a PR has been merged to fix this but has not been released yet)

Link to a viewer

No response

Additional context

No response

@Snuffleupagus
Copy link
Collaborator

Fixed by PR #19015.

@jacob-israel-turner
Copy link

jacob-israel-turner commented Nov 21, 2024

Thanks for fixing this @Snuffleupagus! It'll be nice to not have to wrestle with canvas going forward.

Any idea when the next release will be cut? I'm still encountering this bug on v4.8.69, and I haven't found a workaround.

EDIT: I found a workaround - downgrading canvas to 2.x fixes the issue. IDK if there are any incompatibility issues with pdf.js v4.8.69 though. Canvas 2.x does not work in workers either. I'm still looking forward to #19015 shipping!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants