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

Chrome: Failed to execute 'getImageData' on 'OffscreenCanvasRenderingContext2D' #8

Closed
stereobooster opened this issue Dec 8, 2022 · 3 comments

Comments

@stereobooster
Copy link

I got this error in Chrome for image from remote server

Uncaught (in promise) DOMException: Failed to execute 'getImageData' on 'OffscreenCanvasRenderingContext2D': The canvas has been tainted by cross-origin data.
    at t2 (http://localhost:3000/node_modules/.vite/deps/@undecaf_barcode-detector-polyfill.js?v=0927827e:104:41)
@undecaf
Copy link
Owner

undecaf commented Dec 8, 2022

You might try <img crossorigin="anonymous"> in the markup (as in the example)
or image.setAttribute('crossOrigin', 'anonymous') on the Image object before loading the image from the remote server.

This article presents a more in-depth explanation: https://inspirnathan.com/posts/105-fix-tainted-canvas-from-cross-origin-error/

@stereobooster
Copy link
Author

Hey 👋

First of all thank you for this library.

I probably poorly worded bug report. The problem is that this promise rejection isn't handled. I would expect detect function to reject with this error. I can make a PR to fix (I didn't check code, but it should be easy to find)

@undecaf undecaf closed this as completed in 8f30742 Dec 9, 2022
@undecaf
Copy link
Owner

undecaf commented Dec 9, 2022

Ahh... I understand now what you meant, and I have fixed detect() to return a rejected Promise in error cases.

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

2 participants