bevy
bevy copied to clipboard
fix order of exit/close window systems
Objective
Fixes #5384 and maybe other issues around window closing/app not exiting
Solution
There are three systems involved in exiting when closing a window:
-
close_when_requested
asking Winit to close the window in stageUpdate
-
exit_on_all_closed
exiting when no window remains opened in stageUpdate
-
change_window
removing windows that are closed in stagePostUpdate
This ordering meant that when closing a window, we had to run one more frame to actually exit. As there was no window, panics could occur in user code assuming there was a window. In case of Bevy app using a low power options, that means waiting for the timeout before actually exiting the app (60 seconds by default)
This PR changes the ordering so that exit_on_all_closed
happens after change_window
in the same frame, so there isn't an extra frame without window