From 80088b6a0b8e4b042c37e14e2cea047cd8162772 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Mon, 13 Jul 2026 13:11:12 -0600 Subject: [PATCH] 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 --- .../i-slint-renderer-femtovg-1.16.1/wgpu.rs | 48 ++++++++++++++++--- 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/crates/vendor/i-slint-renderer-femtovg-1.16.1/wgpu.rs b/crates/vendor/i-slint-renderer-femtovg-1.16.1/wgpu.rs index 031e3f3e2..f9977deb0 100644 --- a/crates/vendor/i-slint-renderer-femtovg-1.16.1/wgpu.rs +++ b/crates/vendor/i-slint-renderer-femtovg-1.16.1/wgpu.rs @@ -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()? + { + let mut device = self.device.borrow_mut(); + let device = device.as_mut().unwrap(); + surface.configure(device, self.surface_config.borrow().as_ref().unwrap()); + } + 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);