You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've noticed an issue when using Javascript callbacks and ASYNCIFY_IGNORE_INDIRECT. If wakeUp is called in a nested callback it will raise function signature mismatch with -O3 and unreachable otherwise. With -O3 the function call still works as expected, emscripten is woken up and parameters are passed correctly, it just raises the runtime error.
Is this the desired behaviour? From what I understand the indirect call only refers to a C++ indirect call?
<html><head><scripttype="text/javascript" src="a.out.js"></script><scripttype="text/javascript">Module({// First callback, raises an error when wakeUp is calledcallback: (wakeUp)=>{setTimeout(()=>{console.log("First callback")wakeUp();},0);}}).then((module)=>{console.log(module)window.MODULE=module})// Second callback, works without raising an errorsetTimeout(()=>{window.MODULE.callback=(wakeUp)=>{console.log("Second callback")wakeUp();}},1000)</script></head><body></body></html>
This following common pattern also doesn't work, i.e., chaining wakeUp on a promise returned from the callback.
That dynCall_v is doing an indirect call, which is why ASYNCIFY_IGNORE_INDIRECT breaks things. It's because of how the main loop works: it gets a function pointer, then does an indirect call to that. So you can't ignore indirect calls in this case.
Thanks for looking into this @kripken, that makes sense. I was overthinking my main loop, making the proper design decisions was the proper way to go about my issue.
I've noticed an issue when using Javascript callbacks and
ASYNCIFY_IGNORE_INDIRECT
. IfwakeUp
is called in a nested callback it will raisefunction signature mismatch
with-O3
andunreachable
otherwise. With-O3
the function call still works as expected, emscripten is woken up and parameters are passed correctly, it just raises the runtime error.Is this the desired behaviour? From what I understand the indirect call only refers to a C++ indirect call?
Here is a minimal reproduction:
This following common pattern also doesn't work, i.e., chaining wakeUp on a promise returned from the callback.
Thanks for taking a look!
The text was updated successfully, but these errors were encountered: