-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ASYNCIFY=1 emscripten_sleep broken #19872
Comments
I was unable to reproduce with the following: #include <stdio.h>
#include <emscripten.h>
int main() {
for (int i = 0; i < 100; i++) {
EM_ASM(
globalThis.start = performance.now();
);
emscripten_sleep(16);
EM_ASM(
console.log(performance.now() - start);
);
}
}
Could you try bisecting? |
Is indeed hard to reproduce in C. Now the questions are maybe:
I will try filing a bug in the Rust repo, too, but maybe you have an idea what could be wrong from a WASM perspective? |
setTimeout is throttled to 1000ms on background tabs. Are you seeing a 1000ms pause on foreground tabs too? |
I bisected manually by jumping commits in this repo. The culprit is c8857a6. All testing was done with: edit: Switched to Seems all maybe a bit dubious. Will try getting into the edit: Using the full emsdk bisection approach with
So this is again pointing to #17401.
Yes, but what is more, when trying to sleep 16 ms and intentionally spinning until I actually reach that amount of sleep (expecting potential early wakeups), I see this:
|
OK, I think this hinted in the right direction. When I use Yep, seems that time_t is wrong in the libc wrapper https://github.com/rust-lang/libc/blob/af676d102b238ea605cb7bdbe61ffac7903b7c51/src/unix/linux_like/emscripten/mod.rs#L23-L33 Filed rust-lang/libc#3306 – it’s curious that the issue did not exist before #16966 even though the definition for emscripten’s |
Fixing this in rust-lang/libc#3307.
– on wasm32, |
It seems that
emscripten_sleep
withASYNCIFY=1
, when called with low amount of ms (e.g. 16 or 1) often sleeps for 1000 ms or 0 ms instead of the requested amount.See further down for bisection.
Reproducer: https://github.com/benjamin-sieffert/emscripten-sleep-bug
All details for how to run are in the repo.
Sorry the reproducer being in Rust – it does work with older versions of emscripten (see below), so this must be related to emscripten somehow.
The text was updated successfully, but these errors were encountered: