[sokol_app] add an option html5_use_emsc_set_main_loop #997
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.
Implementation of the idea suggested in #843 (comment)
emscripten_set_main_loop
is a higher level function compared toemscripten_request_animation_frame_loop
and seems to play nicer with variousemcc
options (EXIT_RUNTIME or PROXY_TO_PTHREAD). The downside is that we have to compute the timestamp on our side and hence it might be less accurate than the one the browser returns with[requestAnimationFrame](https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame)
.I tested both implementation on a test app. Not sure if we need more testing and how to test.
In particular for my use case, only the version
SOKOL_EMSC_USE_SET_MAIN_LOOP
works whenPROXY_TO_PTHREAD
is enabled. But A few more changes are needed for this case in sokol_app which will be for another PR.