emilk/egui · error

Failed to find current viewport in egui RawInput. This is…

Error message

Failed to find current viewport in egui RawInput. This is the fault of the egui backend

What it means

Error "Failed to find current viewport in egui RawInput. This is the fault of the egui backend" thrown in emilk/egui.

Solutions

  1. The backend must include the current viewport in RawInput::viewports: if you wrote a custom backend, populate raw_input.viewports with the active ViewportId.
  2. If using an official backend, this is a backend bug: update egui/eframe and report if reproducible.

Example fix

raw_input.viewports.insert(viewport_id, ViewportInfo { parent: None, ..Default::default() });

When it happens

Trigger: Thrown at crates/egui/src/data/input/raw_input.rs:117 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of emilk/egui@b9a0723d88 (2026-08-19). Data as JSON: /api/errors/5a04ec771c178059. Report an issue: GitHub.

Appendix: source

Thrown at crates/egui/src/data/input/raw_input.rs:117

            screen_rect: None,
            max_texture_side: None,
            time: None,
            predicted_dt: 1.0 / 60.0,
            events: vec![],
            hovered_files: Default::default(),
            dropped_files: Default::default(),
            focused: true, // integrations opt into global focus tracking
            system_theme: None,
            safe_area_insets: Default::default(),
        }
    }
}

impl RawInput {
    /// Info about the active viewport
    #[inline]
    pub fn viewport(&self) -> &ViewportInfo {
        self.viewports.get(&self.viewport_id).expect("Failed to find current viewport in egui RawInput. This is the fault of the egui backend")
    }

    /// Helper: move volatile (deltas and events), clone the rest.
    ///
    /// * [`Self::hovered_files`] is cloned.
    /// * [`Self::dropped_files`] is moved.
    pub fn take(&mut self) -> Self {
        Self {
            viewport_id: self.viewport_id,
            viewports: self
                .viewports
                .iter_mut()
                .map(|(id, info)| (*id, info.take()))
                .collect(),
            screen_rect: self.screen_rect.take(),
            safe_area_insets: self.safe_area_insets.take(),
            max_texture_side: self.max_texture_side.take(),
            time: self.time,

View on GitHub (pinned to b9a0723d88)