Skip to content

[3.x] Game consumes 100% CPU if the window is covered by another OS window (macOS) #64708

@BigZaphod

Description

@BigZaphod

Godot version

v3.5.stable.official [991bb6a]

System information

macOS 12.5.1 (21G83), Apple M1 Max MacBook Pro

Issue description

Simply covering up the game's window with another OS window causes CPU usage to spike to 100%. You can see this in action in the video:

Screen.Recording.2022-08-21.at.4.43.46.PM.mov

Steps to reproduce

Run the attached project (or any project, really - the attached one is essentially empty and has no scripts) on macOS. Drag a window over top of the game's window (it needs to cover it completely). Watch as CPU usage skyrockets.

My uninformed suspicion is that macOS detects when the window is covered and stops sending rendering/v-sync events to the app in an effort to save power. Godot may be waiting for those events in an inefficient polling loop and when they stop coming that loop starts burning up cycles.

Godot now has the distinction of being the first app on my M1 Max that's actually managed to get the fan to run because of this. I noticed it because I have a habit of leaving the game open behind other windows when I switch back to the editor to keep working on it. I don't think this is an uncommon habit, tbh, and this behavior would have caused Godot to very rapidly deplete my laptop's battery if I hadn't happened to be running while plugged in.

Minimal reproduction project

Godot 100% CPU Bug.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    For team assessment

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions