emilk/egui · error

Window did not show

Error message

Window did not show

What it means

`Context::show_new_viewport` (viewport helper) shows the new viewport as an egui `Window` and unwraps the `InnerResponse` from `Window::show`. `show` returns `None` when the window was not drawn this frame (e.g. collapsed to nothing, or constrained so it can't be laid out), in which case this code panics with "Window did not show".

Source

Thrown at crates/egui/src/context.rs:4384

                immediate_viewport_renderer(self, viewport);
            }

            out.expect(
                "egui backend is implemented incorrectly - the user callback was never called",
            )
        })
    }

    fn show_embedded_viewport<T>(
        &self,
        new_viewport_id: ViewportId,
        builder: ViewportBuilder,
        viewport_ui_cb: impl FnOnce(&mut Ui) -> T,
    ) -> T {
        crate::Window::from_viewport(new_viewport_id, builder)
            .collapsible(false)
            .show(self, |ui| viewport_ui_cb(ui))
            .unwrap_or_else(|| panic!("Window did not show"))
            .inner
            .unwrap_or_else(|| panic!("Window was collapsed"))
    }
}

/// ## Interaction
impl Context {
    /// Read which widgets are currently being interacted with.
    pub fn interaction_snapshot<R>(&self, reader: impl FnOnce(&InteractionSnapshot) -> R) -> R {
        self.write(|w| reader(&w.viewport().interact_widgets))
    }

    /// The widget currently being dragged, if any.
    ///
    /// For widgets that sense both clicks and drags, this will
    /// not be set until the mouse cursor has moved a certain distance.
    ///
    /// NOTE: if the widget was released this pass, this will be `None`.

View on GitHub (pinned to 441971a776)

Solutions

  1. Ensure the ViewportBuilder/window state is not collapsed (set `.collapsible(false)` semantics or default_open/resizable state so it renders).
  2. Check persisted egui memory for stale collapsed state; clear memory or reset the viewport's window state.
  3. Give the viewport enough space: enlarge the parent window or adjust the builder's default size/position.
  4. If the window may legitimately fail to show, handle it yourself with `Window::show` + Option check instead of this helper.

Example fix

// before
let viewport = ViewportBuilder::default().with_collapsed(true);
ctx.show_new_viewport(viewport, |ui| { ... }); // panics: Window did not show
// after
let viewport = ViewportBuilder::default().with_collapsed(false);
ctx.show_new_viewport(viewport, |ui| { ... });
Defensive patterns

Strategy: validation

Validate before calling

// ensure the viewport window will render
let builder = ViewportBuilder::default().with_collapsed(false);
assert!(!is_collapsed(ctx, new_viewport_id), "viewport window must not be collapsed before show_new_viewport");

Prevention

When it happens

Trigger: Calling `ctx.show_new_viewport(builder, cb)` where `Window::from_viewport(...).show(...)` returns `None` — typically because the window is fully collapsed/minimized so egui skips painting it, or layout constraints leave no space to show it.

Common situations: Creating child viewports that start collapsed (`ViewportBuilder` with collapsed state) or restoring persisted window state that is collapsed; very small host windows leaving no room for the new viewport window.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of emilk/egui@441971a776 (2026-09-12). Data as JSON: /api/errors/77460b477e985d8c. Report an issue: GitHub.