-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Execution worker.recognize
repeatedly causes "Out of Memory" error in JSFiddle
#920
Comments
Edit: This explanation is not the root cause for this user, however it may be useful for other users experiencing an 'out of memory' error. See comments below. Copying the code from the JSFiddle below for the benefit of other users, as opening will indeed freeze/crash the page. let worker
let i=0;
const x = 50;
const image = document.querySelector('img');
async function OCRImageByTesseract() {
i++;
if (i%x==0) {
worker = worker || await Tesseract.createWorker('eng');
const result = await worker.recognize(image.src);
console.log(i/x, result)
}
requestAnimationFrame(OCRImageByTesseract)
}
// loop start;
requestAnimationFrame(OCRImageByTesseract); Short answer: I believe this would be resolved by switching to using a scheduler rather than using Longer answer: I believe this issue is due to the fact that this code sends new jobs to the worker before the previous job is completed. Workers have no mechanism for queuing jobs--workers were written with the assumption that a new |
Thank you @Balearica Doesn't the below code using const result = await worker.recognize(image.src); What I want to do is just executing |
You're right, my original explanation was incorrect. I was unfamiliar with the I do not know why this code is causing the page to crash in JSFiddle, however I now suspect the issue is with JSFiddle rather than Tesseract.js. I was unable to replicate this issue outside of JSFiddle, even when copy/pasting the exact code from the JSFiddle that crashes. If you are able to replicate this problem using a standard web server, please create a repo with a reproducible example, or alternatively paste an HTML snippet that can be run as a single-file site, and I can look into it further. If the issue cannot be replicated anywhere outside of JSFiddle, then the issue should be raised with that project. |
Thank you @Balearica ! |
I checked same code on CodePen, but this issue cannot be reproducible. |
worker.recognize
repeatedly causes "Out of Memory" errorworker.recognize
repeatedly causes "Out of Memory" error in JSFiddle
If there are some non-appropreate description, point out.
Tesseract.js version (version number for npm/GitHub release, or specific commit for repo)
I beleave the latest version is used because Tesseract is included by the following
script
tag<script src='https://cdn.jsdelivr.net/npm/tesseract.js@5/dist/tesseract.min.js'></script>
Describe the bug
When
worker.recognize
is executed repeatedly,Out of Memory
occurs.To Reproduce
Steps to reproduce the behavior:
In this page,
worker.recognize
executes repeatedly by usingrequestAnimationFrame
and output the result to the consoleOut of Memory
error as the following screenshot before the number reaches 30.Expected behavior
I expected the error doesn't occur and the repeatation of
worker.recognize
can continue.Device Version:
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: