mirror of
https://github.com/bevyengine/bevy
synced 2024-11-14 00:47:32 +00:00
Dirty fix for App hanging when windows are invisible on WindowsOS (#14155)
# Objective - Fixes #14135 ## Solution - If no windows are visible, app updates will run regardless of redraw call result. This a relatively dirty fix, a more robust solution is desired in the long run: https://github.com/bevyengine/bevy/issues/1343#issuecomment-770091684 https://discord.com/channels/691052431525675048/1253771396832821270/1258805997011730472 The solution would disconnect rendering from app updates. ## Testing - `window_settings` now works ## Other platforms Not a problem on Linux: https://discord.com/channels/691052431525675048/692572690833473578/1259526650622640160 Not a problem on MacOS: https://discord.com/channels/691052431525675048/692572690833473578/1259563986148659272
This commit is contained in:
parent
17a77445e2
commit
b36b0230e6
1 changed files with 9 additions and 1 deletions
|
@ -504,8 +504,16 @@ impl<T: Event> ApplicationHandler<T> for WinitAppRunnerState<T> {
|
||||||
let begin_frame_time = Instant::now();
|
let begin_frame_time = Instant::now();
|
||||||
|
|
||||||
if should_update {
|
if should_update {
|
||||||
|
let (_, windows) = focused_windows_state.get(self.world());
|
||||||
|
// If no windows exist, this will evaluate to `true`.
|
||||||
|
let all_invisible = windows.iter().all(|w| !w.1.visible);
|
||||||
|
|
||||||
// Not redrawing, but the timeout elapsed.
|
// Not redrawing, but the timeout elapsed.
|
||||||
if !self.ran_update_since_last_redraw {
|
//
|
||||||
|
// Additional condition for Windows OS.
|
||||||
|
// If no windows are visible, redraw calls will never succeed, which results in no app update calls being performed.
|
||||||
|
// This is a temporary solution, full solution is mentioned here: https://github.com/bevyengine/bevy/issues/1343#issuecomment-770091684
|
||||||
|
if !self.ran_update_since_last_redraw || all_invisible {
|
||||||
self.run_app_update();
|
self.run_app_update();
|
||||||
self.ran_update_since_last_redraw = true;
|
self.ran_update_since_last_redraw = true;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue