iced-rs/iced · error
Resize surface
Error message
Resize surface
What it means
`Compositor::configure_surface` resizes the softbuffer surface to the window's physical size with `Surface::resize`, which requires non-zero dimensions; the call's `expect("Resize surface")` panics if softbuffer rejects the resize. A zero width/height (minimized or not-yet-laid-out window) trips the inner `NonZeroU32` expects, and other resize failures trip the outer one.
Solutions
- Skip surface configuration when physical size is zero: check `width > 0 && height > 0` before creating/configuring the surface.
- Reconfigure on the next resize event instead of configuring eagerly at startup.
- Validate dimensions before calling compositor configuration in your shell code, or guard redraw when the window is minimized.
- Update softbuffer/drivers if resize fails with valid non-zero dimensions.
Example fix
// before
compositor.configure_surface(&mut surface, &window);
// after
let size = window.inner_size();
if size.width > 0 && size.height > 0 {
compositor.configure_surface(&mut surface, &window);
} Defensive patterns
Strategy: validation
Validate before calling
let size = window.inner_size();
if size.width == 0 || size.height == 0 {
return; // wait for the next resize event
}
compositor.configure_surface(&mut surface, &window); Type guard
fn has_valid_size(size: winit::dpi::PhysicalSize<u32>) -> bool {
size.width > 0 && size.height > 0
} Try / catch
// The library expects; guard the caller instead
if has_valid_size(window.inner_size()) {
compositor.configure_surface(&mut surface, &window);
} Prevention
- Never configure surfaces for minimized or zero-sized windows.
- Defer surface creation until the first non-zero resize event.
- Handle platform quirks that report 0-size client areas at startup.
- Test startup behavior with windows launched minimized or hidden.
When it happens
Trigger: Creating/reconfiguring a tiny_skia window surface while the window has zero physical width or height (minimized window, hidden window, or first layout before sizing), or a softbuffer resize error from an invalid/lost surface.
Common situations: App starts minimized or on a headless/virtual display reporting 0-size; window is minimized by the user and the runtime still tries to redraw; platform quirks returning 0-sized client areas during window creation.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
AI-assisted analysis of iced-rs/iced@d146509d89 (2026-09-11).
Data as JSON: /api/errors/4c077924ee5c61fe.
Report an issue: GitHub.
Appendix: source
Thrown at tiny_skia/src/window/compositor.rs:85
frames: VecDeque::new(),
max_age: 0,
};
if width > 0 && height > 0 {
self.configure_surface(&mut surface, width, height);
}
surface
}
fn configure_surface(&mut self, surface: &mut Self::Surface, width: u32, height: u32) {
surface
.window
.resize(
NonZeroU32::new(width).expect("Non-zero width"),
NonZeroU32::new(height).expect("Non-zero height"),
)
.expect("Resize surface");
surface.clip_mask = tiny_skia::Mask::new(width, height).expect("Create clip mask");
surface.frames.clear();
}
fn information(&self) -> Information {
Information {
adapter: String::from("CPU"),
backend: String::from("tiny-skia"),
}
}
fn present(
&mut self,
renderer: &mut Self::Renderer,
surface: &mut Self::Surface,
viewport: &Viewport,
background_color: Color,View on GitHub (pinned to d146509d89)