-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[JSPI] Pause / resume main loop before executing an async functions (matching behavior of ASYNCIFY=1) #26249
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
base: main
Are you sure you want to change the base?
Conversation
sbc100
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable yes. Maybe we can write a test for this the runs in both modes?
|
|
||
| if (typeof MainLoop != 'undefined' && MainLoop.func) { | ||
| MainLoop.resume(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should put these 2 lines in the finally block? Then we don't need t new res variable I think.
de8611d to
310fa87
Compare
|
Added a JSPI specific test, I'm not quite sure the best way to have that run for both modes. Hate adding tests with sleeps, but not sure of a better way to test that here. |
test/test_other.py
Outdated
| '-Wno-experimental', | ||
| '--post-js=post.js']) | ||
|
|
||
| @requires_jspi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can use @with_asyncify_and_jspi here to get both modes.
Then maybe the test itself should be called test_asyncify_mainloop?
test/test_other.py
Outdated
| } | ||
|
|
||
| int main() { | ||
| emscripten_set_main_loop( loop, 1000, 1 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No space inside braces.
|
Just realized this is failing because of a change I didn't commit, but I'm not sure if you want this right now - I believe I had read some chatter here somewhere about automating this vs sprinkling it around everywhere. |
Isn't the solution here to make sure the interFunc is in |
310fa87 to
8249562
Compare
|
Hmm, I tried adding a '-sJSPI_EXPORTS=loop' into the cflags variable there, but I can't get that function to show up in the exports array passed to instrumentWasmExports. Ah, that finally worked if I also added '-sEXPORTED_FUNCTIONS=_main,_loop'. |
…esume main loop before executing an async function
8249562 to
5e1f1e5
Compare
Seems straight forward, but would appreciate someone more familiar with this code sanity checking.