fix(renderer): keep the app alive when the wgpu surface goes Outdated (#558)

At a non-default UI scale, SLINT_SCALE_FACTOR changes the physical surface
size and the first frames race the winit resize/scale-factor event that
reconfigures the swapchain, so get_current_texture() returns Outdated. The
vendored femtovg-wgpu backend reconfigured and retried once, then propagated a
second Outdated via `?`, which killed the event loop and left the app unable
to start at any interface size other than default. Treat a persistent Outdated
like the #540 timeout: skip the frame and back off briefly; the next
resize/redraw reconfigures cleanly. wgpu now survives the scale race without
depending on the degradation ladder falling back to GL.

cc
This commit is contained in:
vicrodh committed 2026-07-13 13:11:12 -06:00
1 parent 957ac6503a
commit 80088b6a0b
1 file changed
+39 -3
+39 -3
View File
@@ -150,13 +150,49 @@ impl GraphicsBackend for WGPUBackend {
}
return Err(Box::new(crate::FrameSkipped));
}
// Outdated or lost: re-configure and try again
// Outdated or lost: reconfigure from the current config and retry
// ONCE.
//
// QBZ vendor patch (issue #558): if the retry is STILL Outdated the
// reconfigure hasn't caught up with the surface yet — this happens
// at startup under a non-default UI scale, where SLINT_SCALE_FACTOR
// changes the physical surface size and the first frames race the
// winit resize/scale-factor event that reconfigures the swapchain.
// Upstream `?`-propagated that second failure, which killed the
// event loop with "The underlying surface has changed, and
// therefore the swap chain must be updated" and left the app unable
// to start at ANY interface size other than default (the crash the
// reporter hit even after the degradation-ladder fix). Treat a
// persistent Outdated like the #540 timeout instead: skip this
// frame and back off briefly, never a fatal error. The next
// resize/redraw reconfigures with the correct dimensions and the
// following acquire succeeds.
Err(_) => {
{
let mut device = self.device.borrow_mut();
let device = device.as_mut().unwrap();
surface.configure(device, self.surface_config.borrow().as_ref().unwrap());
surface.get_current_texture()?
}
match surface.get_current_texture() {
Ok(texture) => texture,
Err(_) => {
let backoff = (self.acquire_backoff_ms.get().max(30) * 2).min(1000);
self.acquire_backoff_ms.set(backoff);
self.acquire_skip_until.set(Some(
std::time::Instant::now()
+ std::time::Duration::from_millis(backoff),
));
static WARNED: std::sync::atomic::AtomicBool =
std::sync::atomic::AtomicBool::new(false);
if !WARNED.swap(true, std::sync::atomic::Ordering::Relaxed) {
eprintln!(
"qbz(femtovg-wgpu): surface still outdated after reconfigure \
(UI-scale/resize race?); skipping frames until it settles"
);
}
return Err(Box::new(crate::FrameSkipped));
}
}
}
};
self.acquire_backoff_ms.set(0);