bevyengine/bevy · error

DiagnosticsOverlay has been tempered with. Do not despawn it

Error message

DiagnosticsOverlay has been tempered with. Do not despawn its children.

What it means

Marked unreachable in collapse_on_click_to_header: the DiagnosticsOverlay entity has no Children component, meaning its child list was removed after spawning. The overlay always spawns with children, so this indicates user code despawned or stripped them.

Source

Thrown at crates/bevy_dev_tools/src/diagnostics_overlay.rs:472

    }
}

fn collapse_on_click_to_header(
    mut event: On<PointerClick>,
    mut diagnostics_overlays: Query<&Children, With<DiagnosticsOverlay>>,
    mut diagnostics_overlay_contents: Query<&mut Node, With<DiagnosticsOverlayContents>>,
    diagnostics_overlay_header: Query<&ChildOf, With<DiagnosticsOverlayHeader>>,
) {
    if event.duration > Duration::from_millis(250) {
        return;
    }

    let entity = event.entity;
    if let Ok(child_of) = diagnostics_overlay_header.get(entity) {
        event.propagate(false);

        let Ok(children) = diagnostics_overlays.get_mut(child_of.get()) else {
            unreachable!("DiagnosticsOverlay has been tempered with. Do not despawn its children.");
        };
        let mut lists_iter = diagnostics_overlay_contents
            .iter_many_mut(children.collection())
            .matched();

        let Some(mut node) = lists_iter.fetch_next() else {
            panic!(
                "DiagnosticsOverlay has been tempered with. DiagnosticsOverlay must\
            have a child with DiagnosticsList."
            );
        };

        let next_display_mode = match node.display {
            Display::Grid => Display::None,
            Display::None => Display::Grid,
            _ => panic!(
                "The DiagnosticsList has be tempered with. Valid Displays for a\
            DiagnosticsList are Grid or None."

View on GitHub (pinned to 396ca72708)

Solutions

  1. Do not despawn or remove children of the diagnostics overlay
  2. Recreate the overlay through DiagnosticsOverlayPlugin if the hierarchy was modified
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at crates/bevy_dev_tools/src/diagnostics_overlay.rs:472 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of bevyengine/bevy@396ca72708 (2026-08-20). Data as JSON: /api/errors/9041e5817f082436. Report an issue: GitHub.