diff options
author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2021-05-08 11:02:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-08 11:02:50 +0200 |
commit | 871d067aa9f988e69b860887cceebd243011da06 (patch) | |
tree | e15dd6355401f9efa5d4125952462aa91cc9a104 /platform/javascript/javascript_main.cpp | |
parent | ee44982c4526a2823543d4e9eca5d4e566d645af (diff) | |
parent | a1fe6d6899c5ed4cf13c16f9d6bcd64958ab8254 (diff) |
Merge pull request #48543 from Faless/js/4.x_target_fps_fix
[HTML5] Fix target_fps when window loses focus.
Diffstat (limited to 'platform/javascript/javascript_main.cpp')
-rw-r--r-- | platform/javascript/javascript_main.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/platform/javascript/javascript_main.cpp b/platform/javascript/javascript_main.cpp index 0fe95b0a8f..40771d1882 100644 --- a/platform/javascript/javascript_main.cpp +++ b/platform/javascript/javascript_main.cpp @@ -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()) { |