From 43a79130f60980fba45b81ccbf3a620dc3b43c29 Mon Sep 17 00:00:00 2001 From: Cam Spiers Date: Wed, 1 Oct 2025 23:10:10 +1300 Subject: [PATCH] Reconfigure surface on `SurfaceError::Lost` or `Outdated` --- winit/src/lib.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/winit/src/lib.rs b/winit/src/lib.rs index 92007e56..89d35b73 100644 --- a/winit/src/lib.rs +++ b/winit/src/lib.rs @@ -1009,10 +1009,26 @@ async fn run_instance

( present_span.finish(); } Err(error) => match error { - // This is an unrecoverable error. compositor::SurfaceError::OutOfMemory => { + // This is an unrecoverable error. panic!("{error:?}"); } + compositor::SurfaceError::Outdated + | compositor::SurfaceError::Lost => { + present_span.finish(); + + // Reconfigure surface and try redrawing + let physical_size = + window.state.physical_size(); + + current_compositor.configure_surface( + &mut window.surface, + physical_size.width, + physical_size.height, + ); + + window.raw.request_redraw(); + } _ => { present_span.finish();