Merge pull request #3067 from camspiers/fixes/surface-outdated

Reconfigure wgpu surface on SurfaceError Lost or Outdated
This commit is contained in:
Héctor 2025-11-29 15:11:10 +01:00 committed by GitHub
commit 1cde186def
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1009,10 +1009,35 @@ async fn run_instance<P>(
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();
if error == compositor::SurfaceError::Lost {
window.surface = current_compositor
.create_surface(
window.raw.clone(),
physical_size.width,
physical_size.height,
);
} else {
current_compositor.configure_surface(
&mut window.surface,
physical_size.width,
physical_size.height,
);
}
window.raw.request_redraw();
}
_ => {
present_span.finish();