Skip to content

Commit

Permalink
Dirty fix for App hanging when windows are invisible on WindowsOS (#1…
Browse files Browse the repository at this point in the history
…4155)

# 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
  • Loading branch information
MiniaczQ authored Jul 14, 2024
1 parent 17a7744 commit b36b023
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion crates/bevy_winit/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,16 @@ impl<T: Event> ApplicationHandler<T> for WinitAppRunnerState<T> {
let begin_frame_time = Instant::now();

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.
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.ran_update_since_last_redraw = true;
} else {
Expand Down

0 comments on commit b36b023

Please sign in to comment.