Skip to content

Running systems with both a state and a stage limitation causes systems to sometimes just be ignored. #3870

@haihala

Description

@haihala

Bevy version

0.6 off of crates.io

Operating system & version

Windows 10.

What you did

  1. Wanted to make system execution order (more) deterministic.
  2. Did this by assigning systems to stages with app.add_system_to_stage
  3. Got a white screen and the program froze on load with the warning WARN bevy_ecs::schedule::graph_utils: Chain(bevy_ecs::schedule::state::State<time::game_flow::GameState>::on_enter::{{closure}}, bevy_ecs::schedule::state::should_run_adapter<time::game_flow::GameState>) wants to be after unknown label: DriverLabel(TypeId { t: 3089577881103655877 })
  4. Added a driver system set (don't understand how this works at all) with app.add_system_set_to_stage(CoreState::First, State::<my custom state enum>::get_driver())
  5. That worked for CoreState::First
  6. Want to do the same for CoreState::Last with state run criteria, repeat 3-4 for the new stage
  7. Doesn't crash, but the run criteria never passes. Removing the run criteria the system runs every tick (want it to run on entry to a state)
  8. Switched order of ...::get_driver() commands,
  9. Systems in CoreStage::Last work, systems in CoreStage::First with run_criteria don't

What you expected to happen

Expected all systems to run

What actually happened

Systems get executed based on the order of the added stages. Only impacts systems with further run criteria and doesn't impact ones that always run in a stage.

Additional information

Snippet from the plugin that adds the state:

        .add_state(GameState::PreRound)
        .add_system_set_to_stage(CoreStage::Last, State::<GameState>::get_driver())
        .add_system_set_to_stage(CoreStage::First, State::<GameState>::get_driver())

Usage:

        .add_system_to_stage(
            CoreStage::First,
            update_clock
                .with_run_criteria(FixedTimestep::steps_per_second(constants::FPS as f64))
                .label(TimeSystemLabel::UpdateClock),
        )
        ...
        .add_system_to_stage(
            CoreStage::Last,
            text::update_timer
                .with_run_criteria(State::on_update(GameState::Combat))
                .label(UISystemLabel::Timer),
        )

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-BugAn unexpected or incorrect behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions