emscripten-core / emscripten-core/emscripten

emscripten_sleep performs badly in windows Firefox

Open
#20,628 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 6h
Merged PRs (30d)
109

Description

Specifically, it fails to force a higher timer resolution.

Using sleep to enforce timing in a game works pretty well on all platforms, EXCEPT Windows Firefox.

https://bugzilla.mozilla.org/show_bug.cgi?id=1826224

Even in nightly, the timer resolution of windows is considerably worse than 1MS when on battery.

This matters when you wish to design a fixed framerate game at a specific refresh rate that might not match the displays.

The waitanimationframe bit only works if native is the desired refresh rate.

So we must sleep instead with 1ms precision, and you don't get that on Windows unless you turn on the firefox profiler with a sub 10ms sample rate. This causes the incredibly silly result of the game working faster with the profiler on.

Because by default sdl uses emscripten_sleep internally until told not to by a hint, this cause 60 fps no frameskip games to run at 30FPS instead.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.