Describe the project you are working on
The Godot editor 🙂
Describe the problem or limitation you are having in your project
The Godot editor already limits itself to 10 FPS when the window is unfocused. This helps decrease CPU and GPU usage significantly, whicn in turn saves power/battery and decreases heat/noise emissions.
However, exported projects do not have any kind of FPS limitations when unfocused or minimized. This is problematic as it harms the "default" experience for exported projects, in a way similar to #1923. We should aim to have a out-of-the-box experience as good as possible, even for casual/gamejam games.
Many other game engines offer this feature by default. Likewise, many AAA games also limit the game's framerate when the window is minimized or unfocused.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
By default, enable low-processor mode and limit the FPS of exported projects to a relatively low value when their window is unfocused or minimized. Engines that support this feature often default to 10 or 20 FPS.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Add a project setting application/run/max_fps_when_unfocused (integer), defaults to 10. If set to 0, the limit is disabled.
We can also add a second project setting application/run/low_processor_mode_when_unfocused, which defaults to true. This behaves the same as low-processor mode (skips redrawing if nothing has changed).
If this enhancement will not be used often, can it be worked around with a few lines of script?
Technically, yes, but the project will need to be modified for it (see below). Also, implementing this functionality with a script will not make this option easy to discover as it won't be standardized across all Godot projects.
The script below can be added in an AutoLoad:
3.x
func _notification(what: int) -> void:
match what:
NOTIFICATION_WM_FOCUS_OUT:
Engine.target_fps = 20
OS.low_processor_usage_mode = true
NOTIFICATION_WM_FOCUS_IN:
# `0` means "unlimited".
Engine.target_fps = 0
OS.low_processor_usage_mode = false
4.x
func _notification(what: int) -> void:
match what:
NOTIFICATION_APPLICATION_FOCUS_OUT:
Engine.max_fps = 20
OS.low_processor_usage_mode = true
NOTIFICATION_APPLICATION_FOCUS_IN:
# `0` means "unlimited".
Engine.max_fps = 0
OS.low_processor_usage_mode = false
Is there a reason why this should be core and not an add-on in the asset library?
It can technically be an add-on, but the point here is that this functionality must be built-in to achieve the desired goal (which is, decreasing CPU/GPU usage on any project made with Godot).
Describe the project you are working on
The Godot editor 🙂
Describe the problem or limitation you are having in your project
The Godot editor already limits itself to 10 FPS when the window is unfocused. This helps decrease CPU and GPU usage significantly, whicn in turn saves power/battery and decreases heat/noise emissions.
However, exported projects do not have any kind of FPS limitations when unfocused or minimized. This is problematic as it harms the "default" experience for exported projects, in a way similar to #1923. We should aim to have a out-of-the-box experience as good as possible, even for casual/gamejam games.
Many other game engines offer this feature by default. Likewise, many AAA games also limit the game's framerate when the window is minimized or unfocused.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
By default, enable low-processor mode and limit the FPS of exported projects to a relatively low value when their window is unfocused or minimized. Engines that support this feature often default to 10 or 20 FPS.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Add a project setting
application/run/max_fps_when_unfocused(integer), defaults to 10. If set to 0, the limit is disabled.We can also add a second project setting
application/run/low_processor_mode_when_unfocused, which defaults totrue. This behaves the same as low-processor mode (skips redrawing if nothing has changed).If this enhancement will not be used often, can it be worked around with a few lines of script?
Technically, yes, but the project will need to be modified for it (see below). Also, implementing this functionality with a script will not make this option easy to discover as it won't be standardized across all Godot projects.
The script below can be added in an AutoLoad:
3.x4.xIs there a reason why this should be core and not an add-on in the asset library?
It can technically be an add-on, but the point here is that this functionality must be built-in to achieve the desired goal (which is, decreasing CPU/GPU usage on any project made with Godot).