Throttle framerate when V-sync is enabled but window is not focused.#18826
Merged
LibretroAdmin merged 1 commit intolibretro:masterfrom Mar 19, 2026
Merged
Throttle framerate when V-sync is enabled but window is not focused.#18826LibretroAdmin merged 1 commit intolibretro:masterfrom
LibretroAdmin merged 1 commit intolibretro:masterfrom
Conversation
RetroArch hogs an entire CPU core when running in the background with V-sync enabled. It seems that when the window is fully obscured by other windows, V-sync ceases to work, allowing RetroArch to run at an unlimited framerate, thrashing the CPU. As a workaround, the framerate is now throttled when the window is not in focus. I would rather have it throttle when the window is not visible, but there does not seem to be a way of detecting that. Note that this is only known to be the case on Windows: I don't know what the situation is for Linux and other operating systems, though macOS does suffer from this exact same problem, according to this SDL issue: libsdl-org/SDL#4521
Contributor
|
Hi, this sounds great. Let me try to ask someone who is quite familiar with the runloop to give this a quick look. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RetroArch hogs an entire CPU core when running in the background with V-sync enabled. It seems that when the window is fully obscured by other windows, V-sync ceases to work, allowing RetroArch to run at an unlimited framerate, thrashing the CPU (and making my laptop very loud and hot).
As a workaround, the framerate is now throttled when the window is not in focus. I would rather have it throttle when the window is not visible, but there does not seem to be a way of detecting that.
Note that this is only known to be the case on Windows: I do not know what the situation is for Linux and other operating systems, though macOS does apparently suffer from this exact same problem, according to this SDL issue.
For the unlimited framerate issue to occur, the video driver must be Direct3D11, OpenGL, or Vulkan, 'pause on focus loss' needs to be disabled, V-sync needs to be enabled, and VRR needs to be disabled. If this is not enough to reproduce it, I can try to provide more information.
If anybody knows a better way to mitigate this issue, please let me know.