zed-industries/zed · error

parent absolute outer origin should be cached

Error message

parent absolute outer origin should be cached

What it means

TaffyLayoutEngine::layout_bounds computes a child's absolute bounds from its parent's cached bounds; the expect asserts the parent's absolute outer origin is already in the cache. Firing means layout ran with a parent whose cached bounds were not computed first — a taffy layout ordering/traversal bug.

Source

Thrown at crates/gpui/src/taffy.rs:367

    pub fn layout_bounds(&mut self, id: LayoutId, scale_factor: f32) -> Bounds<Pixels> {
        if let Some(layout) = self.absolute_layout_bounds.get(&id).cloned() {
            return layout;
        }

        let layout = self.taffy.layout(id.into()).expect(EXPECT_MESSAGE);
        let layout_location = layout.location;
        let layout_size = layout.size;
        let parent = self.taffy.parent(id.0);

        let absolute_outer_origin = match parent {
            Some(parent_id) => {
                let parent_id = LayoutId::from(parent_id);
                self.layout_bounds(parent_id, scale_factor);
                let parent_origin = *self
                    .absolute_outer_origins
                    .get(&parent_id)
                    .expect("parent absolute outer origin should be cached");
                parent_origin + Point::from(layout_location)
            }
            None => Point::from(layout_location),
        };
        self.absolute_outer_origins
            .insert(id, absolute_outer_origin);

        let absolute_far = absolute_outer_origin + Point::from(Size::from(layout_size));
        let snapped_bounds = Bounds::from_corners(
            absolute_outer_origin.map(round_half_toward_zero),
            absolute_far.map(round_half_toward_zero),
        );

        let bounds = (snapped_bounds / scale_factor).map(Pixels);
        self.absolute_layout_bounds.insert(id, bounds);
        bounds
    }
}

View on GitHub (pinned to f4178619ac)

Solutions

  1. Ensure parents are processed before children when computing absolute layout bounds
  2. Check that compute_layout ran on the full tree before layout_bounds queries
  3. Reproduce with a minimal nested-layout case and inspect cache population order
Defensive patterns

Strategy: validation

When it happens

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

Common situations: See trigger scenarios.


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