diff --git a/src/library_browser.js b/src/library_browser.js index 3b88f602a2edc..bb0a3ede1eec3 100644 --- a/src/library_browser.js +++ b/src/library_browser.js @@ -701,34 +701,6 @@ var LibraryBrowser = { document.body.appendChild(script); }, - $safeRequestAnimationFrame__deps: ['$MainLoop'], - $safeRequestAnimationFrame: (func) => { - {{{ runtimeKeepalivePush() }}} - return MainLoop.requestAnimationFrame(() => { - {{{ runtimeKeepalivePop() }}} - callUserCallback(func); - }); - }, - - // Runs natively in pthread, no __proxy needed. - emscripten_async_call__deps: ['$safeSetTimeout', '$safeRequestAnimationFrame'], - emscripten_async_call: (func, arg, millis) => { - function wrapper() { - {{{ makeDynCall('vp', 'func') }}}(arg); - } - - if (millis >= 0 -#if ENVIRONMENT_MAY_BE_NODE - // node does not support requestAnimationFrame - || ENVIRONMENT_IS_NODE -#endif - ) { - safeSetTimeout(wrapper, millis); - } else { - safeRequestAnimationFrame(wrapper); - } - }, - emscripten_get_window_title__proxy: 'sync', emscripten_get_window_title: () => { var buflen = 256; diff --git a/src/library_eventloop.js b/src/library_eventloop.js index c72182104223c..ae9fa2226d565 100644 --- a/src/library_eventloop.js +++ b/src/library_eventloop.js @@ -33,6 +33,15 @@ LibraryJSEventLoop = { return id; }, + $safeRequestAnimationFrame__deps: ['$MainLoop'], + $safeRequestAnimationFrame: (func) => { + {{{ runtimeKeepalivePush() }}} + return MainLoop.requestAnimationFrame(() => { + {{{ runtimeKeepalivePop() }}} + callUserCallback(func); + }); + }, + // Just like clearImmediate but takes an i32 rather than an object. $clearImmediateWrapped: (id) => { #if ASSERTIONS @@ -149,6 +158,22 @@ LibraryJSEventLoop = { clearInterval(id); }, + emscripten_async_call__deps: ['$safeSetTimeout', '$safeRequestAnimationFrame'], + emscripten_async_call: (func, arg, millis) => { + var wrapper = () => {{{ makeDynCall('vp', 'func') }}}(arg); + + if (millis >= 0 +#if ENVIRONMENT_MAY_BE_NODE + // node does not support requestAnimationFrame + || ENVIRONMENT_IS_NODE +#endif + ) { + safeSetTimeout(wrapper, millis); + } else { + safeRequestAnimationFrame(wrapper); + } + }, + $registerPostMainLoop: (f) => { // Does nothing unless $MainLoop is included/used. typeof MainLoop != 'undefined' && MainLoop.postMainLoop.push(f);