{"record":{"id":"dcf6c578e7a813e9","repo":"iced-rs/iced","slug":"node-configuration-and-count-do-not-match","errorCode":null,"errorMessage":"Node configuration and count do not match","messagePattern":"Node configuration and count do not match","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"widget/src/pane_grid/node.rs","lineNumber":292,"sourceCode":"                    Axis::Vertical => (count_a.vertical(), count_b.vertical()),\n                };\n\n                let (region_a, region_b, _ratio) = axis.split(\n                    current,\n                    *ratio,\n                    spacing,\n                    min_size * (a_factor + 1) as f32 + spacing * a_factor as f32,\n                    min_size * (b_factor + 1) as f32 + spacing * b_factor as f32,\n                );\n\n                a.compute_regions(spacing, min_size, &region_a, count_a, regions);\n                b.compute_regions(spacing, min_size, &region_b, count_b, regions);\n            }\n            (Node::Pane(pane), Count::Pane) => {\n                let _ = regions.insert(*pane, *current);\n            }\n            _ => {\n                unreachable!(\"Node configuration and count do not match\")\n            }\n        }\n    }\n\n    fn compute_splits(\n        &self,\n        spacing: f32,\n        min_size: f32,\n        current: &Rectangle,\n        count: &Count,\n        splits: &mut BTreeMap<Split, (Axis, Rectangle, f32)>,\n    ) {\n        match (self, count) {\n            (\n                Node::Split {\n                    axis,\n                    ratio,\n                    a,","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/iced-rs/iced/blob/d146509d893945de5c304cfaf4301335eee278bd/widget/src/pane_grid/node.rs#L274-L310","documentation":"`Node::compute_regions` walks a pane_grid `Node` tree alongside a parallel `Count` tree and reaches a shape pair (node kind, count kind) that cannot correspond — e.g. a `Node::Split` paired with `Count::Pane`, or a `Node::Pane` paired with `Count::Split`. This indicates the count structure was computed from a different tree than the node tree, so the library calls `unreachable!`.","triggerScenarios":"Calling `pane_regions`/`PaneGrid::layout` where the `Count` snapshot and the `Node` tree were produced at different times — e.g. a pane was split/removed after the count was derived, or application code deserialized/constructed a mismatched node/count pair.","commonSituations":"Custom pane_grid state restoration (saving/loading layouts) where counts and nodes drift out of sync; racing state updates that split a pane while regions are computed; hand-built `Node` values in tests or custom widgets.","solutions":["Regenerate the `Count` tree from the same `PaneGridState`/node snapshot used for region computation so both structures match.","If layout is persisted, save node and count together atomically and validate on load (recompute counts by walking the node tree).","Check that split/close operations update the cached count structure in the same update cycle as the node mutation.","Report if triggered by ordinary `PaneGrid` usage — it indicates an internal desync bug."],"exampleFix":"// before\ncounts = old_snapshot.counts(); // stale\nregions = node.compute_regions(..., counts, ...);\n// after\ncounts = state.counts(); // derived from the same PaneGridState as `node`\nregions = node.compute_regions(..., counts, ...);","handlingStrategy":"validation","validationCode":"// Re-derive counts from the same node snapshot before layout\nfn counts_match(node: &Node, count: &Count) -> bool {\n    match (node, count) {\n        (Node::Split { a, b }, Count::Split { a: ca, b: cb }) => {\n            counts_match(a, ca) && counts_match(b, cb)\n        }\n        (Node::Pane(_), Count::Pane) => true,\n        _ => false,\n    }\n}","typeGuard":"fn is_consistent(node: &Node, count: &Count) -> bool {\n    matches!(\n        (node, count),\n        (Node::Split { .. }, Count::Split { .. }) | (Node::Pane(_), Count::Pane)\n    )\n}","tryCatchPattern":"// unreachable! panics; validate before calling pane_regions\nif !is_consistent(&node, &count) { return Err(\"node/count desync\"); }\nlet regions = node.compute_regions(...);","preventionTips":["Always derive Count trees from the exact same PaneGridState as the Node tree.","Update nodes and counts atomically on split/close operations.","Validate persisted layouts on load by walking the node tree.","Avoid sharing node snapshots across update cycles."],"tags":["rust","pane-grid","layout","invariant","panic"],"backgroundTag":"internal-invariant-violation","analyzedSha":"d146509d893945de5c304cfaf4301335eee278bd","analyzedAt":"2026-09-11T16:54:14.229Z","contentChangedAt":"2026-09-11T16:54:14.229Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}