Use emscripten_set_main_loop
in sokol app
#915
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem: It appears that Emscripten's async APIs don't get a chance to call user callbacks in Sokol App. For instance, when using
emscripten_async_wget_data
, Firefox shows the request completed with 200 OK, and the data available, but the user callbacks are never called.Root Cause: From docs about
emscripten_request_animation_frame_loop
, it seems to be intended as a low level API, and is likely not handling callbacks. Switching toemscripten_set_main_loop
fires the callbacks, and still usesrequestAnimationFrame
under the hood.Proposal: Use
emscripten_set_main_loop
instead ofemscripten_request_animation_frame_loop
in Sokol App.NOTE: I haven't dug too deeply into what else
emscripten_set_main_loop
does, or if it duplicates functionality elsewhere in Sokol App. Maybe we just need to hook up the async API callbacks explicitly somewhere else?I don't mean to open a glut of pull requests, but I thought that maybe others could benefit from some of these findings. If I've misunderstood something or these PRs are not helpful, please just let me know and I'll close them! :-)