Merge pull request #48543 from Faless/js/4.x_target_fps_fix

[HTML5] Fix target_fps when window loses focus.
This commit is contained in:
Fabio Alessandrelli
2021-05-08 11:02:50 +02:00
committed by GitHub
2 changed files with 13 additions and 1 deletions

View File

@ -66,6 +66,11 @@ void main_loop_callback() {
int target_fps = Engine::get_singleton()->get_target_fps();
if (target_fps > 0) {
if (current_ticks - target_ticks > 1000000) {
// When the window loses focus, we stop getting updates and accumulate delay.
// For this reason, if the difference is too big, we reset target ticks to the current ticks.
target_ticks = current_ticks;
}
target_ticks += (uint64_t)(1000000 / target_fps);
}
if (os->main_loop_iterate()) {