iced-rs/iced · error
Non-zero height
Error message
Non-zero height
What it means
The height half of configure_surface's NonZeroU32 conversion: NonZeroU32::new(height).expect("Non-zero height") panics when height == 0. create_surface guards both dimensions (compositor.rs:71) and iced_winit filters zero physical sizes before configuring (winit/src/lib.rs:759-761), so the panic requires calling the Compositor trait's configure_surface directly with a zero height, e.g. from a custom windowing loop.
Source
Thrown at tiny_skia/src/window/compositor.rs:83
window,
clip_mask: tiny_skia::Mask::new(1, 1).expect("Create clip mask"),
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,View on GitHub (pinned to 3de451447b)
Solutions
- Filter zero-height resize events before calling configure_surface
- Clamp height to 1 when a valid surface must exist even for hidden windows
- Reuse the stock iced_winit runtime, which already skips configuration on 0x0
Example fix
// before
compositor.configure_surface(&mut surface, size.width, size.height);
// after
if size.width > 0 && size.height > 0 {
compositor.configure_surface(&mut surface, size.width, size.height);
} Defensive patterns
Strategy: validation
Validate before calling
// Before configuring a surface in a custom runtime:
fn is_configurable(size: (u32, u32)) -> bool {
size.0 > 0 && size.1 > 0
}
if is_configurable((physical.width, physical.height)) {
compositor.configure_surface(&mut surface, physical.width, physical.height);
} Prevention
- Treat 0x0 resize events as 'window hidden', not as a size to apply
- Clamp to 1x1 only when a valid backbuffer must exist while hidden
When it happens
Trigger: A custom runtime calling configure_surface(&mut surface, width, 0) for a minimized or not-yet-sized window; forwarding winit Resized events with unfiltered inner_size() values; driving the compositor in tests with dummy 0-height viewports.
Common situations: Minimized windows on Windows/Linux reporting 0 height; custom embedded runtimes that skip iced_winit's guards; race conditions between window creation and the first size event.
Related errors
- Non-zero width
- Create pixel map
- Create softbuffer surface for window
- Create softbuffer context
- Create color
AI-assisted analysis of iced-rs/iced@3de451447b (2026-08-17).
Data as JSON: /api/errors/596b389dc3092534.
Report an issue: GitHub.