You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Entity with Marker component gets queued for despawning.
Its observer runs and queues the spawning of a new entity.
End result is the entity with Marker being despawned, and a new empty entity being spawned.
App continues to run.
What actually happened?
thread 'main' panicked at F:\packages\cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_ecs-0.14.0\src\entity\mod.rs:582:9:
flush() needs to be called before this operation is legal
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Encountered a panic when applying buffers for system `flush_panic_repro::update`!
Encountered a panic in system `bevy_app::main_schedule::Main::run_main`!
error: process didn't exit successfully: `target\debug\flush_panic_repro.exe` (exit code: 101)
Additional information
#14300 runs into the same panic, but involves component hooks, MapEntities, and DynamicScene. I don't know enough about Bevy's internals to know if these are ultimately the same bug, or just coincidentally panic in the same spot.
If just the Marker component is removed without despawning its entity, the observer still runs (as expected) but there is no panic:
fnupdate(query:Query<Entity,With<Marker>>,mutcommands:Commands){for entity in&query {
commands.entity(entity).remove::<Marker>();// Does NOT panic.}}// Rest of code is unchanged.
Here's what seems like the most relevant part of the panic backtrace:
2: bevy_ecs::entity::Entities::verify_flushed
at F:\packages\cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_ecs-0.14.0\src\entity\mod.rs:582
3: bevy_ecs::entity::Entities::free
at F:\packages\cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_ecs-0.14.0\src\entity\mod.rs:680
4: bevy_ecs::world::entity_ref::EntityWorldMut::despawn
at F:\packages\cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_ecs-0.14.0\src\world\entity_ref.rs:1235
5: bevy_ecs::world::World::despawn
at F:\packages\cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_ecs-0.14.0\src\world\mod.rs:1105
6: bevy_ecs::system::commands::despawn
at F:\packages\cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_ecs-0.14.0\src\system\commands\mod.rs:1241
The text was updated successfully, but these errors were encountered:
…#15398)
# Objective
Fixes#14467
Observers and component lifecycle hooks are allowed to perform
operations that subsequently require `Entities` to be flushed, such as
reserving a new entity. If this occurs during an `on_remove` hook or an
`OnRemove` event trigger during an `EntityWorldMut::despawn`, a panic
will occur.
## Solution
Call `world.flush_entities()` after running `on_remove` hooks/observers
during `despawn`
## Testing
Added a new test that fails before the fix and succeeds afterward.
Bevy version
0.14.0
What you did
What went wrong
What were you expecting?
Marker
component gets queued for despawning.Marker
being despawned, and a new empty entity being spawned.What actually happened?
Additional information
#14300 runs into the same panic, but involves component hooks,
MapEntities
, andDynamicScene
. I don't know enough about Bevy's internals to know if these are ultimately the same bug, or just coincidentally panic in the same spot.If just the
Marker
component is removed without despawning its entity, the observer still runs (as expected) but there is no panic:Here's what seems like the most relevant part of the panic backtrace:
The text was updated successfully, but these errors were encountered: