diff --git a/crates/fj-window/src/run.rs b/crates/fj-window/src/run.rs index 401bebaae..a7815a8cb 100644 --- a/crates/fj-window/src/run.rs +++ b/crates/fj-window/src/run.rs @@ -51,6 +51,12 @@ pub fn run( let mut camera = Camera::new(&Default::default()); let mut camera_update_once = watcher.is_some(); + // Only handle resize events once every frame. This filters out spurious + // resize events that can lead to wgpu warnings. See this issue for some + // context: + // https://github.com/rust-windowing/winit/issues/2094 + let mut new_size = None; + event_loop.run(move |event, _, control_flow| { trace!("Handling event: {:?}", event); @@ -147,11 +153,10 @@ pub fn run( event: WindowEvent::Resized(size), .. } => { - let size = Size { + new_size = Some(Size { width: size.width, height: size.height, - }; - renderer.handle_resize(size); + }); } Event::WindowEvent { event: WindowEvent::MouseInput { state, button, .. }, @@ -169,6 +174,9 @@ pub fn run( if let Some(shape) = &shape { camera.update_planes(&shape.aabb); } + if let Some(size) = new_size.take() { + renderer.handle_resize(size); + } let egui_input = egui_winit_state.take_egui_input(window.window());