From d5343cab92e1ca04ddb028f5040cbd1342c93c8c Mon Sep 17 00:00:00 2001 From: Ottatop Date: Tue, 28 May 2024 17:03:22 -0500 Subject: [PATCH] Don't panic when render state is unexpected Crashed after waking from sleep, hopefully this fixes that --- src/backend/udev.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/backend/udev.rs b/src/backend/udev.rs index 7fb5e31..7481ca1 100644 --- a/src/backend/udev.rs +++ b/src/backend/udev.rs @@ -767,9 +767,10 @@ struct DrmSurfaceDmabufFeedback { } /// The state of a [`RenderSurface`]. -#[derive(Debug)] +#[derive(Debug, Default)] enum RenderState { /// No render is scheduled. + #[default] Idle, // TODO: remove the token on tty switch or output unplug /// A render has been queued. @@ -1322,12 +1323,15 @@ impl Udev { } }; - let RenderState::WaitingForVblank { dirty } = surface.render_state else { - unreachable!(); + let dirty = match std::mem::take(&mut surface.render_state) { + RenderState::WaitingForVblank { dirty } => dirty, + state => { + debug!("vblank happened but render state was {state:?}",); + self.schedule_render(&pinnacle.loop_handle, &output); + return; + } }; - surface.render_state = RenderState::Idle; - if dirty { self.schedule_render(&pinnacle.loop_handle, &output); } else {