-
-
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
If we try to write to an entity that doesn't exist, log it rather than completely crash the game. #2219
Conversation
…n completely crash the game.
I don't know if I completely agree with this judgement. For example if you had a game that was in production, and you were trying to write to an invalid entity, I don't know if I would want to to succeed and meerly log a message, as now my game might be in an invalid state and have unpredictable behavior. (Or crash elsewhere and make the bug harder to track down). If we wanted a solution to this, my proposal would be to extend the API on E.g. something like fn system(mut commands: Commands) {
let invalid_entity = //...
// crashes the app because the entity is invalid
commands.entity(invalid_entity).insert(MyComponent);
// does not crash the app, just silently succeeds (and logs if logging is enabled)
commands.entity_safe(invalid_entity).insert(MyComponent);
} |
Seems a good idea, but not |
Yea, haha I don't want to use |
In general I agree that this shouldn't fail in any way. However, I'm hugely lucky if I know which system caused it so I can even begin debugging the issue. And, more often than not, if I manage to identify the system, I then discover that the failure isn't at all deterministic, and no amount of reordering fixes it. I don't think there should be two paths. I think there should be a single functional path, and until Bevy can either guarantee that path works or give me actionable advice that I can trace back to a system and fix a known problem, then it shouldn't just crash. I'm effectively blocked right now because Bevy is trying to write to entities I'm despawning when my game is reset. It's nothing wild and revolutionary, and certainly nothing that should reset the game by dumping me back to my command prompt. :) |
I agree there could be better messages here.
I agree here as well, having two paths adds extra confusion.
Yes I agree that just completely crashing the app (especially in |
I'll say one more thing and let it go. Again, sorry to be cranky, but
this bug probably upsets me more than any other Bevy bug has. :) Not in
a road-ragy kind of way, but:
Bevy has a bunch of rough edges right now, and I think that those of us
doing serious work with it can all agree on that. I agree, this is
likely a system ordering issue, and I agree, there's probably something
I can do to fix it.
But until Bevy can either prevent it from happening out-right or
directly light the way to what I need to fix, crashing is about the most
user-hostile and unfun thing it can do. And I'm here to make games,
which should be fun.
If we're going to acknowledge Bevy's rough edges, then let's acknowledge
them in a way that is at least fun to work with in its incorrectness.
Now I'm just frustrated working with it because I get a few minutes into
a game, it crashes, and I have no clue how to fix it. And it crashes on
a condition that would not have made the game run incorrectly, at least
from its perspective.
Anyway, I'm out of the discussion. :) Again, I'm not ragey, just
passionate and a bit frustrated. Bevy's gonna get a lot less fun if it
just randomly crashes on me in some way I can't fix, and nothing gets
done about it because we don't have a technically correct fix yet.
|
No worries, and thank you for bringing this issue up. <3 |
Closing this since we have #2004 to track the issue. |
Admittedly this should probably be fixed in the bowels of the ECS where I'm not smart enough to wander, but I've hit this again and again to the point where it's holding back feature development. Every single time I've hit this crash, it's been when writing to an entity that I removed--enemy I destroyed, an entity that no longer exists because I reset the game, etc. Who cares if the ECS tries to write hit points to a monster that was killed and removed entirely from the game? I don't--certainly not enough to bring down the entire world. :)
I don't know if this should log at a higher level--debug, maybe?
I hesitate to call this a fix for #1743 because again, there's probably a proper fix. But can we please stop crashing? Aside from occasional log messages, this works well for me and I've had no crashes since.
Sorry if I seem cranky--it'd just be nice to not bring things to a screeching halt if we can at all avoid it. :) Thanks.