Crash when observing SceneInstanceReady trigger #19219
Labels
A-ECS
Entities, components, systems, and events
C-Bug
An unexpected or incorrect behavior
S-Needs-Review
Needs reviewer attention (from anyone!) to move forward
Bevy version
Bevy 0.16.0
[Optional] Relevant system information
What you did
The following code reproduces the issue:
What went wrong
Running the program above results in a crash due to missing
SceneSpawner
resource:The expected behaviour is that the program doesn't crash (and the SceneSpawner resource should be available on the observer).
Additional information
This crash was a bit annoying to narrow down as it only happens if there are multiple scenes "queued" to be spawned at once, and they all have a parent (so that the
set_scene_instance_parent_sync
tries to calladd_child
).The root cause here is that the
add_child
call will cause a command queue flush: since there are multiple scenes queued to be spawned in the samescene_spawner_system
call, previous scenes'SceneInstanceReady
observers will be triggered during thescene_spawner_system
call, which causes the crash as theresource_scope::<SceneSpawnerSystem, _>
call temporarily removes the SceneSpawner from the world.The text was updated successfully, but these errors were encountered: