Reconfigure surface on SurfaceError::Lost or Outdated

This commit is contained in:
Cam Spiers 2025-10-01 23:10:10 +13:00 committed by Héctor Ramón Jiménez
parent 39ca9e0233
commit 43a79130f6
No known key found for this signature in database
GPG key ID: 7CC46565708259A7

View file

@ -1009,10 +1009,26 @@ 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();
current_compositor.configure_surface(
&mut window.surface,
physical_size.width,
physical_size.height,
);
window.raw.request_redraw();
}
_ => {
present_span.finish();