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

Framerate/FPS jumps to 110, wasting CPU, when game is minimized #19741

Open
rokasv opened this issue Jun 23, 2018 · 6 comments · May be fixed by #47812
Open

Framerate/FPS jumps to 110, wasting CPU, when game is minimized #19741

rokasv opened this issue Jun 23, 2018 · 6 comments · May be fixed by #47812

Comments

@rokasv
Copy link

rokasv commented Jun 23, 2018

v3.0.2.stable.official
Windows 10

Monitor shows the fps going straight for double the normal when minimized.
Happens even when OS.set_low_processor_usage_mode(true)

@marcelofg55
Copy link
Contributor

It seems that when minimized VSync is ignored. I've seen this on OS X too. A possible solution for this would be to limit the FPS to the display frequency when the app is minimized.

@zhengying
Copy link

Yes!when game minimized, cpu usage is very high (70%) on my imac 2017.

@gblues
Copy link

gblues commented Nov 8, 2018

Doesn't even have to be minimized. Just hidden.

On my 2017 MBP, my project is set vsync=on and I turned on "print FPS", and then ran a scene.

  • With the game window visible (not fully occluded), the FPS remains stable at 60 and Godot CPU usage is at ~5%
  • With the game window fully occluded (e.g. web browser), CPU usage spikes to 92-95% and the FPS jumps:
Game FPS: 60
Game FPS: 855
Game FPS: 2698
Game FPS: 2416
Game FPS: 2129
Game FPS: 1875
Game FPS: 1814
Game FPS: 1828
Game FPS: 1775
Game FPS: 1734
Game FPS: 511
Game FPS: 60

If I set a FPS limit in the debug settings, then the problem does not occur; however, this is a workaround and not a solution.

@akien-mga akien-mga modified the milestones: 3.1, 3.2 Jan 23, 2019
@Calinou
Copy link
Member

Calinou commented Aug 15, 2019

This could be solved by adding a FPS limit that applies only when the project is minimized. #29297 does something similar for the editor, which also applies when the window is unfocused. Limiting the FPS when the window is unfocused may be undesirable for some projects, but it would also solve the "fully occluded" case for the most part.

Otherwise, to solve the "fully occluded" issue without capping the FPS when the window is unfocused, we'd need a way to detect when the window is fully occluded by another window. This is technically possible (it's been done in Chromium), but it's not particularly easy.

@KoBeWi
Copy link
Member

KoBeWi commented Dec 10, 2020

Still valid in d8825fb

@Calinou
Copy link
Member

Calinou commented Dec 26, 2020

See also godotengine/godot-proposals#2001.

@akien-mga akien-mga removed this from the 4.0 milestone Feb 22, 2023
github-merge-queue bot pushed a commit to bevyengine/bevy that referenced this issue Aug 2, 2023
…s not visible (#7611)

Fixes #5856. Fixes #8080. Fixes #9040.

# Objective

We need to limit the update rate of games whose windows are not visible
(minimized or completely occluded). Compositors typically ignore the
VSync settings of windows that aren't visible. That, combined with the
lack of rendering work, results in a scenario where an app becomes
completely CPU-bound and starts updating without limit.

There are currently three update modes.
- `Continuous` updates an app as often as possible.
- `Reactive` updates when new window or device events have appeared, a
timer expires, or a redraw is requested.
- `ReactiveLowPower` is the same as `Reactive` except it ignores device
events (e.g. general mouse movement).

The problem is that the default "game" settings are set to `Contiuous`
even when no windows are visible.

### More Context

- libsdl-org/SDL#1871
- glfw/glfw#680
- godotengine/godot#19741
- godotengine/godot#64708

## Solution

Change the default "unfocused" `UpdateMode` for games to
`ReactiveLowPower` just like desktop apps. This way, even when the
window is occluded, the app still updates at a sensible rate or if
something about the window changes. I chose 20Hz arbitrarily.
Subserial pushed a commit to Subserial/bevy_winit_hook that referenced this issue Jan 24, 2024
…s not visible (#7611)

Fixes #5856. Fixes #8080. Fixes #9040.

# Objective

We need to limit the update rate of games whose windows are not visible
(minimized or completely occluded). Compositors typically ignore the
VSync settings of windows that aren't visible. That, combined with the
lack of rendering work, results in a scenario where an app becomes
completely CPU-bound and starts updating without limit.

There are currently three update modes.
- `Continuous` updates an app as often as possible.
- `Reactive` updates when new window or device events have appeared, a
timer expires, or a redraw is requested.
- `ReactiveLowPower` is the same as `Reactive` except it ignores device
events (e.g. general mouse movement).

The problem is that the default "game" settings are set to `Contiuous`
even when no windows are visible.

### More Context

- libsdl-org/SDL#1871
- glfw/glfw#680
- godotengine/godot#19741
- godotengine/godot#64708

## Solution

Change the default "unfocused" `UpdateMode` for games to
`ReactiveLowPower` just like desktop apps. This way, even when the
window is occluded, the app still updates at a sensible rate or if
something about the window changes. I chose 20Hz arbitrarily.
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.

9 participants