From a0e93389a0e78ecdf827932f97006cf781595f17 Mon Sep 17 00:00:00 2001 From: shuo Date: Mon, 5 Sep 2022 18:56:44 +0800 Subject: [PATCH 1/3] disable window pre creation for ios --- crates/bevy_winit/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_winit/src/lib.rs b/crates/bevy_winit/src/lib.rs index b48dd441146d7..2a13504275767 100644 --- a/crates/bevy_winit/src/lib.rs +++ b/crates/bevy_winit/src/lib.rs @@ -54,7 +54,7 @@ impl Plugin for WinitPlugin { let create_window_reader = WinitCreateWindowReader::default(); // Note that we create a window here "early" because WASM/WebGL requires the window to exist prior to initializing // the renderer. - #[cfg(not(target_os = "android"))] + #[cfg(not(any(target_os = "android", target_os = "ios")))] handle_create_window_events(&mut app.world, &event_loop, &mut create_window_reader.0); app.insert_resource(create_window_reader) .insert_non_send_resource(event_loop); From e41721fb470451db605b55001bc3cd2602987622 Mon Sep 17 00:00:00 2001 From: shuo Date: Tue, 6 Sep 2022 07:34:26 +0800 Subject: [PATCH 2/3] also exclude window precreation on macos, add comment on why exclude --- crates/bevy_winit/src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/bevy_winit/src/lib.rs b/crates/bevy_winit/src/lib.rs index 2a13504275767..143d293a35484 100644 --- a/crates/bevy_winit/src/lib.rs +++ b/crates/bevy_winit/src/lib.rs @@ -54,7 +54,9 @@ impl Plugin for WinitPlugin { let create_window_reader = WinitCreateWindowReader::default(); // Note that we create a window here "early" because WASM/WebGL requires the window to exist prior to initializing // the renderer. - #[cfg(not(any(target_os = "android", target_os = "ios")))] + // And for ios and macos, we should not create window early, all ui related code should be executed inside + // UIApplicationMain/NSApplicationMain. + #[cfg(not(any(target_os = "android", target_os = "ios", target_os = "macos")))] handle_create_window_events(&mut app.world, &event_loop, &mut create_window_reader.0); app.insert_resource(create_window_reader) .insert_non_send_resource(event_loop); From 79fae7a5600cd21bc7bef9d1ba61c18ef217dd52 Mon Sep 17 00:00:00 2001 From: shuo Date: Tue, 6 Sep 2022 08:01:29 +0800 Subject: [PATCH 3/3] fix warning --- crates/bevy_winit/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/bevy_winit/src/lib.rs b/crates/bevy_winit/src/lib.rs index 143d293a35484..21216674e7fe7 100644 --- a/crates/bevy_winit/src/lib.rs +++ b/crates/bevy_winit/src/lib.rs @@ -48,9 +48,9 @@ impl Plugin for WinitPlugin { #[cfg(target_arch = "wasm32")] app.add_plugin(web_resize::CanvasParentResizePlugin); let event_loop = EventLoop::new(); - #[cfg(not(target_os = "android"))] + #[cfg(not(any(target_os = "android", target_os = "ios", target_os = "macos")))] let mut create_window_reader = WinitCreateWindowReader::default(); - #[cfg(target_os = "android")] + #[cfg(any(target_os = "android", target_os = "ios", target_os = "macos"))] let create_window_reader = WinitCreateWindowReader::default(); // Note that we create a window here "early" because WASM/WebGL requires the window to exist prior to initializing // the renderer.