From fc481106afadd97553d5d576e00a9a3a87d8d479 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Fri, 30 Dec 2022 08:52:01 -0700 Subject: [PATCH] windows: avoid panic when minimizing w/ WebGpu ``` thread 'main' panicked at 'Error in Surface::configure: Both `Surface` width and height must be non-zero. Wait to recreate the `Surface` until the window has non-zero area.', C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\wgpu-0.14.0\src\backend\direct.rs:274:9 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ``` refs: https://github.com/wez/wezterm/issues/2881 --- docs/changelog.md | 2 ++ wezterm-gui/src/termwindow/webgpu.rs | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/changelog.md b/docs/changelog.md index 34e31504a..0fe5b4445 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -27,6 +27,8 @@ As features stabilize some brief notes about them will accumulate here. [#2819](https://github.com/wez/wezterm/issues/2819) * `wezterm ssh` now respects the `AddressFamily` option when connecting [#2893](https://github.com/wez/wezterm/issues/2893) +* Windows: panic when minimizing a window when `front_end='WebGpu'` + [#2881](https://github.com/wez/wezterm/issues/2881) #### Changed * `CTRL-SHIFT-P` now activates the new command palette, instead of `PaneSelect` diff --git a/wezterm-gui/src/termwindow/webgpu.rs b/wezterm-gui/src/termwindow/webgpu.rs index 5590f21d4..796f25553 100644 --- a/wezterm-gui/src/termwindow/webgpu.rs +++ b/wezterm-gui/src/termwindow/webgpu.rs @@ -474,6 +474,11 @@ impl WebGpuState { let mut config = self.config.borrow_mut(); config.width = dims.pixel_width as u32; config.height = dims.pixel_height as u32; - self.surface.configure(&self.device, &config); + if config.width > 0 && config.height > 0 { + // Avoid reconfiguring with a 0 sized surface, as webgpu will + // panic in that case + // + self.surface.configure(&self.device, &config); + } } }