diff --git a/crates/bevy_winit/src/winit_windows.rs b/crates/bevy_winit/src/winit_windows.rs index 49698f9f97..cd281103e4 100644 --- a/crates/bevy_winit/src/winit_windows.rs +++ b/crates/bevy_winit/src/winit_windows.rs @@ -110,14 +110,16 @@ impl WinitWindows { } }; + // It's crucial to avoid setting the window's final visibility here; + // as explained above, the window must be invisible until the AccessKit + // adapter is created. winit_window_attributes = winit_window_attributes .with_window_level(convert_window_level(window.window_level)) .with_theme(window.window_theme.map(convert_window_theme)) .with_resizable(window.resizable) .with_enabled_buttons(convert_enabled_buttons(window.enabled_buttons)) .with_decorations(window.decorations) - .with_transparent(window.transparent) - .with_visible(window.visible); + .with_transparent(window.transparent); #[cfg(target_os = "windows")] { @@ -284,6 +286,10 @@ impl WinitWindows { handlers, ); + // Now that the AccessKit adapter is created, it's safe to show + // the window. + winit_window.set_visible(window.visible); + // Do not set the grab mode on window creation if it's none. It can fail on mobile. if window.cursor_options.grab_mode != CursorGrabMode::None { let _ = attempt_grab(&winit_window, window.cursor_options.grab_mode);