Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/lib/libeventloop.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,16 @@ LibraryJSEventLoop = {
{{{ runtimeKeepalivePop() }}}
callUserCallback(() => {
if ({{{ makeDynCall('idp', 'cb') }}}(t, userData)) {
{{{ runtimeKeepalivePush() }}}
// Save a little bit of code space: modern browsers should treat
// negative setTimeout as timeout of 0
// (https://stackoverflow.com/questions/8430966/is-calling-settimeout-with-a-negative-delay-ok)
{{{ runtimeKeepalivePush() }}}
setTimeout(tick, n - _emscripten_get_now());
var remaining = n - _emscripten_get_now();
#if ENVIRONMENT_MAY_BE_NODE
// Recent revsions of node, however, give TimeoutNegativeWarning
remaining = Math.max(0, remaining);
#endif
setTimeout(tick, remaining);
}
});
}
Expand Down