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

500% increase CPU usage when app goes to background #9040

Closed
olegus199 opened this issue Jul 4, 2023 · 1 comment · Fixed by #7611 · May be fixed by #9034
Closed

500% increase CPU usage when app goes to background #9040

olegus199 opened this issue Jul 4, 2023 · 1 comment · Fixed by #7611 · May be fixed by #9034
Labels
A-Windowing Platform-agnostic interface layer to run your app in C-Bug An unexpected or incorrect behavior O-MacOS Specific to the MacOS (Apple) desktop operating system

Comments

@olegus199
Copy link

olegus199 commented Jul 4, 2023

Bevy version

0.10.1

[Optional] Relevant system information

iMac 27 late 2012, core i7, NVIDIA GeForce GTX 675MX 1GB, 24GB RAM, macOS Catalina 10.15.7

What you did

I noticed that Bevy consumes massive amount of CPU when going to background when I focus on the another window (VS code, for instance)
This is normal load of 59% of CPU. Bevy window is focused
Screenshot 2023-07-04 at 14 20 10
This is abnormal load of 284.8% of CPU. VS code is focused, Bevy on the background
Screenshot 2023-07-04 at 14 22 22

@olegus199 olegus199 added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Jul 4, 2023
@mockersf
Copy link
Member

mockersf commented Jul 4, 2023

duplicate of #8080 and #5856

@mockersf mockersf added A-Windowing Platform-agnostic interface layer to run your app in O-MacOS Specific to the MacOS (Apple) desktop operating system and removed S-Needs-Triage This issue needs to be labelled labels Jul 4, 2023
@B-head B-head mentioned this issue Jul 6, 2023
8 tasks
github-merge-queue bot pushed a commit that referenced this issue Aug 3, 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.
@cart cart closed this as completed in #7611 Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Windowing Platform-agnostic interface layer to run your app in C-Bug An unexpected or incorrect behavior O-MacOS Specific to the MacOS (Apple) desktop operating system
Projects
None yet
2 participants