-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[rcore] [SDL2] Add implementation for FLAG_WINDOW_ALWAYS_RUN
#4598
base: master
Are you sure you want to change the base?
Conversation
@asdqwe Actually, stop running is my expected behaviour when minimizing the Window, I think it's the optimal option, so being default. About the other platforms, the ones that have the minimizing option I think implement similar alternatives (afair, Android also pauses the Activity and Web browsers pauses tabs activity when minimized/unselected tab). I prefer to let the user configure it for the sub-optimal use case that is Also, about the othe Desktop backends (SDL, RGFW), probably behaviour should be the same, just forgot about it when added. Just thinking... what is the default behaviour for games on Windows? |
@raysan5 I'm not aware of any (big) game that fully stops processing like that when minimizing because that breaks timers, gameplay sincronization, animations, networking, etc. Most games just lower the framerate when minimized or unfocused (some even allow to set specific foreground fps and background fps values). Which was why I thought this was a bug when debugging #4588. Basically everything with timers break if this happens. |
@raysan5 I don't know how Android specifically handles it. But on This example can test/confirm that behavior:
When running it, after 1 second I changed tabs. Waited 10 seconds then returned. Here's the screenshot of the console log where it shows the execution dropping to once a second: Edit: I'm trying to find a case where iconifying the window halts processing by default, but I'm unable to find one so far. GLFW continues execution by default (tested on Linux and Windows):
SDL2 (native) continues execution by default (tested on Linux and Windows):
Nvidia has Background Application Max Frame Rate on it's Control Panel (ref). |
71885dd
to
449aba9
Compare
FLAG_WINDOW_ALWAYS_RUN
by default on PLATFORM_DESKTOP_GLFW
FLAG_WINDOW_ALWAYS_RUN
@raysan5 Although I don't think that should be the default behavior, I've reverted my previous commit on This PR was tested with The PR can be tested with:
Regarding |
At the moment, on
PLATFORM_DESKTOP_GLFW
, when a window is iconified (minimized) it stops processing until the window is raised again. That happens because theFLAG_WINDOW_ALWAYS_RUN
, when disabled (and the window iconified), callsglfwWaitEvents()
(ref), which "puts the calling thread to sleep until at least one event is available" (doc).Since
FLAG_WINDOW_ALWAYS_RUN
is disabled by default, every time the window is iconified, all processing stops, causing a series of problems for anyone expecting that the program will continue to run while iconified, unlike on the other platforms, which won't stop processing while iconified.This PR fixes this by turning
FLAG_WINDOW_ALWAYS_RUN
on by default onPLATFORM_DESKTOP_GLFW
'sInitPlatform()
so it will behave like the other platforms by default. The flag funcionality is still maintained and the user can still disable it if he wants to stop processing when iconifying. This change doesn't affect the other platforms since it's aPLATFORM_DESKTOP_GLFW
-only flag.The PR can be tested with:
Also closes #4588.