Showing viewports from App::logic doesn't work with deferred and can crash with immediate
Author: kalilamodowCreated Aug 29, 2026Updated Sep 10, 2026
Labelsbug
This code example prints "showing" after the right amount of time, but only actually shows the deferred viewport if the main window is not minimized. So if the main window is visible the whole time, it works great, but if the main window is minimized, the deferred viewport only shows up once the main window is un-minimized
...
struct MyApp {
name: String,
created_at: Instant,
}
const SHOW_AFTER: Duration = Duration::from_secs(5);
const LOOP_INTERVAL: Duration = Duration::from_millis(1000 / 60);
impl eframe::App for MyApp {
fn logic(&mut self, ctx: &Context, _frame: &mut Frame) {
if Instant::now().duration_since(self.created_at) >= SHOW_AFTER {
println!("showing");
ctx.show_viewport_deferred(
ViewportId("hello".into()),
ViewportBuilder::default(),
|ui, _| {
egui::CentralPanel::default().show(ui, |ui| {
ui.label("Other viewport");
});
},
);
}
ctx.request_repaint_after(LOOP_INTERVAL);
}
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut Frame) {
egui::CentralPanel::default().show(ui, |ui| {
ui.heading("My egui Application");
ui.text_edit_singleline(&mut self.name);
ui.label(format!("Hello '{}'", self.name));
});
}
}Using show_viewport_immediate has a worse issue; like before, it works if the main window is visible the whole time. But if the viewport is created while the main window is minimized, it crashes saying the egui backend is implemented incorrectly, probably because the viewport isn't painted immediately
thread 'main' (11748) panicked at C:\Users\kmdw\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\egui-0.36.1\src\context.rs:4165:17:
egui backend is implemented incorrectly - the user callback was never called
... big stacktraceWindows 11, eframe/egui 0.36.1
Source: emilk/egui