disable window pre creation for ios (#5883)

# Objective

Fixes #5882 

## Solution

Per https://github.com/rust-windowing/winit/issues/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.
This commit is contained in:
shuo 2022-09-06 15:06:17 +00:00
parent 28c16b9713
commit 6b889774cb

View File

@ -48,13 +48,15 @@ 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.
#[cfg(not(target_os = "android"))]
// 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);