From c99ca79825675d66f5db5a13ef3e9b99e6c5cb56 Mon Sep 17 00:00:00 2001 From: Mike Date: Fri, 2 Feb 2024 15:41:44 -0800 Subject: [PATCH] Allow prepare_windows to run off main thread. (#11660) # Objective - Allow prepare windows to run off of the main thread on platforms that allow it. - Fixes https://github.com/bevyengine/bevy/issues/9964 on most platforms. ## Solution - Conditionally compile prepare windows for different OS's - Seems like it's only the call to `create_surface` that needs to run on the main thread here. - I've only tested this on windows, but I do see prepare windows running on other threads. --- ## Changelog - Allow prepare windows to run off main thread on platforms that allow it. --- crates/bevy_render/src/view/window/mod.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/bevy_render/src/view/window/mod.rs b/crates/bevy_render/src/view/window/mod.rs index b25957dcc4310..7f0e7d2f61a76 100644 --- a/crates/bevy_render/src/view/window/mod.rs +++ b/crates/bevy_render/src/view/window/mod.rs @@ -42,7 +42,6 @@ impl Plugin for WindowRenderPlugin { render_app .init_resource::() .init_resource::() - .init_non_send_resource::() .add_systems(ExtractSchedule, extract_windows) .add_systems(Render, prepare_windows.in_set(RenderSet::ManageViews)); } @@ -238,8 +237,8 @@ impl WindowSurfaces { #[allow(clippy::too_many_arguments)] pub fn prepare_windows( // By accessing a NonSend resource, we tell the scheduler to put this system on the main thread, - // which is necessary for some OS s - _marker: NonSend, + // which is necessary for some OS's + #[cfg(any(target_os = "macos", target_os = "ios"))] _marker: Option>, mut windows: ResMut, mut window_surfaces: ResMut, render_device: Res,