Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash in 0.15 due to system ordering ambiguities #571

Closed
spectria-limina opened this issue Dec 2, 2024 · 2 comments · Fixed by #577
Closed

Crash in 0.15 due to system ordering ambiguities #571

spectria-limina opened this issue Dec 2, 2024 · 2 comments · Fixed by #577
Labels
A-Scheduling Relates to scheduling or system sets P-Crash A sudden unexpected crash

Comments

@spectria-limina
Copy link
Contributor

Using the lastest main and:

            PhysicsPlugins::default()
                .build()
                .disable::<IntegratorPlugin>()
                .disable::<SolverPlugin>()
                .disable::<SleepingPlugin>(),

I get the following crash:

   0: bevy_ecs::schedule::schedule::schedule
           with name=PhysicsSchedule
             at /home/alercah/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.15.0/src/schedule/schedule.rs:379
   1: bevy_ecs::system::function_system::system
           with name="avian2d::schedule::run_physics_schedule"
             at /home/alercah/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.15.0/src/system/function_system.rs:65
thread 'main' panicked at /home/alercah/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.15.0/src/schedule/schedule.rs:383:33:
Error when initializing schedule PhysicsSchedule: Systems with conflicting access have indeterminate run order.
25 pairs of systems with conflicting data access have indeterminate execution order. Consider adding `before`, `after`, or `ambiguous_with` relationships between these:
 -- update_aabb_intervals (in sets BroadPhase, UpdateStructures) and run_substep_schedule (in set Substep)
    conflict on: bevy_ecs::world::World
 -- run_substep_schedule (in set Substep) and solve_swept_ccd (in sets PostSubstep, SweptCcdSet)
    conflict on: bevy_ecs::world::World
 -- run_substep_schedule (in set Substep) and add_new_aabb_intervals (in sets BroadPhase, UpdateStructures)
    conflict on: bevy_ecs::world::World
 -- run_substep_schedule (in set Substep) and collect_collision_pairs (in sets BroadPhase, CollectCollisions)
    conflict on: bevy_ecs::world::World
 -- run_substep_schedule (in set Substep) and propagate_collider_transforms (in sets First, NarrowPhase)
    conflict on: bevy_ecs::world::World
 -- run_substep_schedule (in set Substep) and update_child_collider_position (in sets First, NarrowPhase)
    conflict on: bevy_ecs::world::World
 -- run_substep_schedule (in set Substep) and reset_collision_states (in set NarrowPhase)
    conflict on: bevy_ecs::world::World
 -- run_substep_schedule (in set Substep) and run_post_process_collisions_schedule (in sets NarrowPhase, PostProcess)
    conflict on: bevy_ecs::world::World
 -- run_substep_schedule (in set Substep) and <NarrowPhasePlugin<Collider> as Plugin>::{{closure}}
    conflict on: bevy_ecs::world::World
 -- run_substep_schedule (in set Substep) and report_contacts (in set ReportContacts)
    conflict on: bevy_ecs::world::World
 -- run_substep_schedule (in set Substep) and remove_ended_collisions
    conflict on: bevy_ecs::world::World
 -- run_substep_schedule (in set Substep) and update_ray_caster_positions (in set SpatialQuery)
    conflict on: bevy_ecs::world::World
 -- run_substep_schedule (in set Substep) and update_shape_caster_positions (in set SpatialQuery)
    conflict on: bevy_ecs::world::World
 -- run_substep_schedule (in set Substep) and <SpatialQueryPlugin as Plugin>::{{closure}} (in set SpatialQuery)
    conflict on: bevy_ecs::world::World
 -- run_substep_schedule (in set Substep) and raycast (in set SpatialQuery)
    conflict on: bevy_ecs::world::World
 -- run_substep_schedule (in set Substep) and shapecast (in set SpatialQuery)
    conflict on: bevy_ecs::world::World
 -- run_substep_schedule (in set Substep) and handle_rigid_body_removals
    conflict on: bevy_ecs::world::World
 -- solve_swept_ccd (in sets PostSubstep, SweptCcdSet) and collect_collision_pairs (in sets BroadPhase, CollectCollisions)
    conflict on: ["avian2d::collision::broad_phase::AabbIntersections"]
 -- solve_swept_ccd (in sets PostSubstep, SweptCcdSet) and update_child_collider_position (in sets First, NarrowPhase)
    conflict on: ["avian2d::position::Position", "avian2d::position::Rotation"]
 -- solve_swept_ccd (in sets PostSubstep, SweptCcdSet) and run_post_process_collisions_schedule (in sets NarrowPhase, PostProcess)
    conflict on: bevy_ecs::world::World
 -- solve_swept_ccd (in sets PostSubstep, SweptCcdSet) and update_ray_caster_positions (in set SpatialQuery)
    conflict on: ["avian2d::position::Rotation"]
 -- solve_swept_ccd (in sets PostSubstep, SweptCcdSet) and update_shape_caster_positions (in set SpatialQuery)
    conflict on: ["avian2d::position::Rotation"]
 -- solve_swept_ccd (in sets PostSubstep, SweptCcdSet) and <SpatialQueryPlugin as Plugin>::{{closure}} (in set SpatialQuery)
    conflict on: ["avian2d::position::Rotation"]
 -- solve_swept_ccd (in sets PostSubstep, SweptCcdSet) and raycast (in set SpatialQuery)
    conflict on: ["avian2d::position::Rotation"]
 -- solve_swept_ccd (in sets PostSubstep, SweptCcdSet) and shapecast (in set SpatialQuery)
    conflict on: ["avian2d::position::Rotation"]

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Encountered a panic in system `avian2d::schedule::run_physics_schedule`!
Encountered a panic in system `bevy_app::main_schedule::FixedMain::run_fixed_main`!
Encountered a panic in system `bevy_time::fixed::run_fixed_main_schedule`!
Encountered a panic in system `bevy_app::main_schedule::Main::run_main`!

I can try to further minimize if need be.

@spectria-limina
Copy link
Contributor Author

Leaving all the plugins enables works.

@Jondolf Jondolf added A-Scheduling Relates to scheduling or system sets P-Crash A sudden unexpected crash labels Dec 2, 2024
@Jondolf
Copy link
Owner

Jondolf commented Dec 6, 2024

This should be fixed by #577.

Jondolf added a commit that referenced this issue Dec 6, 2024
# Objective

Fixes #571.

Currently, a lot of plugins depend on the system sets of the solver, even if they don't strictly need the solver. Most of these system sets are initialized by the `SolverPlugin`, and if you disable it, you get a crash.

We should aim to decouple system set ordering and the substepping loop scheduling from the actual solver, allowing the engine to rely on ordering guarantees while letting users freely disable and modify parts of the engine.

## Solution

Add a `SolverSchedulePlugin`, which sets up core system sets for the physics solver, and runs the substepping loop. Types related to the solver and substepping loop have been moved over from the `PhysicsSchedulePlugin`.

This isn't a perfect solution yet, and we could certainly decouple and reorganize things more, but it is a step forward.

---

## Migration Guide

System set configuration and scheduling related to the solver and substepping loop are now primarily in the new `SolverSchedulePlugin`. It is included in the `PhysicsPlugins` plugin group, so for most applications, this should not be a breaking change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Scheduling Relates to scheduling or system sets P-Crash A sudden unexpected crash
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants