Skip to content

Commit b36b023

Browse files
authored
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: #1343 (comment) 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
1 parent 17a7744 commit b36b023

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

crates/bevy_winit/src/state.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,8 +504,16 @@ impl<T: Event> ApplicationHandler<T> for WinitAppRunnerState<T> {
504504
let begin_frame_time = Instant::now();
505505

506506
if should_update {
507+
let (_, windows) = focused_windows_state.get(self.world());
508+
// If no windows exist, this will evaluate to `true`.
509+
let all_invisible = windows.iter().all(|w| !w.1.visible);
510+
507511
// Not redrawing, but the timeout elapsed.
508-
if !self.ran_update_since_last_redraw {
512+
//
513+
// Additional condition for Windows OS.
514+
// If no windows are visible, redraw calls will never succeed, which results in no app update calls being performed.
515+
// This is a temporary solution, full solution is mentioned here: https://github.com/bevyengine/bevy/issues/1343#issuecomment-770091684
516+
if !self.ran_update_since_last_redraw || all_invisible {
509517
self.run_app_update();
510518
self.ran_update_since_last_redraw = true;
511519
} else {

0 commit comments

Comments
 (0)