Skip to content

Commit bc32924

Browse files
committed
HACK to fix freezing when launching the color picker overlay
1 parent e4534ee commit bc32924

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

crates/bevy_winit/src/state.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -608,21 +608,20 @@ impl<T: Event> ApplicationHandler<T> for WinitAppRunnerState<T> {
608608
});
609609
}
610610
else {
611-
event_loop.set_control_flow(ControlFlow::Wait);
611+
// HACK when showing an overlay, ControlFlow::Wait can be unbounded
612+
event_loop.set_control_flow(ControlFlow::WaitUntil(begin_frame_time + std::time::Duration::from_millis(25)));
612613
}
613614
}
614615

615616
// Trigger the next redraw to refresh the screen immediately if waiting
616-
if let ControlFlow::Wait = event_loop.control_flow() {
617+
if !matches!(event_loop.control_flow(), ControlFlow::Poll) {
617618
self.redraw_requested = true;
618619
}
619620
}
620621
UpdateMode::Reactive { wait, .. } => {
621622
// Set the next timeout, starting from the instant before running app.update() to avoid frame delays
622-
if let Some(next) = begin_frame_time.checked_add(wait) {
623-
if self.wait_elapsed {
624-
event_loop.set_control_flow(ControlFlow::WaitUntil(next));
625-
}
623+
if self.wait_elapsed {
624+
event_loop.set_control_flow(ControlFlow::WaitUntil(begin_frame_time + wait));
626625
}
627626
}
628627
}

0 commit comments

Comments
 (0)