-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
thread 'main' panicked at 'Entity does not exist' #1743
Description
Bevy version
Operating system & version
Windows 10
What you did
I have a system that adds/removes unit struct components via Commands. Sometimes my game runs fine for several minutes before crashing. Others, it crashes quickly with this panic:
panic: thread 'main' panicked at 'Entity does not exist'
The full log of my run, with Bevy set to debug mode and the system ambiguity checker added, can be found here. I can't pin down an easy reproduction even in my own game--it just seems like things crash after a while and I don't know why. If I'm tracing the panic back correctly to the system in question, it isn't immediately obvious to me that it's accessing despawned entities.
I'm seeing lots of this in the log:
�[2mMar 24 10:46:27.784�[0m �[34mDEBUG�[0m bevy_ecs::system::commands: Failed to despawn non-existent entity 271v1
I'm not sure where this is happening, but this is logging on debug. I'm also not sure how to trace back from this failing command invocation, to whatever system originated it. Obviously I want to do something about these failed despawns--I just don't know how.
What you expected to happen
Not panicking would be nice. as would some mechanism for tracing back from the panic to the specific command that caused it. Maybe some sort of no-op remove (I.e. "remove this component, but don't panic if the entity doesn't exist") would be nice too, though maybe I'm hitting a soundness bug somewhere that shouldn't be papered over by no-op commands. :)
What actually happened
Panics at random times. It's always when interacting with a specific subsystem of my game, but never in response to a specific action type or at a transition point.
Additional information
Happy to provide any, just let me know how to turn logging up to 11. :)