Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug ObjectDisposedException: The Unity.Entities.EntityManager has been deallocated

Discussion in 'Entity Component System' started by hippocoder, May 21, 2022.

  1. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Code (CSharp):
    1. ObjectDisposedException: The Unity.Entities.EntityManager has been deallocated, it is not allowed to access it
    2. Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.CheckWriteAndThrowNoEarlyOut (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle handle) (at <ae72fc958ab44fdbb61b9d8c36cf141e>:0)
    3. Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.CheckWriteAndThrow (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle handle) (at <ae72fc958ab44fdbb61b9d8c36cf141e>:0)
    4. Unity.Entities.EntityManager.GetCheckedEntityDataAccess () (at Library/PackageCache/com.unity.entities@0.50.1-preview.2/Unity.Entities/EntityManager.cs:88)
    5. 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)
    6. 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:
    upload_2022-5-21_13-29-39.png
    (Crashy initial load when play)

    upload_2022-5-21_13-30-15.png
    (Works again after reloading main scene)
     
    soundeosdev likes this.
  2. nanaktaev

    nanaktaev

    Joined:
    May 21, 2022
    Posts:
    10
    I have the same issue. Did you figure out the solution?
     
  3. flashkoshnik

    flashkoshnik

    Joined:
    Jan 4, 2019
    Posts:
    1
    Same issue. Unity DOTS 1.0 with 2022.2.14
     
  4. DeathPro

    DeathPro

    Joined:
    Jul 28, 2018
    Posts:
    69
    Similar issue. I mentioned about this on here
     
  5. inSight01

    inSight01

    Joined:
    Apr 18, 2017
    Posts:
    86
    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.
     
    soundeosdev and Pilltech101 like this.
  6. null-fun

    null-fun

    Joined:
    Jul 1, 2017
    Posts:
    5
    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
     
    Eristen and lclemens like this.
  7. lclemens

    lclemens

    Joined:
    Feb 15, 2020
    Posts:
    714
    Yeah I'm getting these errors all over the place. I know it has something to do with the entity hierarchy. 2022.3.4.
     
  8. inSight01

    inSight01

    Joined:
    Apr 18, 2017
    Posts:
    86
    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.
     
  9. diesoftgames

    diesoftgames

    Joined:
    Nov 27, 2018
    Posts:
    114
    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...
     
  10. SteenPetersen

    SteenPetersen

    Joined:
    Mar 13, 2016
    Posts:
    79
    This happened to me as well, trying to debug looking at an entity I then left play and it started.
     
  11. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,626