-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Description
Bevy version
Current main
(8777dd4).
Relevant system information
Windows 11
What you did
Ran a Bevy project and resized the window.
What went wrong
While resizing the application window, the program freezes up completely and crashes. This problem occurs on every run but may take repeated resizing before it shows up. This is occurring in my application along with the basic Bevy 3d Scene example.
Additional information
I bisected this and found the problem is introduced in 8122b35.
It seems like the issue is within WinitAppRunnerState::about_to_wait()
where self.redraw_requested(event_loop)
is always called for non-Windows platforms (where I assume the freezing does not occur), but there is unique, problematic logic for Windows that is causing self.redraw_requested(event_loop)
to NOT be called enough.
The code causing this resize crash is also causing at least one related problem (and possibly others). See #19030 and my related PR #19772 where there is a freeze occurring during drag-and-drop events—the PR fix just ensures that self.redraw_requested(event_loop)
runs during a drag-and-drop event.
This issue (along with #19030) can be fixed with the following code changes. That said, I'm not familiar with the reasons for the current code, and this may cause other problems that the existing Windows-specific code was meant to fix.
Other related issues per code comments: #17488 and #18027.
bevy_winit/src/state.rs
lines 457-469
- Just comment out the Windows block
WindowEvent::RedrawRequested => {
self.ran_update_since_last_redraw = false;
// // https://github.com/bevyengine/bevy/issues/17488
// #[cfg(target_os = "windows")]
// {
// // Have the startup behavior run in about_to_wait, which prevents issues with
// // invisible window creation. https://github.com/bevyengine/bevy/issues/18027
// if self.startup_forced_updates == 0 {
// manual_run_redraw_requested = true;
// }
// }
}
bevy_winit/src/state.rs
lines 519-539
- Comment out the Windows block and replace it with just calling
self.redraw_requested(event_loop)
like occurs on non-Windows platforms
// // Have the startup behavior run in about_to_wait, which prevents issues with
// // invisible window creation. https://github.com/bevyengine/bevy/issues/18027
// #[cfg(target_os = "windows")]
// {
// WINIT_WINDOWS.with_borrow(|winit_windows| {
// let headless = winit_windows.windows.is_empty();
// let exiting = self.app_exit.is_some();
// let reactive = matches!(self.update_mode, UpdateMode::Reactive { .. });
// let all_invisible = winit_windows
// .windows
// .iter()
// .all(|(_, w)| !w.is_visible().unwrap_or(false));
// if !exiting
// && (self.startup_forced_updates > 0 || headless || all_invisible || reactive)
// {
// self.redraw_requested(event_loop);
// }
// });
// }
self.redraw_requested(event_loop);