diff options
author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2020-06-14 15:48:18 +0200 |
---|---|---|
committer | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2020-06-14 16:04:45 +0200 |
commit | 5c75cb01332988a1c7c8e0ab5b3c4176903900a4 (patch) | |
tree | 60cf3a69cdab9faea5b3c61b190effc9841e08d0 | |
parent | 8b79f2aad4c42644ba0d398b427ccbe64c5d8204 (diff) |
Immediately run first iteration after JS FS sync.
Which is now run inside an animation frame.
This avoid a 1 frame black screen when setting up the canvas.
-rw-r--r-- | platform/javascript/javascript_main.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/platform/javascript/javascript_main.cpp b/platform/javascript/javascript_main.cpp index 740a72fafa..fd61c46e63 100644 --- a/platform/javascript/javascript_main.cpp +++ b/platform/javascript/javascript_main.cpp @@ -80,6 +80,9 @@ extern "C" EMSCRIPTEN_KEEPALIVE void main_after_fs_sync(char *p_idbfs_err) { Main::start(); os->get_main_loop()->init(); emscripten_resume_main_loop(); + // Immediately run the first iteration. + // We are inside an animation frame, we want to immediately draw on the newly setup canvas. + main_loop_callback(); } int main(int argc, char *argv[]) { @@ -91,14 +94,15 @@ int main(int argc, char *argv[]) { // Sync from persistent state into memory and then // run the 'main_after_fs_sync' function. /* clang-format off */ - EM_ASM( + EM_ASM({ FS.mkdir('/userfs'); FS.mount(IDBFS, {}, '/userfs'); FS.syncfs(true, function(err) { - ccall('main_after_fs_sync', null, ['string'], [err ? err.message : ""]) + requestAnimationFrame(function() { + ccall('main_after_fs_sync', null, ['string'], [err ? err.message : ""]); + }); }); - - ); + }); /* clang-format on */ return 0; |