emilk/egui · error

Failed to get interaction

Error message

Failed to get interaction

What it means

Error "Failed to get interaction" thrown in emilk/egui.

Solutions

  1. The interaction snapshot is missing for this pass: don't access Memory interaction state outside a UI pass; read it from within update.

Example fix

// Access interaction state inside the app update:
fn update(&mut self, ctx: &egui::Context, _: &mut eframe::Frame) { let _ = ctx.memory(|m| m.interaction()); }

When it happens

Trigger: Thrown at crates/egui/src/memory/mod.rs:1022 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of emilk/egui@1a9d2af9ef (2026-08-19). Data as JSON: /api/errors/6a029b5e6090440f. Report an issue: GitHub.

Appendix: source

Thrown at crates/egui/src/memory/mod.rs:1026

    /// Forget window positions, sizes etc.
    /// Can be used to auto-layout windows.
    pub fn reset_areas(&mut self) {
        #[expect(clippy::iter_over_hash_type)]
        for area in self.areas.values_mut() {
            *area = Default::default();
        }
    }

    /// Obtain the previous rectangle of an area.
    pub fn area_rect(&self, id: impl Into<Id>) -> Option<Rect> {
        self.areas().get(id.into()).map(|state| state.rect())
    }

    pub(crate) fn interaction(&self) -> &InteractionState {
        self.interactions
            .get(&self.viewport_id)
            .expect("Failed to get interaction")
    }

    pub(crate) fn interaction_mut(&mut self) -> &mut InteractionState {
        self.interactions.entry(self.viewport_id).or_default()
    }

    pub(crate) fn focus(&self) -> Option<&Focus> {
        self.focus.get(&self.viewport_id)
    }

    pub(crate) fn focus_mut(&mut self) -> &mut Focus {
        self.focus.entry(self.viewport_id).or_default()
    }

    /// Check if the widget owns IME events.
    ///
    /// A widget should only consume IME events if this returns `true`. At most
    /// one widget can own IME events for each frame.

View on GitHub (pinned to 1a9d2af9ef)