fix(renderer): treat wgpu surface-acquire timeout as a skipped frame

Issue #540: under Hyprland VFR a static screen or hidden workspace
stops compositor frame callbacks, wgpu's get_current_texture() times
out, and the vendored femtovg-wgpu backend retried once then
propagated the error — killing the event loop and the app mid-
playback.

A surface-acquire timeout is transient by definition: return a
FrameSkipped sentinel instead, which the renderer treats as nothing-
to-render, and back off exponentially (250 ms to 2 s) so repeated
redraw requests do not keep blocking the UI thread on a parked
compositor. The first successful acquire resets the cooldown. A
one-time stderr notice aids field diagnosis. Also give the vendored
crate an empty [workspace] table so it can be cargo-checked
standalone.

cc
This commit is contained in:
vicrodh committed 2026-07-04 17:26:04 -06:00
1 parent 1e521a182f
commit 6bf4bb2414
4 files changed
+70 -2672

No files matched your search

+23 -1
View File
@@ -48,6 +48,22 @@ pub trait WindowSurface<R: femtovg::Renderer> {
fn render_output(&self) -> impl Into<R::RenderOutput>;
}
/// QBZ vendor patch (issue #540): sentinel error a graphics backend returns
/// from `begin_surface_rendering` when the current frame should be silently
/// skipped (e.g. a transient wgpu surface-acquire timeout while the
/// compositor is parked by VRR). The renderer treats it as "nothing to
/// render" instead of a fatal platform error.
#[derive(Debug)]
pub struct FrameSkipped;
impl core::fmt::Display for FrameSkipped {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.write_str("frame skipped: surface temporarily unavailable")
}
}
impl std::error::Error for FrameSkipped {}
pub trait GraphicsBackend {
type Renderer: femtovg::Renderer + TextureImporter;
type WindowSurface: WindowSurface<Self::Renderer>;
@@ -125,7 +141,13 @@ impl<B: GraphicsBackend> FemtoVGRenderer<B> {
surface_size: i_slint_core::api::PhysicalSize,
post_render_cb: Option<&dyn Fn(&mut dyn ItemRenderer)>,
) -> Result<(), i_slint_core::platform::PlatformError> {
let surface = self.graphics_backend.begin_surface_rendering()?;
// QBZ vendor patch (issue #540): a FrameSkipped from the backend is
// "nothing to render this frame", not a fatal error — the next
// redraw request will try again once the compositor resumes.
let surface = match self.graphics_backend.begin_surface_rendering() {
Err(e) if e.is::<FrameSkipped>() => return Ok(()),
other => other?,
};
if self.rendering_first_time.take() {
*self.rendering_metrics_collector.borrow_mut() = RenderingMetricsCollector::new(