Skip to content
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

Vertical synchronization is reactivated when the window regains focus #48061

Closed
yfekraoui opened this issue Apr 21, 2021 · 6 comments · Fixed by #48543
Closed

Vertical synchronization is reactivated when the window regains focus #48061

yfekraoui opened this issue Apr 21, 2021 · 6 comments · Fixed by #48543

Comments

@yfekraoui
Copy link

Godot version:
3.3 rc9

OS/device including version:
Windows 10, Macbook pro retina 2013, Intel Iris Graphics 6100, Google Chrome
Windows 10, AMD Ryzen 5 2600, GTX 1650, Google Chrome

Issue description:
In HTML5 export, i disabled vsync and set FPS target to 30 to make my game more friendly for user with old devices.
Everything work when window's user keep focus.

When you decide to open another tab/window for 10 seconds and you get back on the game tab ; vsync is re-enabled and FPS target is set to 60

Steps to reproduce:

  1. Make a project with target fps to 0 and vsync disabled, put a button to set FPS target to 30
  2. Export to HTML5
  3. Run on the browser, check your GPU consumption
  4. Open/change tab for 10 seconds
  5. Get back to the game tab, vsync is re-enabled, check your GPU consumption

Minimal reproduction project:
https://chapatizretro.com/fps/fps.zip

https://chapatizretro.com/fps/fps.html (web version)

@Calinou
Copy link
Member

Calinou commented Apr 21, 2021

Can you reproduce this in 3.2.3?

Also, in HTML5, you do not have effective control over V-Sync as the browser will likely force it. The graphics driver may also force V-Sync by default, especially on macOS.

@yfekraoui
Copy link
Author

Can you reproduce this in 3.2.3?

Also, in HTML5, you do not have effective control over V-Sync as the browser will likely force it. The graphics driver may also force V-Sync by default, especially on macOS.

https://chapatizretro.com/fps/fps_323.html (vsync is disabled but seems to be still enabled, can't reach 30 fps)

So why you can set target fps to 30 if you can't control vsync in HTML5 ? I find that very useful because players with old devices can run my game without setting their old graphics card on fire

@Calinou
Copy link
Member

Calinou commented Apr 21, 2021

So why you can set target fps to 30 if you can't control vsync in HTML5 ? I find that very useful because players with old devices can run my game without setting their old graphics card on fire

The Target FPS setting is unrelated to V-Sync. The following combinations are all valid:

  • Zero (unlimited) target FPS and V-Sync enabled. This is the default. No tearing, but there will be more input lag and stuttering will happen if the device can't keep up.
  • Non-zero target FPS and V-Sync enabled. Generally suboptimal as it can cause stuttering.
  • Zero (unlimited) target FPS and V-Sync disabled. Uncapped framerate.
  • Non-zero target FPS and V-Sync disabled. Lower input lag compared to V-Sync, but tearing will be visible.

While you will always have control over the target FPS, you won't always have control over V-Sync, especially on mobile and web platforms.

As a workaround, you may be able to set Engine.target_fps in a script's _process() or _physics_process() function to enforce the FPS limit continuously.

@yfekraoui
Copy link
Author

So why you can set target fps to 30 if you can't control vsync in HTML5 ? I find that very useful because players with old devices can run my game without setting their old graphics card on fire

The Target FPS setting is unrelated to V-Sync. The following combinations are all valid:

  • Zero (unlimited) target FPS and V-Sync enabled. This is the default. No tearing, but there will be more input lag and stuttering will happen if the device can't keep up.
  • Non-zero target FPS and V-Sync enabled. Generally suboptimal as it can cause stuttering.
  • Zero (unlimited) target FPS and V-Sync disabled. Uncapped framerate.
  • Non-zero target FPS and V-Sync disabled. Lower input lag compared to V-Sync, but tearing will be visible.

While you will always have control over the target FPS, you won't always have control over V-Sync, especially on mobile and web platforms.

As a workaround, you may be able to set Engine.target_fps in a script's _process() or _physics_process() function to enforce the FPS limit continuously.

Thanks Calinou, i will try your solution :D

@yfekraoui
Copy link
Author

yfekraoui commented Apr 22, 2021

So @Calinou i tried your workaround with _process or _physics_process and the behavior is the same ...
Even with _process, there is a delay to set fps to 30 ...
I tried with the last version 3.3 stable

@yfekraoui
Copy link
Author

@Faless hello Fales, how i can fix this issue ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants