Skip to content

One-shot exclusive system recursion regression #22713

@Pascualex

Description

@Pascualex

Bevy version and features

0.18.0

What you did

Upgrade to 0.18 and run my game, which contains recursions.

What went wrong

The game panicked.

Additional information

I believe this was caused by #22437. Recursion should be supported according to #18030.

It is pretty easy to work around this (at least in my case) by converting the exclusive system into a command.

A minimal repro:

use bevy::prelude::*;

fn main() {
    App::new()
        .add_plugins(MinimalPlugins)
        .init_resource::<RecursionCount>()
        .add_systems(Startup, system)
        .run();
}

#[derive(Resource, Default)]
struct RecursionCount(i32);

fn system(world: &mut World) {
    let mut count = world.resource_mut::<RecursionCount>();

    if count.0 >= 5 {
        return;
    }

    count.0 += 1;
    println!("Execution {}", count.0);

    world.run_system_cached(system).unwrap();
}

Output on 0.17:

Test 1
Test 2
Test 3
Test 4
Test 5

Output on 0.18:

Test 1
Test 2
thread 'main' (273254) panicked at src/main.rs:30:35:
called `Result::unwrap()` on an `Err` value: SystemMissing(SystemId(13v0))

I did a quick test with a non exclusive system and it didn't fail.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-BugAn unexpected or incorrect behaviorS-Needs-TriageThis issue needs to be labelled

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions