zed-industries/zed · error

Callback above only errors or returns Some

Error message

Callback above only errors or returns Some

What it means

When inserting a rasterized glyph into the sprite atlas, get_or_insert_with's closure returns Ok(Some(...)) — it can only error or produce a tile. The expect fires if the atlas reported a tile present but the closure produced None, meaning atlas/closure contract violation (internal bug or race).

Source

Thrown at crates/gpui/src/window.rs:4561

    /// This method should only be called as part of the paint phase of element drawing.
    pub fn paint_glyph(
        &mut self,
        origin: Point<Pixels>,
        font_id: FontId,
        glyph_id: GlyphId,
        font_size: Pixels,
        color: Hsla,
    ) -> Result<()> {
        self.invalidator.debug_assert_paint();

        let element_opacity = self.element_opacity();
        let scale_factor = self.scale_factor();
        let glyph_origin = origin.scale(scale_factor);

        let quantized_origin = Point::new(
            round_half_toward_zero(glyph_origin.x.0 * SUBPIXEL_VARIANTS_X as f32)
                / SUBPIXEL_VARIANTS_X as f32,
            round_half_toward_zero(glyph_origin.y.0 * SUBPIXEL_VARIANTS_Y as f32)
                / SUBPIXEL_VARIANTS_Y as f32,
        );
        let subpixel_variant = Point::new(
            (quantized_origin.x.fract() * SUBPIXEL_VARIANTS_X as f32) as u8,
            (quantized_origin.y.fract() * SUBPIXEL_VARIANTS_Y as f32) as u8,
        );
        let integer_origin = quantized_origin.map(|c| ScaledPixels(c.trunc()));
        let subpixel_rendering = self.should_use_subpixel_rendering(font_id, font_size);
        let dilation = self.text_system().glyph_dilation_for_color(color);
        let params = RenderGlyphParams {
            font_id,
            glyph_id,
            font_size,
            subpixel_variant,
            scale_factor,
            is_emoji: false,
            subpixel_rendering,
            dilation,

View on GitHub (pinned to 9d272b0363)

Solutions

  1. Verify the rasterize_glyph closure always returns Ok(Some(..)) on success
  2. Check for races or double-insert on the same atlas key
  3. Report as a framework bug if the closure provably returns Some
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/gpui/src/window.rs:4307 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-08-20). Data as JSON: /api/errors/5bdc9c4f91ea9582. Report an issue: GitHub.