bevyengine / bevyengine/bevy

One-shot exclusive system recursion regression

Open
#22,713 3 comments 0 reactions 0 assignees View on GitHub
A-ECS C-Bug I-Regression S-Needs-Design X-Contentious
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## 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 https://github.com/bevyengine/bevy/pull/22437. Recursion should be supported according to https://github.com/bevyengine/bevy/issues/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:

```rust
use bevy::prelude::*;

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

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

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

if count.0 >= 5 {
return;
}

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

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

Output on 0.17:

```text
Test 1
Test 2
Test 3
Test 4
Test 5
```

Output on 0.18:

```text
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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.