emilk/egui · error

run_ui should only be called with AppKind::Ui or AppKind::Ui

Error message

run_ui should only be called with AppKind::Ui or AppKind::UiState

What it means

Error "run_ui should only be called with AppKind::Ui or AppKind::UiState" thrown in emilk/egui.

Source

Thrown at crates/egui_kittest/src/app_kind.rs:67

        &mut self,
        ui: &mut egui::Ui,
        state: &mut State,
        sizing_pass: bool,
    ) -> egui::Response {
        let mut builder = egui::UiBuilder::new();
        if sizing_pass {
            builder.sizing_pass = true;
        }
        ui.scope_builder(builder, |ui| {
            Frame::central_panel(ui.style())
                // Only set outer margin, so we show no frame for tests with only free-floating windows/popups:
                .outer_margin(8.0)
                .inner_margin(0.0)
                .show(ui, |ui| match self {
                    AppKind::Ui(f) => f(ui),
                    AppKind::UiState(f) => f(ui, state),
                    #[cfg(feature = "eframe")]
                    AppKind::Eframe(_) => unreachable!(
                        "run_ui should only be called with AppKind::Ui or AppKind::UiState"
                    ),
                });
        })
        .response
    }
}

View on GitHub (pinned to b9a0723d88)

Solutions

  1. Call run_ui only on a Harness created with AppKind::Ui or AppKind::UiState; for other app kinds use the appropriate run method.

Example fix

let mut harness = Harness::new_ui(|ui| { ui.label("hi"); }); harness.run_ui(|ctx| {});

When it happens

Trigger: Thrown at crates/egui_kittest/src/app_kind.rs:67 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/828e2ea2e63a83c8. Report an issue: GitHub.