Skip to content

Commit a4e6d11

Browse files
authored
Move emscripten_async_call to library_eventloop.js. NFC (#22845)
1 parent c560421 commit a4e6d11

File tree

2 files changed

+25
-28
lines changed

2 files changed

+25
-28
lines changed

src/library_browser.js

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -701,34 +701,6 @@ var LibraryBrowser = {
701701
document.body.appendChild(script);
702702
},
703703

704-
$safeRequestAnimationFrame__deps: ['$MainLoop'],
705-
$safeRequestAnimationFrame: (func) => {
706-
{{{ runtimeKeepalivePush() }}}
707-
return MainLoop.requestAnimationFrame(() => {
708-
{{{ runtimeKeepalivePop() }}}
709-
callUserCallback(func);
710-
});
711-
},
712-
713-
// Runs natively in pthread, no __proxy needed.
714-
emscripten_async_call__deps: ['$safeSetTimeout', '$safeRequestAnimationFrame'],
715-
emscripten_async_call: (func, arg, millis) => {
716-
function wrapper() {
717-
{{{ makeDynCall('vp', 'func') }}}(arg);
718-
}
719-
720-
if (millis >= 0
721-
#if ENVIRONMENT_MAY_BE_NODE
722-
// node does not support requestAnimationFrame
723-
|| ENVIRONMENT_IS_NODE
724-
#endif
725-
) {
726-
safeSetTimeout(wrapper, millis);
727-
} else {
728-
safeRequestAnimationFrame(wrapper);
729-
}
730-
},
731-
732704
emscripten_get_window_title__proxy: 'sync',
733705
emscripten_get_window_title: () => {
734706
var buflen = 256;

src/library_eventloop.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ LibraryJSEventLoop = {
3333
return id;
3434
},
3535

36+
$safeRequestAnimationFrame__deps: ['$MainLoop'],
37+
$safeRequestAnimationFrame: (func) => {
38+
{{{ runtimeKeepalivePush() }}}
39+
return MainLoop.requestAnimationFrame(() => {
40+
{{{ runtimeKeepalivePop() }}}
41+
callUserCallback(func);
42+
});
43+
},
44+
3645
// Just like clearImmediate but takes an i32 rather than an object.
3746
$clearImmediateWrapped: (id) => {
3847
#if ASSERTIONS
@@ -149,6 +158,22 @@ LibraryJSEventLoop = {
149158
clearInterval(id);
150159
},
151160

161+
emscripten_async_call__deps: ['$safeSetTimeout', '$safeRequestAnimationFrame'],
162+
emscripten_async_call: (func, arg, millis) => {
163+
var wrapper = () => {{{ makeDynCall('vp', 'func') }}}(arg);
164+
165+
if (millis >= 0
166+
#if ENVIRONMENT_MAY_BE_NODE
167+
// node does not support requestAnimationFrame
168+
|| ENVIRONMENT_IS_NODE
169+
#endif
170+
) {
171+
safeSetTimeout(wrapper, millis);
172+
} else {
173+
safeRequestAnimationFrame(wrapper);
174+
}
175+
},
176+
152177
$registerPostMainLoop: (f) => {
153178
// Does nothing unless $MainLoop is included/used.
154179
typeof MainLoop != 'undefined' && MainLoop.postMainLoop.push(f);

0 commit comments

Comments
 (0)