From cfca7ebd6d952545771b5985de867a6a20772ed8 Mon Sep 17 00:00:00 2001 From: Lucas Meurer Date: Thu, 9 Oct 2025 11:44:10 +0200 Subject: [PATCH] Fix black flash on start in glow eframe backend (#7616) Before: https://github.com/user-attachments/assets/b31b7a4f-a5f7-45af-bfe0-4c8e174e209f After: https://github.com/user-attachments/assets/47544987-ca81-4efb-b778-5ca59b7fc0ac I think to make things even nicer we could also try calling request_discard when a window is shown --- crates/eframe/src/native/glow_integration.rs | 6 ++++++ crates/egui/src/memory/mod.rs | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/eframe/src/native/glow_integration.rs b/crates/eframe/src/native/glow_integration.rs index a087c9fa..4a3bee46 100644 --- a/crates/eframe/src/native/glow_integration.rs +++ b/crates/eframe/src/native/glow_integration.rs @@ -563,6 +563,12 @@ impl GlowWinitRunning<'_> { (raw_input, viewport_ui_cb) }; + // HACK: In order to get the right clear_color, the system theme needs to be set, which + // usually only happens in the `update` call. So we call Options::begin_pass early + // to set the right theme. Without this there would be a black flash on the first frame. + self.integration + .egui_ctx + .options_mut(|opt| opt.begin_pass(&raw_input)); let clear_color = self .app .clear_color(&self.integration.egui_ctx.style().visuals); diff --git a/crates/egui/src/memory/mod.rs b/crates/egui/src/memory/mod.rs index cab041bf..ddc5a9ff 100644 --- a/crates/egui/src/memory/mod.rs +++ b/crates/egui/src/memory/mod.rs @@ -318,7 +318,9 @@ impl Default for Options { } impl Options { - pub(crate) fn begin_pass(&mut self, new_raw_input: &RawInput) { + // Needs to be pub because we need to set the system_theme early in the eframe glow renderer. + #[doc(hidden)] + pub fn begin_pass(&mut self, new_raw_input: &RawInput) { self.system_theme = new_raw_input.system_theme; }