Merge pull request #39537 from Faless/js/fs_sync_iteration

Immediately run first iteration after JS FS sync.
This commit is contained in:
Rémi Verschelde 2020-06-14 22:57:32 +02:00 committed by GitHub
commit 6fa2a5ac14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 4 deletions

View File

@ -80,6 +80,9 @@ extern "C" EMSCRIPTEN_KEEPALIVE void main_after_fs_sync(char *p_idbfs_err) {
Main::start(); Main::start();
os->get_main_loop()->init(); os->get_main_loop()->init();
emscripten_resume_main_loop(); 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[]) { int main(int argc, char *argv[]) {
@ -91,14 +94,15 @@ int main(int argc, char *argv[]) {
// Sync from persistent state into memory and then // Sync from persistent state into memory and then
// run the 'main_after_fs_sync' function. // run the 'main_after_fs_sync' function.
/* clang-format off */ /* clang-format off */
EM_ASM( EM_ASM({
FS.mkdir('/userfs'); FS.mkdir('/userfs');
FS.mount(IDBFS, {}, '/userfs'); FS.mount(IDBFS, {}, '/userfs');
FS.syncfs(true, function(err) { 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 */ /* clang-format on */
return 0; return 0;