{"record":{"id":"b8e053387a63dc8f","repo":"emilk/egui","slug":"window-was-collapsed","errorCode":null,"errorMessage":"Window was collapsed","messagePattern":"Window was collapsed","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/egui/src/context.rs","lineNumber":4386,"sourceCode":"\n            out.expect(\n                \"egui backend is implemented incorrectly - the user callback was never called\",\n            )\n        })\n    }\n\n    fn show_embedded_viewport<T>(\n        &self,\n        new_viewport_id: ViewportId,\n        builder: ViewportBuilder,\n        viewport_ui_cb: impl FnOnce(&mut Ui) -> T,\n    ) -> T {\n        crate::Window::from_viewport(new_viewport_id, builder)\n            .collapsible(false)\n            .show(self, |ui| viewport_ui_cb(ui))\n            .unwrap_or_else(|| panic!(\"Window did not show\"))\n            .inner\n            .unwrap_or_else(|| panic!(\"Window was collapsed\"))\n    }\n}\n\n/// ## Interaction\nimpl Context {\n    /// Read which widgets are currently being interacted with.\n    pub fn interaction_snapshot<R>(&self, reader: impl FnOnce(&InteractionSnapshot) -> R) -> R {\n        self.write(|w| reader(&w.viewport().interact_widgets))\n    }\n\n    /// The widget currently being dragged, if any.\n    ///\n    /// For widgets that sense both clicks and drags, this will\n    /// not be set until the mouse cursor has moved a certain distance.\n    ///\n    /// NOTE: if the widget was released this pass, this will be `None`.\n    /// Use [`Self::drag_stopped_id`] instead.\n    pub fn dragged_id(&self) -> Option<Id> {","sourceCodeStart":4368,"sourceCodeEnd":4404,"githubUrl":"https://github.com/emilk/egui/blob/441971a776322a482e371775219380eca812cfa9/crates/egui/src/context.rs#L4368-L4404","documentation":"In the same `show_new_viewport` helper, after the window is shown its inner content is unwrapped. `Window::show` returns `None` for `.inner` when the window body was collapsed (title bar only, no content drawn), so the helper panics with \"Window was collapsed\" — even though the helper called `.collapsible(false)` on the window.","triggerScenarios":"Calling `ctx.show_new_viewport(builder, cb)` when the egui window state still reports the window as collapsed — typically stale/persisted collapse state in egui memory overriding the `.collapsible(false)` setting, so the body isn't rendered and `inner` is None.","commonSituations":"Restarting an app with egui persistence where the viewport window was collapsed when last saved; programmatically collapsing the window earlier in the same frame; viewport state restored from memory.","solutions":["Clear or fix the persisted window state: `ctx.memory_mut(|m| ...)` remove the window's collapsed flag, or reset egui memory in development.","Ensure nothing collapses the window programmatically before `show_new_viewport` is called.","Open the window once manually (uncollapse) so persisted state is updated, then rely on the helper.","If collapse is possible, use `Window::show` directly and handle the Option rather than this infallible helper."],"exampleFix":"// before\n// stale persisted state has the window collapsed\nctx.show_new_viewport(builder, |ui| { ... }); // panics: Window was collapsed\n// after\nctx.memory_mut(|mem| mem.data.remove_temp(win_id, \"collapsed\")); // or clear window state\nctx.show_new_viewport(builder, |ui| { ... });","handlingStrategy":"validation","validationCode":"// clear stale collapse state for the viewport window id before showing\nctx.memory_mut(|mem| mem.collapse(Window::from_viewport(new_viewport_id, builder.clone()).id(), false));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Uncollapse the window state before calling show_new_viewport each session start.","Avoid mixing programmatic collapse with the show_new_viewport helper.","When egui persistence is enabled, reset viewport window memory after upgrading versions.","Handle window state yourself via Window::show if collapse must be supported."],"tags":["viewport","window","ui-state","panic"],"backgroundTag":"invalid-state-transition","analyzedSha":"441971a776322a482e371775219380eca812cfa9","analyzedAt":"2026-09-12T04:29:21.500Z","contentChangedAt":"2026-09-12T04:29:21.500Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}