iced-rs/iced · info

Create clip mask

Error message

Create clip mask

What it means

When a tiny-skia Surface is constructed, iced allocates a placeholder 1x1 clip mask via tiny_skia::Mask::new(1, 1). Mask::new returns None only for zero dimensions or when the width*height allocation exceeds tiny-skia's internal ceiling; with the constant arguments 1x1 neither condition can hold, so this expect is a defensive assertion that effectively cannot fire unless the process is already out of memory.

Solutions

  1. Treat the panic as an OOM symptom: capture a memory profile of the process at crash time
  2. Reduce the number of simultaneous window surfaces or the retained frame history (max_age frames per surface)
  3. Fix the memory leak in the host application that exhausted the allocator
Defensive patterns

Strategy: fallback

Prevention

When it happens

Trigger: Only a failed allocation of a single mask byte: the process is at allocator exhaustion at the exact moment a window surface is created. No input or configuration reaches this code path with invalid values because the arguments are the literals 1 and 1.

Common situations: Never seen in isolation; if it appears, it accompanies a broader out-of-memory condition such as unbounded layer caching in long-running applications or memory leaks in the embedding application.

Related errors


AI-assisted analysis of iced-rs/iced@3de451447b (2026-08-17). Data as JSON: /api/errors/2a11247668260317. Report an issue: GitHub.

Appendix: source

Thrown at tiny_skia/src/window/compositor.rs:66

        Ok(new(display))
    }

    fn create_renderer(&self, settings: renderer::Settings) -> Self::Renderer {
        Renderer::new(settings)
    }

    fn create_surface(
        &mut self,
        window: impl compositor::Window + Clone,
        width: u32,
        height: u32,
    ) -> Self::Surface {
        let window = softbuffer::Surface::new(&self.context, Box::new(window.clone()) as _)
            .expect("Create softbuffer surface for window");

        let mut surface = Surface {
            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"),
            )

View on GitHub (pinned to 3de451447b)