diff --git a/crates/bevy_ecs/src/schedule/executor/simple.rs b/crates/bevy_ecs/src/schedule/executor/simple.rs index 002ba532ad..6c1b7437ac 100644 --- a/crates/bevy_ecs/src/schedule/executor/simple.rs +++ b/crates/bevy_ecs/src/schedule/executor/simple.rs @@ -4,7 +4,9 @@ use fixedbitset::FixedBitSet; use std::panic::AssertUnwindSafe; use crate::{ - schedule::{BoxedCondition, ExecutorKind, SystemExecutor, SystemSchedule}, + schedule::{ + executor::is_apply_deferred, BoxedCondition, ExecutorKind, SystemExecutor, SystemSchedule, + }, world::World, }; @@ -86,6 +88,10 @@ impl SystemExecutor for SimpleExecutor { } let system = &mut schedule.systems[system_index]; + if is_apply_deferred(system) { + continue; + } + let res = std::panic::catch_unwind(AssertUnwindSafe(|| { system.run((), world); })); @@ -125,3 +131,16 @@ fn evaluate_and_fold_conditions(conditions: &mut [BoxedCondition], world: &mut W .map(|condition| condition.run((), world)) .fold(true, |acc, res| acc && res) } + +#[cfg(test)] +#[test] +fn skip_automatic_sync_points() { + // Schedules automatically insert appy_deferred systems, but these should + // not be executed as they only serve as markers and are not initialized + use crate::prelude::*; + let mut sched = Schedule::default(); + sched.set_executor_kind(ExecutorKind::Simple); + sched.add_systems((|_: Commands| (), || ()).chain()); + let mut world = World::new(); + sched.run(&mut world); +}