-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Panic calling DynamicScene::write_to_world
with MapEntities
and ComponentHooks
#14300
Comments
looks related to #14465 |
Can confirm - this is almost identical to #14465. In both cases, observers or hooks are able to create pending entities which aren't getting flushed before an operation is attempted which requires a flush in advance. Still trying to figure out the best place to put the flush for this one. |
Maybe this is more of an issue of Still seems like observers are able to put the |
# Objective - Add a test case for #14300 Fixes #14300 ## Solution `SceneEntityMapper` relies on operations on `Entities` that require flushing in advance, such as `alloc` and `free`. Previously, it wasn't calling `world.flush_entities()` itself and relied on its caller having flushed beforehand. This wasn't an issue before observers and hooks were released, since entity reservation was happening at expected times. Now that hooks and observers are a thing, they can introduce a need to flush. We have a few options: * Flush after each observer/hook run * Flush between each paired observer/hook and operation that requires a flush * Flush before operations requiring it The first option for this case seemed trickier to reason about than I wanted, since it involved the `BundleInserter` and its `UnsafeWorldCell`, and the second is generally harder to track down. The third seemed the most straightforward and conventional, since we can see a flush occurring at the start of a number of `World` methods. Therefore, we're letting `SceneEntityMapper` be in charge of upholding its own invariants and calling `flush_entities` when it's created. ## Testing Added a new test case modeled after #14300
Bevy version
0.14.0
What you did
DynamicScene::write_to_world
with two components:MapEntities
world.commands().spawn_empty()
inComponentHooks::on_add
What went wrong
Panics at
bevy_ecs::entity::Entities::verify_flushed
, traced back toscene::write_to_world
Additional information
I dont know enough about the ecs internals to understand whats happening, possibly commands from the DeferredWorld in
ComponentHooks::on_add
are being called at an inappropriate time?Full reproducible
The text was updated successfully, but these errors were encountered: