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

Support OffscreenCanvas #766

Merged
merged 2 commits into from
May 30, 2023
Merged

Conversation

nathanbabcock
Copy link
Contributor

  • Handle OffscreenCanvas in browser loadImage function
  • Update ImageLike type to include OffscreenCanvas
  • Add unit test covering recognize from an OffscreenCanvas
  • If OffscreenCanvas is not supported in the browser, the relevant branch in loadImage will be safely skipped over without any errors

Other references:

@Balearica
Copy link
Member

This implementation breaks Tesseract.js for users who do not have a browser that supports OffscreenCanvas, which includes all non-Chromium users who have not updated their browser recently. I'm not opposed to adding handling for OffscreenCanvas inputs, but that aspect needs to be fixed.

@nathanbabcock
Copy link
Contributor Author

You're quite right of course.

The check I was using -- if(OffscreenCanvas) -- was inadequate and it still produced a ReferenceError in older browsers. I've replaced this with if (typeof OffscreenCanvas !== 'undefined'). To verify this, I downgraded to an older version of Firefox, v72.0.2 from January 2020, which does not natively support OffscreenCanvas. Before this change, I saw an error when running the Tesseract.js demo app -- after the commit, it works smoothly.

Thanks for your time and let me know if you notice any other problems.

@Balearica
Copy link
Member

Thanks for editing, as well as checking using the old version of the browser. The new implementation looks good, I will merge.

@Balearica Balearica merged commit a5f10d8 into naptha:master May 30, 2023
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

Successfully merging this pull request may close these issues.

2 participants