diff --git a/crates/bevy_ecs/src/system/system_piping.rs b/crates/bevy_ecs/src/system/system_piping.rs index 4f4a192ff535dd..c9be4096c75b13 100644 --- a/crates/bevy_ecs/src/system/system_piping.rs +++ b/crates/bevy_ecs/src/system/system_piping.rs @@ -202,7 +202,7 @@ pub mod adapter { /// // Building a new schedule/app... /// # use bevy_ecs::schedule::SystemStage; /// # let mut sched = Schedule::default(); sched - /// # .add_stage(CoreStage::Update, SystemStage::single_threaded()) + /// # .add_stage(CoreStage::Update, SystemStage::parallel()) /// .add_system_to_stage( /// CoreStage::Update, /// // Panic if the load system returns an error. @@ -246,7 +246,7 @@ pub mod adapter { /// // Building a new schedule/app... /// # use bevy_ecs::schedule::SystemStage; /// # let mut sched = Schedule::default(); sched - /// # .add_stage(CoreStage::Update, SystemStage::single_threaded()) + /// # .add_stage(CoreStage::Update, SystemStage::parallel()) /// .add_system_to_stage( /// CoreStage::Update, /// // If the system fails, just move on and try again next frame. diff --git a/crates/bevy_tasks/src/task_pool.rs b/crates/bevy_tasks/src/task_pool.rs index d2f5c05cbee957..39308c2bfd7bc4 100644 --- a/crates/bevy_tasks/src/task_pool.rs +++ b/crates/bevy_tasks/src/task_pool.rs @@ -118,14 +118,21 @@ impl TaskPool { thread_builder .spawn(move || { TaskPool::LOCAL_EXECUTOR.with(|local_executor| { - let tick_forever = async move { - loop { - local_executor.tick().await; + loop { + let res = std::panic::catch_unwind(|| { + let tick_forever = async move { + loop { + local_executor.tick().await; + } + }; + future::block_on(ex.run(tick_forever.or(shutdown_rx.recv()))) + }); + if let Ok(value) = res { + // Use unwrap_err because we expect a Closed error + value.unwrap_err(); + break; } - }; - let shutdown_future = ex.run(tick_forever.or(shutdown_rx.recv())); - // Use unwrap_err because we expect a Closed error - future::block_on(shutdown_future).unwrap_err(); + } }); }) .expect("Failed to spawn thread.") diff --git a/crates/bevy_time/src/time.rs b/crates/bevy_time/src/time.rs index 89ef1c11a31fd2..111ba6f74574d0 100644 --- a/crates/bevy_time/src/time.rs +++ b/crates/bevy_time/src/time.rs @@ -120,7 +120,7 @@ impl Time { /// world.insert_resource(time); /// world.insert_resource(Health { health_value: 0.2 }); /// - /// let mut update_stage = SystemStage::single_threaded(); + /// let mut update_stage = SystemStage::parallel(); /// update_stage.add_system(health_system); /// /// // Simulate that 30 ms have passed diff --git a/crates/bevy_transform/src/systems.rs b/crates/bevy_transform/src/systems.rs index 1d1c5cff45ced3..f96b56d676447e 100644 --- a/crates/bevy_transform/src/systems.rs +++ b/crates/bevy_transform/src/systems.rs @@ -318,8 +318,8 @@ mod test { let mut temp = World::new(); let mut app = App::new(); - // Adding the system in a single threaded stage. As the system will panic, this will - // only bring down the current test thread. + // FIXME: Parallel executors seem to have some odd interaction with the other + // tests in this crate. Using single_threaded until a root cause can be found. app.add_stage("single", SystemStage::single_threaded()) .add_system_to_stage("single", transform_propagate_system);