ObjectDisposedException: The Unity.Entities.EntityManager has been deallocated

ObjectDisposedException: The Unity.Entities.EntityManager has been deallocated, it is not allowed to access it
Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.CheckWriteAndThrowNoEarlyOut (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle handle) (at <ae72fc958ab44fdbb61b9d8c36cf141e>:0)
Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.CheckWriteAndThrow (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle handle) (at <ae72fc958ab44fdbb61b9d8c36cf141e>:0)
Unity.Entities.EntityManager.GetCheckedEntityDataAccess () (at Library/PackageCache/com.unity.entities@0.50.1-preview.2/Unity.Entities/EntityManager.cs:88)
Unity.Entities.EntityManager.HasComponent[T] (Unity.Entities.Entity entity) (at Library/PackageCache/com.unity.entities@0.50.1-preview.2/Unity.Entities/EntityManager.cs:2850)
Unity.Physics.Authoring.PhysicsStepAuthoring.OnValidate () (at Library/PackageCache/com.unity.physics@0.50.0-preview.43/Unity.Physics.Hybrid/Components/PhysicsStepAuthoring.cs:106)

The error has been thrown since I started working with DOTS/Entities again a few weeks ago. It happens only on each new Editor session, but it happens every time without fail. What happens is that the editor loads the last loaded scene however the last loaded scene has subscenes in it. Looking at the Hierarchy, I can see something is amiss on the first run as the enabled checkbox is missing to enable or disable the subscenes.

Pressing play at this point will crash with the above error.

To fix it, I simply manually load the original scene again, and all is well, tickboxes there for subscenes etc and play works fine until the time when I will close the editor and load it again.

I suspect it’s just an 0.50x + 2020 bug that is known and going to be fixed, but am reporting it here on the off-chance that someone may have missed it, somehow.

Comparison images for context:
8145266--1057739--upload_2022-5-21_13-29-39.png
(Crashy initial load when play)

8145266--1057742--upload_2022-5-21_13-30-15.png
(Works again after reloading main scene)

1 Like

I have the same issue. Did you figure out the solution?

Same issue. Unity DOTS 1.0 with 2022.2.14

Similar issue. I mentioned about this on here

Same issue here. A little disappointing. For a production ready asset, it seems a lot less stable than Entities 0.51. Hope they get it sorted out soon.

2 Likes

In my scenario, Unity 2022.3.2f1, Entities 1.0.11
The problem seems to be triggered by the entity hierarchy
if you pick any item in the hierarchy and quit the playmode
the error would occur
it seems the unity entity hierarchy is somehow hooked with a runtime entity manager

2 Likes

Yeah I’m getting these errors all over the place. I know it has something to do with the entity hierarchy. 2022.3.4.

From my experience, it was due to trying to create my own ConvertToEntity script. Although it works, it throws this error. I couldn’t use subscenes as I wasn’t using Unity.Graphics so anything I threw into a subscene would break.

I’m giving up on Unity ECS for now. Looking into other alternatives like Arch. May not be as fast but seems a lot more flexible and user friendly.

Ahhh nice catch, I think this was the cause of this for me as well. Is there a solution for this aside from closing and re-opening Unity? I tend to look at the component data on my entities fairly often when debugging…

This happened to me as well, trying to debug looking at an entity I then left play and it started.

I’ve had a workaround in my library for this for a long time