Skip to content

Commit f795656

Browse files
authored
Winit update: fix suspend on Android (#11403)
# Objective - Android still plays audio when suspended ## Solution - When status is `WillSuspend`, trigger an update without requesting a redraw
1 parent a00c71e commit f795656

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

crates/bevy_winit/src/lib.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,11 +407,16 @@ pub fn winit_runner(mut app: App) {
407407
should_update = true;
408408
}
409409

410+
// Trigger one last update to enter suspended state
411+
if runner_state.active == ActiveState::WillSuspend {
412+
should_update = true;
413+
}
414+
410415
if should_update {
411416
let visible = windows.iter().any(|window| window.visible);
412417
let (_, winit_windows, _, _) =
413418
event_writer_system_state.get_mut(&mut app.world);
414-
if visible {
419+
if visible && runner_state.active != ActiveState::WillSuspend {
415420
for window in winit_windows.windows.values() {
416421
window.request_redraw();
417422
}
@@ -427,7 +432,9 @@ pub fn winit_runner(mut app: App) {
427432
&mut app_exit_event_reader,
428433
&mut redraw_event_reader,
429434
);
430-
event_loop.set_control_flow(ControlFlow::Poll);
435+
if runner_state.active != ActiveState::Suspended {
436+
event_loop.set_control_flow(ControlFlow::Poll);
437+
}
431438
}
432439
}
433440
}

0 commit comments

Comments
 (0)