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

add_startup_system_to_stage is broken #2246

Closed
msklywenn opened this issue May 24, 2021 · 3 comments
Closed

add_startup_system_to_stage is broken #2246

msklywenn opened this issue May 24, 2021 · 3 comments
Labels
A-ECS Entities, components, systems, and events C-Bug An unexpected or incorrect behavior C-Docs An addition or correction to our documentation

Comments

@msklywenn
Copy link
Contributor

msklywenn commented May 24, 2021

Bevy version

Tested 0.5.0 and main

Operating system & version

Windows 10

What you did

I tried adding a startup system to a custom stage. It panic'd.

use bevy::prelude::*;

#[derive(Debug, Hash, PartialEq, Eq, Clone, StageLabel)]
struct MyStage;

fn my_system() {
    println!("hello from my stage");
}

fn main() {
    App::build()
        .add_stage_after(CoreStage::Update, MyStage, SystemStage::single_threaded())
        .add_startup_system_to_stage(MyStage, my_system.system())
        .run();
}

What you expected to happen

my_system to be called normally.

What actually happened

$ RUST_BACKTRACE=1 cargo r
    Finished dev [unoptimized + debuginfo] target(s) in 0.36s
     Running `target\debug\stage_test.exe`
thread 'main' panicked at 'Stage 'MyStage' does not exist or is not a SystemStage', C:\Users\Daniel\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_ecs-0.5.0\src\schedule\mod.rs:150:17
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53\/library\std\src\panicking.rs:493
   1: std::panicking::begin_panic_fmt
             at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53\/library\std\src\panicking.rs:435
   2: bevy_ecs::schedule::{{impl}}::add_system_to_stage::{{closure}}<prout::MyStage,bevy_ecs::system::into_system::FunctionSystem<tuple<>, tuple<>, tuple<>, tuple<>, fn()>>
             at C:\Users\Daniel\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_ecs-0.5.0\src\schedule\mod.rs:150
   3: core::option::Option<mut bevy_ecs::schedule::stage::SystemStage*>::unwrap_or_else<mut bevy_ecs::schedule::stage::SystemStage*,closure-0>
             at C:\Users\Daniel\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\option.rs:427
   4: bevy_ecs::schedule::Schedule::add_system_to_stage<prout::MyStage,bevy_ecs::system::into_system::FunctionSystem<tuple<>, tuple<>, tuple<>, tuple<>, fn()>>
             at C:\Users\Daniel\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_ecs-0.5.0\src\schedule\mod.rs:147
   5: bevy_app::app_builder::{{impl}}::add_startup_system_to_stage::{{closure}}<prout::MyStage,bevy_ecs::system::into_system::FunctionSystem<tuple<>, tuple<>, tuple<>, tuple<>, fn()>>
             at C:\Users\Daniel\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_app-0.5.0\src\app_builder.rs:176
   6: bevy_ecs::schedule::Schedule::stage<bevy_ecs::schedule::Schedule,closure-0,bevy_app::CoreStage>
             at C:\Users\Daniel\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_ecs-0.5.0\src\schedule\mod.rs:177
   7: bevy_app::app_builder::AppBuilder::add_startup_system_to_stage<prout::MyStage,bevy_ecs::system::into_system::FunctionSystem<tuple<>, tuple<>, tuple<>, tuple<>, fn()>>
             at C:\Users\Daniel\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_app-0.5.0\src\app_builder.rs:173
   8: stage_test::main
             at .\src\main.rs:20
   9: core::ops::function::FnOnce::call_once<fn(),tuple<>>
             at C:\Users\Daniel\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\ops\function.rs:227
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Additional information

add_system_to_stage works fine.

@msklywenn msklywenn added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels May 24, 2021
@mockersf
Copy link
Member

Could you try with add_startup_stage_after instead of add_stage_after? You will also have to use one of the StartupStage instead of CoreStage::Update.

@msklywenn
Copy link
Contributor Author

Oh wow, I had no idea there was a StartupStage too. This is super surprising and so this is issue probably isn't one.

Shouldn't the panic message be "Stage 'MyStage' does not exist or is not a StartupStage" ?

@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events C-Docs An addition or correction to our documentation and removed S-Needs-Triage This issue needs to be labelled labels May 24, 2021
@alice-i-cecile
Copy link
Member

Very related to #2229.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Bug An unexpected or incorrect behavior C-Docs An addition or correction to our documentation
Projects
None yet
3 participants