-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Flush commands after every mutation in WorldEntityMut
#16219
base: main
Are you sure you want to change the base?
Conversation
90f42bc
to
82340bf
Compare
Yes please, I'd like a small Migration Guide note here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is pretty much what I was thinking. I assume branch prediction should hide any overhead from this since the condition should basically never be true.
I think hitting this case should issue a warning. And we might want to have a #[track_caller]
on the affected EntityWorldMut
methods so that anyone who sees the warning knows where to start looking.
Something like...
#[inline(never)]
#[cold]
fn on_entity_invalid(entity: Entity, caller: &'static Location) {
warn!("error[B<insert-error-number-here>]: {caller} tried to modify the entity {:?}, but it no longer exists. See: https://bevyengine.org/learn/errors/b<insert-error-number-here>", entity);
}
Ah, wait. Since Some of the |
|
Objective
WorldEntityMut
is used after thisWorldEntityMut
attempted to (unsuccessfully) avoid flushing commands until finished was that such commands may move or despawn the entity being referenced, invalidating the cached location.observe
onWorldEntityMut
may cause the reference to be invalidated #16212Commands
apply at unexpected times with exclusiveWorld
access #14621Solution
WorldEntityMut
to exist even when it refers to a despawned entity by allowingEntityLocation
to be marked invalidTesting
Migration Guide
FIXME: Is a note desired to let users know about the extra flushes and change in behaviour?