Skip to content

Commit 6b88977

Browse files
committed
disable window pre creation for ios (bevyengine#5883)
# Objective Fixes bevyengine#5882 ## Solution Per rust-windowing/winit#1705, the root cause is "UIWindow should be created inside UIApplicationMain". Currently, there are two places to create UIWindow, one is Plugin's build function, which is not inside UIApplicationMain. Just comment it out, and it works.
1 parent 28c16b9 commit 6b88977

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

crates/bevy_winit/src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,15 @@ impl Plugin for WinitPlugin {
4848
#[cfg(target_arch = "wasm32")]
4949
app.add_plugin(web_resize::CanvasParentResizePlugin);
5050
let event_loop = EventLoop::new();
51-
#[cfg(not(target_os = "android"))]
51+
#[cfg(not(any(target_os = "android", target_os = "ios", target_os = "macos")))]
5252
let mut create_window_reader = WinitCreateWindowReader::default();
53-
#[cfg(target_os = "android")]
53+
#[cfg(any(target_os = "android", target_os = "ios", target_os = "macos"))]
5454
let create_window_reader = WinitCreateWindowReader::default();
5555
// Note that we create a window here "early" because WASM/WebGL requires the window to exist prior to initializing
5656
// the renderer.
57-
#[cfg(not(target_os = "android"))]
57+
// And for ios and macos, we should not create window early, all ui related code should be executed inside
58+
// UIApplicationMain/NSApplicationMain.
59+
#[cfg(not(any(target_os = "android", target_os = "ios", target_os = "macos")))]
5860
handle_create_window_events(&mut app.world, &event_loop, &mut create_window_reader.0);
5961
app.insert_resource(create_window_reader)
6062
.insert_non_send_resource(event_loop);

0 commit comments

Comments
 (0)