-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Add a project setting to limit FPS on focus loss #76988
Conversation
Haven't checked deeply, but I think the editor already enters low processor mode on focus lost. Would we have after this PR two different code paths addressing the same issue? |
The editor already has its own FPS limiting routine based on low-processor mode (which is always enabled unless you have Update Continuously enabled in the Editor Settings). This is why the code is guarded with We could merge these codepaths together in the long run by removing the editor's implementation and making it use the project code. |
I have some concerns about this:
|
This is enabled by default to save power automatically and improve editor performance if the project is running in the background.
5a8e8e9
to
2a9e507
Compare
if (max_fps_when_unfocused >= 1 || low_processor_mode_when_unfocused) { | ||
if (OS::get_singleton()->is_stdout_verbose()) { | ||
if (max_fps_when_unfocused >= 1 && low_processor_mode_when_unfocused) { | ||
print_line(vformat("Window: Restoring previous maximum FPS (%d) and low-processor mode status (%s) on focus restore.", max_fps_on_focus_loss_previous, low_processor_mode_on_focus_loss_previous ? "enabled" : "disabled")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print_verbose
might be better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's already encapsulated in is_stdout_verbose()
; print_line()
within is_stdout_verbose()
is equivalent to print_verbose()
. I did this to prevent conditions from being evaluated when --verbose
is not used.
Possible problem with the logic here: If you set a Common solution for this problem is to maintain e.g. a focused and unfocused |
This can be an issue indeed. We could increase the maximum amount of physics ticks simulated per frame when the window is unfocused to avoid this issue. The default is 8; we could increase it to 48 when unfocused by default (assuming you'd be running at 60 FPS when focused). As for timers, we should add a way to make them able to emit their signals multiple times in a single frame. This will need to be opt-in on a per-Timer basis to avoid performance issues, and also to preserve compatibility with existing projects.
These can be set at run-time.
Indeed, it would be better to have a property at the Engine level for this (like I did for #66367). |
Closing in favor of #47812, which is a more robust implementation. |
Alternative implementation of #47812 (it turns out I forgot about that PR). See also #76987.
This is enabled by default to save power automatically and improve editor performance if the project is running in the background.
Testing project: test_max_fps_on_focus_loss.zip