{"record":{"id":"2952afb6b70f7f59","repo":"iced-rs/iced","slug":"fill-rectangle","errorCode":null,"errorMessage":"Fill rectangle","messagePattern":"Fill rectangle","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"wgpu/src/geometry.rs","lineNumber":197,"sourceCode":"            .current\n            .0\n            .transform_point(lyon::math::Point::new(top_left.x, top_left.y));\n\n        let size = self\n            .transforms\n            .current\n            .0\n            .transform_vector(lyon::math::Vector::new(size.width, size.height));\n\n        let options = tessellation::FillOptions::default().with_fill_rule(into_fill_rule(rule));\n\n        self.fill_tessellator\n            .tessellate_rectangle(\n                &lyon::math::Box2D::new(top_left, top_left + size),\n                &options,\n                buffer.as_mut(),\n            )\n            .expect(\"Fill rectangle\");\n    }\n\n    fn stroke<'a>(&mut self, path: &Path, stroke: impl Into<Stroke<'a>>) {\n        let stroke = stroke.into();\n\n        let mut buffer = self\n            .buffers\n            .get_stroke(&self.transforms.current.transform_style(stroke.style));\n\n        let mut options = tessellation::StrokeOptions::default();\n        options.line_width = stroke.width;\n        options.start_cap = into_line_cap(stroke.line_cap);\n        options.end_cap = into_line_cap(stroke.line_cap);\n        options.line_join = into_line_join(stroke.line_join);\n\n        let path = if stroke.line_dash.segments.is_empty() {\n            Cow::Borrowed(path)\n        } else {","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/iced-rs/iced/blob/d146509d893945de5c304cfaf4301335eee278bd/wgpu/src/geometry.rs#L179-L215","documentation":"`Geometry::fill_rectangle` tessellates an axis-aligned rectangle with `fill_tessellator.tessellate_rectangle` and `.expect(\"Fill rectangle\")` panics on failure. Rectangle tessellation errors indicate bad numeric inputs (NaN/infinite corners) or an internal vertex allocation failure.","triggerScenarios":"`Frame::fill_rectangle(top_left, size)` (or internal fill calls) where `top_left + size` yields non-finite coordinates, or the lyon tessellator errors for degenerate rectangles; also triggered on GPU buffer allocation failure while writing the output buffer.","commonSituations":"Computed rectangle positions/sizes containing NaN (layout math divided by zero width); enormous sizes overflowing f32; degenerate zero-area rectangles produced by downstream widgets; faulty custom widget geometry code.","solutions":["Validate `top_left` and `size` for finiteness and positivity before calling `fill_rectangle`.","Clamp computed rectangle geometry to sane bounds in the widget that produces it.","Avoid passing zero-width/zero-height rectangles; skip drawing when the size is degenerate.","If it occurs with valid input, file a bug with iced/lyon including the exact rectangle values."],"exampleFix":"// before\nframe.fill_rectangle(position, size);\n// after\nif size.width.is_finite() && size.height.is_finite() && size.width > 0.0 && size.height > 0.0 {\n    frame.fill_rectangle(position, size);\n}","handlingStrategy":"validation","validationCode":"fn rect_is_valid(top_left: iced::Point, size: iced::Size) -> bool {\n    top_left.x.is_finite()\n        && top_left.y.is_finite()\n        && size.width.is_finite()\n        && size.height.is_finite()\n        && size.width > 0.0\n        && size.height > 0.0\n}","typeGuard":"fn drawable_size(size: iced::Size) -> bool {\n    size.width.is_finite() && size.height.is_finite() && size.width > 0.0 && size.height > 0.0\n}","tryCatchPattern":"// Skip invalid rectangles instead of panicking inside the tessellator\nif drawable_size(size) {\n    frame.fill_rectangle(position, size);\n}","preventionTips":["Validate layout-computed sizes before drawing rectangles.","Guard against division-by-zero in size calculations that feed fills.","Clamp sizes to positive finite ranges in widget draw code.","Skip zero-area rectangles explicitly rather than passing them down."],"tags":["rust","wgpu","lyon","tessellation","rectangle","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"}