-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
Crash when disposing entities #123
Comments
From the look of it, the error occurs when accessing the previous component pool. Since you already have the source to debug, could you try a small change?
Change the message type from EntityDisposedMessage to EntityDisposingMessage , I tried to replicate what I though was occuring but couldn't make it fails :/, still this change is worth a shot (basically the subscription order is not guaranteed and maybe the component is removed from the pool before the callback to remove the entity from the EntityMap is called, I made the Disposing/Disposed message specifically for this but this subscription slipped pass me). I will keep looking into it.
edit: |
I do indeed have multiple Maps with the same key. This change does appear to have fixed it! Thanks! |
Thank you for giving all those infos, made finding the problem much easier :) |
Hi I'm trying to use DefaultEcs for an MMO emulation project. When the users client is closed a couple of network connections are disconnected. There is an entity for each of the network connections the client makes.
I've been experiencing a crash when trying to Dispose of those entities.
When a network connection is closed and it's not a connection associated with a player in the world a NetworkClientDisconnected component is added to the entity and you can see in the following log that it gets picked up by the NetworkClientDisconnectedCleanupSystem, if it's associated with a player in the world it will get a PlayerDisconnectedComponent and get picked up by the PlayerDisconnectedCleanupSystem.
Both of these systems use an EntityCommandRecorder to do the disposing and then in PostUpdate if any commands were recorded it publishes a message to have the server add the recorder to a queue to be processed when all systems have completed the current Update.
My original thinking was that I must be accidentally disposing the same entity twice somehow but I could not figure out where I was doing it if I was. So I ended up cloning the DefaultEcs repo and adding it as a project to my solution so that I could modify Entity.cs and have it do a Debug.WriteLine in its Dispose method to see exactly what entities are being disposed leading up to the crash and hopefully prove it wasn't my fault.
These are the Debug.WriteLines from Entity.Dispose()
This is a screenshot of the _mapping array in ComponentPool.cs at the point of the exception
It looks like this is getting corrupted somehow? I'm not really sure. Any help is greatly appreciated
The text was updated successfully, but these errors were encountered: