diff options
author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2020-06-29 18:51:53 +0200 |
---|---|---|
committer | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2020-07-01 17:16:13 +0200 |
commit | 7a5e10b8a93c0d38d114b2683460c150c1b43229 (patch) | |
tree | 93e67807502de29d555c7422954c9d14dee4072f /platform/javascript/javascript_main.cpp | |
parent | 1a637b07b11c2a205eeb5936b8f020d36d8b07a9 (diff) | |
download | redot-engine-7a5e10b8a93c0d38d114b2683460c150c1b43229.tar.gz |
Use dummy driver when JS AudioContext is unavailable.
Diffstat (limited to 'platform/javascript/javascript_main.cpp')
-rw-r--r-- | platform/javascript/javascript_main.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/platform/javascript/javascript_main.cpp b/platform/javascript/javascript_main.cpp index 8b7bd2170f..99672745e7 100644 --- a/platform/javascript/javascript_main.cpp +++ b/platform/javascript/javascript_main.cpp @@ -63,10 +63,17 @@ void main_loop_callback() { } if (os->main_loop_iterate()) { emscripten_cancel_main_loop(); // Cancel current loop and wait for finalize_async. + /* clang-format off */ EM_ASM({ // This will contain the list of operations that need to complete before cleanup. - Module.async_finish = []; + Module.async_finish = [ + // Always contains at least one async promise, to avoid firing immediately if nothing is added. + new Promise(function(accept, reject) { + setTimeout(accept, 0); + }) + ]; }); + /* clang-format on */ os->get_main_loop()->finish(); os->finalize_async(); // Will add all the async finish functions. EM_ASM({ |