-
Notifications
You must be signed in to change notification settings - Fork 88
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
QuickJSContext had no callback with id error when newFunction was called many times #98
Comments
The limitation is due to QuickJS internally having only a uint_16 for "magic" on each function we create. I recently merged an improvement to this, but I didn't release it: #94 |
With #94 released, you'll have a limit of 65535 functions. Beyond that you'll need to do indirection in user-space. Meaning, if you've created 65534 functions (limit - 1), you should create a function that takes a function ID as a JS Number value, and maps that to a host function by reading the number. |
Thank you for reply. I also got that idea and implemented it in quickjs-emscripten-sync. reearth/quickjs-emscripten-sync#21 It calls newFunction only once and it saves all funcImpl to the map with a number. I will try it and confirm if it works in our environment. |
Sounds good 😄 |
prints
(this test code was executed on vitest)
Note that If the number of repetitions is small, no error occurs.
Although 50,000 times may seem like a lot, it is an error that is realistically encountered in a code of a certain size.
The text was updated successfully, but these errors were encountered: