Skip to content

Commit

Permalink
disable window pre creation for ios (bevyengine#5883)
Browse files Browse the repository at this point in the history
# 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.
  • Loading branch information
shuoli84 authored and james7132 committed Oct 28, 2022
1 parent 56cfa5c commit f05f151
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions crates/bevy_winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f05f151

Please sign in to comment.