From 4dc964ab4bf0d43d9748e9e8afda2e68236d150e Mon Sep 17 00:00:00 2001 From: zeozeozeo <108888572+zeozeozeo@users.noreply.github.com> Date: Mon, 27 Nov 2023 14:35:37 +0500 Subject: [PATCH] eframe: Fix window flashing white on launch (#3631) This is a bug that can occur on Windows, previously it was fixed by only showing the window after the first frame was rendered, but the bug appeared again with egui 0.24.0. This commit fixes this bug by making the window invisible on startup. ## Before ![window-flash](https://github.com/emilk/egui/assets/108888572/31a675af-8c30-46b1-a1af-653491cf67da) ## After ![no-window-flash](https://github.com/emilk/egui/assets/108888572/e7bfc429-033e-4842-8591-b9229143a60b) Closes https://github.com/emilk/egui/issues/3625. --- crates/eframe/src/native/glow_integration.rs | 3 ++- crates/eframe/src/native/wgpu_integration.rs | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/eframe/src/native/glow_integration.rs b/crates/eframe/src/native/glow_integration.rs index bd9bdac2d8b..9a820bec770 100644 --- a/crates/eframe/src/native/glow_integration.rs +++ b/crates/eframe/src/native/glow_integration.rs @@ -154,7 +154,8 @@ impl GlowWinitApp { event_loop, native_options, window_settings, - ); + ) + .with_visible(false); // Start hidden until we render the first frame to fix white flash on startup (https://github.com/emilk/egui/pull/3631) let mut glutin_window_context = unsafe { GlutinWindowContext::new(egui_ctx, winit_window_builder, native_options, event_loop)? diff --git a/crates/eframe/src/native/wgpu_integration.rs b/crates/eframe/src/native/wgpu_integration.rs index 995014a6168..07e36f96b50 100644 --- a/crates/eframe/src/native/wgpu_integration.rs +++ b/crates/eframe/src/native/wgpu_integration.rs @@ -837,7 +837,9 @@ fn create_window( event_loop, native_options, window_settings, - ); + ) + .with_visible(false); // Start hidden until we render the first frame to fix white flash on startup (https://github.com/emilk/egui/pull/3631) + let window = { crate::profile_scope!("WindowBuilder::build"); create_winit_window_builder(egui_ctx, event_loop, viewport_builder.clone())