-
-
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
Error on iOS 17: RuntimeError: call_indirect to a null table entry #804
Comments
Is this issue specific to the Next.js repo, or could this also be replicated using the basic examples in this repo? Unfortunately my ability to troubleshoot this is limited. I do not own an iOS device and Browserstack (a service that allows us to connect to iOS devices remotely for testing purposes) has not yet added iOS 17. It appears that a similar error existed for the iOS 15.4 beta, so it seems at least possible that this is an issue on Apple's end that will be resolved before the release. https://forum.unity.com/threads/fatal-error-with-webgl-running-on-15-4.1244374/ |
Thanks for the quick response! Using a slightly modified Totally possible that it may be an Apple issue, and will keep an eye out on future betas to see if this issue still exists. Not sure if you're on a Mac, but you may be able to use the iOS simulator in an attempt to reproduce this as well. Either way, figured I'd open an issue to give insight to others running into this issue/notify you guys as I have very little knowledge of the inner workings of Tesseract & WASM :) |
Makes sense, thanks for reporting. Can follow up closer to the release of iOS 17. |
Has there been an investigation and resolution on this? I am also getting an error on iOS 17 - RunTimeError: call_indirect to a null table entry (evaluating .....TessBaseAPI_GetUTF8Text_0=b.asm.Kd).apply(null,argumnets)') |
@MayuraRam Tesseract.js v2 was released in 2019 and is depreciated/unsupported. That version has poor performance and many bugs including (if I recall correctly) some specific to iOS. Therefore, I would strongly advise updating to a recent version. A guide for updating to the latest version can be found in #771. Regarding the iOS 17 issue, Browserstack did recently add iOS 17, so I was able to test using the demo site. Everything worked as expected. Therefore, I think that my theory above (that this is an issue on Apple's end with early beta versions of iOS) was correct. Along those lines, you should check if you are using the latest version of iOS 17, and if not, update to the latest version. |
Thanks @Balearica - What's the best way to get "tesseract-core.wasm.js" corresponding to the latest release? |
If you do not set the Important note: in previous versions of Tesseract.js, |
@Balearica - I am running iOS 17 beta on an actual iPhone. I am running tesseract.js-core-4.0.4\tesseract.js-core-4.0.4\examples\web\benchmark\benchmark.wasm.html from the latest release package mentioned above. I am getting the same error - Unhandled Promise rejection: RuntimeError: call_indirect to a null table entry (evaluating'(Vf=b._emscripten_bind_TessBaseAPI_GetUTF8Text_0=b.asm.Kd).apply(null, arguments)') seeing the same issue on Chrome when running on iPhone with iOS 17 beta. How could I resolve this issue? Thanks for your help! |
@MayuraRam Can you please confirm the following?
|
The demo site works on Safari on the device with iOS 17.0 (21A329) - Downloaded and installed today. Does the demo site use tesseract-core.wasm.js? You mentioned "Tesseract.js" - does this load the wasm version? |
The demo site I linked loads the latest version of the Therefore, as your device was capable of running recognition using this |
Also, for both sites (the demo I linked and whatever you are running) I would be sure that the cache/local files are cleared. When there is an issue that cannot be replicated, cache is a common cause. |
Thanks @Balearica - I verified that the demo code is downloading https://cdn.jsdelivr.net/npm/[email protected]/tesseract-core-simd.wasm.js. This is the code that is not causing a problem. I am trying to use Tesseract.js-core directly - as in the sample code here - https://github.com/naptha/tesseract.js-core/blob/master/examples/web/benchmark/benchmark.wasm.html. It does not use Tesseract.recognize nor worker.recognize. I tried this sample code - https://github.com/naptha/tesseract.js-core/blob/master/examples/web/benchmark/benchmark.wasm-simd.html as well and am seeing the same issue. With this I use tesseract-core-simd.wasm.js directly I am still seeing the same issue when loading directly. |
Given you confirmed Tesseract.js-core v4.0.4 is being downloaded and run within the example code I linked, the errors you are describing must be specific to your project setup, server configuration, or the particular example code you are using. However, just to make sure, I created a minimal repo based on one of the Tesseract.js-core examples and hosted it at https://tesseract-js-core-example.pages.dev/. I tested on iOS 17, and recognition worked as expected. The repo can be found here. Therefore, between this and the earlier tests, I think we can conclude that iOS 17 is compatible. In general, if you use low-level Tesseract.js-core functions rather than the functions in this repo, that is not something we can offer much documentation or support for. The Tesseract.js-core repo exists separately in case advanced users/developers want to build their own version of Tesseract.js with custom wrapper functions or a forked version of Tesseract. |
@Balearica - Thank you for taking the time to setup the sample. That helped me debug. I was using a jpg image (test.jpg) for my testing. Looks like this jpg image is causing the issue on iOS 17 beta. I tried the image with https://tesseract-js-core-example.pages.dev/. There is no problem with other test images, but test.jpg image causes the issue. I then took a screenshot of the image on the iPhone and saved the image as screenshot_2.png. When I use this image I see no problems. I am trying to understand why this could be happening. How can I learn more about why this particular image is causing an issue? |
Many images fail on MacOS with Safari Tech preview with the sample provided at " https://tesseract-js-core-example.pages.dev/" . There is a commit on Webkit which could be connected with the issue. |
@MayuraRam To clarify a couple points above--
Do all
Are the images that fail for MacOS + Safari tech preview the same images that fail on iOS 17? (E.g. does the |
@Balearica - What I mean by "There is no problem with other test images" - the test images at https://github.com/naptha/tesseract.js-core/blob/master/examples/web/benchmark - meditations.jpg, testocr.png and tyger.jpg Re: "Are the images that fail for MacOS + Safari tech preview the same images that fail on iOS 17? (E.g. does the .jpg image you attach fail on MacOS + Safari tech preview?) If so, are the error messages the same?" yes - test.jpg fails and the error message is the same. |
Let me know if you encounter this issue on any images that are not All in all, this is a bizarre issue. I am limited by not owning Apple devices, and was unable to replicate this using the Linux version of webkit in the repo you linked. Unfortunately, while the error can be replicated on the Browserstack devices we can connect to virtually in the sense that recognition does not run, they are not producing the error messages. I may be able to get a hold of an Apple device later in the week. |
@Balearica - attached Tyger.png has the same issue. Let me know if I can provide any other information that could help debug the issue. I think the problem is in this function - function UTF8ArrayToString(u8Array, idx, maxBytesToRead) |
Can you clarify what this is based on? I am not seeing a function of this name anywhere in the codebase. |
@Balearica Apologies - That function is in the earlier version of tesseract-core.wasm.js, which I have been trying to debug as well. I will try to investigate the current (v4.0.4) tesseract-core.wasm.js. |
@aw-0 @MayuraRam Can somebody explain their exact process for producing the |
@MayuraRam It looks like this issue is caused by the Legacy model. As background: Tesseract includes 2 models--LSTM and Legacy. By default, the LSTM model is used. If the LSTM model fails to produce a result it believes is valid (which occurs for a small minority of words), the Legacy model attempts to recognize that word. This behavior appears to be why the issue only occurs for specific images. For many images, the Legacy model will never be run using default settings--however for some images it will be for specific words. As a test, I created an additional 2 versions of the test site:
[Note: I added some additional debugging messages to the Tesseract.js-core builds used in these pages, so you may notice additional messages being printed to console. The original page (https://tesseract-js-core-example.pages.dev/) still uses the release build.] My testing indicates that unlike the earlier tests (where specific images failed but others were recognized correctly), the LSTM-only version always runs properly and the Legacy-only version always fails. Please confirm this is true of all of your test images. Unless anybody identifies images that contradict the above conclusions, the fix I will prioritize is disabling the Legacy model by default, which is already planned for Version 5 (see #820). While an ideal fix would allow both the Legacy and LSTM models to run on iOS 17, there is no telling how long this would take to troubleshoot (much less fix). |
@Balearica - I have verified that the images that were failing earlier are now passing with LSTM-only on an iPhone with iOS 17.0.1 (and iOS 17.0). In addition (FYI): When I ran images that were working with the default LSTM + Legacy, they fail with Legacy only. Thank you for identifying the location of the issue and providing a work around. Could you please provide instructions on how to build "tesseract-core.wasm.js"? I could try to build a LSTM-only version with the files tagged "[v4.1.2]" |
@MayuraRam Can you clarify whether your are able to produce the "RuntimeError: call_indirect to a null table entry" with any of the example pages, and if so, what your process is? I will release an official version of Tesseract.js-core that includes a LSTM-only build in the next few days. Will update this issue once that happens. |
@Balearica - Re your question: Yes - this example fails with iOS 17.0.1 - examples/web/benchmark/benchmark.wasm.html with "RuntimeError: call_indirect to a null table entry" Setup the iPhone for debugging by going to settings-> Safari-> Advanced. Scroll down to find "Web Inspector" and turn it on. Open Safari on a Mac Book and go to Safari->Settings. Select "Advanced" tab and turn on Show Develop menu in the menu bar. Then connect the iPhone to a MacBook. From Develop menu on MacBook Safari you should see the connected iPhone. Run the example pages on an iphone with iOS 17.0 ( and now iOS 17.0.1). Then look at the console from develop menu on the MacBook. Here's a good description. |
@MayuraRam By "the example pages" I mean the example pages that we've been working with over the last week (listed below). Do you observe the "RuntimeError: call_indirect to a null table entry" message when you use any of these pages? |
@Balearica Please see below: |
@MayuraRam While Tesseract.js v5 has not been released yet, if you only use Tesseract.js-core you should can use a build found in that repo or in the Tesseract.js-core v5 beta release on npm. The files for the LSTM-only build would be tesseract-core-simd-lstm.wasm.js (should be served to the vast majority of users) and tesseract-core-lstm.wasm.js (served to the minority of users that have old browsers that lack SIMD support). |
Closing this issue as Tesseract.js v5 has been released, which should be fully compatible with iOS 17 by default (as it only uses the LSTM model by default). If any users encounter issues with iOS 17, upgrading to v5 should resolve. I will open a new Git Issue regarding how the Legacy engine is still not compatible with iOS 17, however I doubt many users use the Legacy model, so that is a much smaller issue. |
@Balearica - Thank you for the quick resolution. |
To close the loop on this--this issue appears to be fixed by Apple in iOS |
Yes - we have verified this as well. |
Tesseract.js version (version number for npm/GitHub release, or specific commit for repo)
4.1.1
Describe the bug
On iOS 17's Safari/WebKit, when
Tesseract.recognize
is called, the following runtime error will occur:Error: RuntimeError: call_indirect to a null table entry (evaluating '(Rf=b._emscripten_bind_TessBaseAPI_Recognize_1= b.asm.Gd).apply(null,arguments)')
This does not occur on devices running iOS 16, or any other desktop OS/browser.
To Reproduce
Steps to reproduce the behavior:
Image used to generate error:
Expected behavior
Tesseract will recognize the text in the image and output successfully.
Device Version:
Additional context
I have created a repo to assist in reproduction, available here
The text was updated successfully, but these errors were encountered: