{"record":{"id":"4c077924ee5c61fe","repo":"iced-rs/iced","slug":"resize-surface","errorCode":null,"errorMessage":"Resize surface","messagePattern":"Resize surface","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tiny_skia/src/window/compositor.rs","lineNumber":85,"sourceCode":"            frames: VecDeque::new(),\n            max_age: 0,\n        };\n\n        if width > 0 && height > 0 {\n            self.configure_surface(&mut surface, width, height);\n        }\n\n        surface\n    }\n\n    fn configure_surface(&mut self, surface: &mut Self::Surface, width: u32, height: u32) {\n        surface\n            .window\n            .resize(\n                NonZeroU32::new(width).expect(\"Non-zero width\"),\n                NonZeroU32::new(height).expect(\"Non-zero height\"),\n            )\n            .expect(\"Resize surface\");\n\n        surface.clip_mask = tiny_skia::Mask::new(width, height).expect(\"Create clip mask\");\n        surface.frames.clear();\n    }\n\n    fn information(&self) -> Information {\n        Information {\n            adapter: String::from(\"CPU\"),\n            backend: String::from(\"tiny-skia\"),\n        }\n    }\n\n    fn present(\n        &mut self,\n        renderer: &mut Self::Renderer,\n        surface: &mut Self::Surface,\n        viewport: &Viewport,\n        background_color: Color,","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/iced-rs/iced/blob/d146509d893945de5c304cfaf4301335eee278bd/tiny_skia/src/window/compositor.rs#L67-L103","documentation":"`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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\ncompositor.configure_surface(&mut surface, &window);\n// after\nlet size = window.inner_size();\nif size.width > 0 && size.height > 0 {\n    compositor.configure_surface(&mut surface, &window);\n}","handlingStrategy":"validation","validationCode":"let size = window.inner_size();\nif size.width == 0 || size.height == 0 {\n    return; // wait for the next resize event\n}\ncompositor.configure_surface(&mut surface, &window);","typeGuard":"fn has_valid_size(size: winit::dpi::PhysicalSize<u32>) -> bool {\n    size.width > 0 && size.height > 0\n}","tryCatchPattern":"// The library expects; guard the caller instead\nif has_valid_size(window.inner_size()) {\n    compositor.configure_surface(&mut surface, &window);\n}","preventionTips":["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."],"tags":["rust","tiny-skia","surface","resize","window","panic"],"backgroundTag":"invalid-argument-value","analyzedSha":"d146509d893945de5c304cfaf4301335eee278bd","analyzedAt":"2026-09-11T16:54:14.229Z","contentChangedAt":"2026-09-11T16:54:14.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}