bashbar icon indicating copy to clipboard operation
bashbar copied to clipboard

Fix: handle SurfaceError::Outdated in render loop

Open diegoQuinas opened this issue 3 months ago • 2 comments

This patch fixes a runtime crash caused by wgpu::SurfaceError::Outdated when the window surface changes (resize, minimize, etc). The fix reconfigures the surface using the existing device and config to allow the renderer to recover gracefully.

diegoQuinas avatar Oct 22 '25 22:10 diegoQuinas

Now it doesn't panics, anyway in i3 the first launch if it isn't in fullscreen it tries to reconfigure infinitely and the window looks glitched. When the window resizes it starts to work well

diegoQuinas avatar Oct 22 '25 23:10 diegoQuinas

Thanks for the PR :smile:

Now it doesn't panics, anyway in i3 the first launch if it isn't in fullscreen it tries to reconfigure infinitely and the window looks glitched. When the window resizes it starts to work well

I think the issue is that we're reconfiguring or expecting a frame inside the render loop before the actual WindowEvent::Resized has been processed. Since we already handle Resized events properly (egor's app crate (winit - windowing): https://github.com/wick3dr0se/egor/blob/main/crates/egor_app/src/lib.rs#L116), we probably just need to skip the first frame

Could you try something like this instead?

let frame = match self.target.surface.get_current_texture() {
    Ok(frame) => frame,
    Err(wgpu::SurfaceError::OutOfMemory) => {
        panic!("Out of GPU memory!");
    }
    Err(_) => return, // Just skip the frame & let `Resized` reconfigure it later
};

Not exactly sure why it's happening yet but assuming you're starting it in tiled mode or something in i3 maybe it's not setting dimensions on the window before that first frame hit

wick3dr0se avatar Oct 25 '25 14:10 wick3dr0se