emilk/egui · error

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

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.

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@8fb03c9ae9 (2026-08-19). Data as JSON: /api/errors/828e2ea2e63a83c8. Report an issue: GitHub.

Appendix: source

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

                app.logic(ui, frame);
                app.ui(ui, frame);
                None
            }
            kind_ui => Some(kind_ui.run_ui(ui, state, sizing_pass)),
        }
    }

    fn run_ui(&mut self, ui: &mut egui::Ui, state: &mut State, sizing_pass: bool) -> UiRunOutput {
        let mut builder = egui::UiBuilder::new();
        if sizing_pass {
            builder.sizing_pass = true;
        }
        let egui::InnerResponse {
            inner: ui_id,
            response,
        } = 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"
                        ),
                    }
                    ui.scope_id()
                })
                .inner
        });
        UiRunOutput { response, ui_id }
    }
}

View on GitHub (pinned to 8fb03c9ae9)