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

Question Dispose ECS World Crash In Android.Unity 2021.3.8

Discussion in 'Entity Component System' started by fgLxy, Nov 4, 2022.

  1. fgLxy

    fgLxy

    Joined:
    Feb 21, 2022
    Posts:
    12
    At the end of the battle, I call the dispose method of the client ECS World in the LateUpdate of MonoBehavior.
    Code (CSharp):
    1. private void LateUpdate()
    2. {
    3.     _commandInTick.Clear();
    4.     if (_destroyECSFlag)
    5.     {
    6.         var clearWorlds = new List<World>();
    7.         foreach (var world in World.All)
    8.         {
    9.             if (world.GetExistingSystem<ClientSimulationSystemGroup>() != null)
    10.             {
    11.                 clearWorlds.Add(world);
    12.             }
    13.         }
    14.         foreach (var world in clearWorlds)
    15.         {
    16.             world.Dispose();
    17.         }
    18.         _instance = null;
    19.         _destroyECSFlag = false;
    20.     }
    21. }
    Application crash when calling world.Dispose.The crash log is in the attachment tombstone_02.
    I tried to restore the stack with ida and il2cppdumper.
    Code (CSharp):
    1. ChunkDataUtility.DeallocateBuffers
    2. EntityComponentStore.Destroy(EntityComponentStore* entityComponentStore)
    3. EntityDataAccess.Dispose
    4. EntityManager.DestroyInstance
    5. WorldUnmanaged.Dispose
    6. World.Dispose
     

    Attached Files:

  2. jeremygillespiecloutier

    jeremygillespiecloutier

    Joined:
    May 28, 2020
    Posts:
    5
    Did you find a solution to this problem?
     
  3. bszandras

    bszandras

    Joined:
    Aug 13, 2021
    Posts:
    4
    I also get this exact crash, did you find a solution?
     
  4. jeremygillespiecloutier

    jeremygillespiecloutier

    Joined:
    May 28, 2020
    Posts:
    5
    No, I ended up adding entities as an embedded package and making changes to skip DeallocateBuffers when Chunk pointer is null or when there is an exception dereferencing it.
     
  5. jeremygillespiecloutier

    jeremygillespiecloutier

    Joined:
    May 28, 2020
    Posts:
    5
    Also added [Il2CppSetOption(Option.NullChecks, true)] in the method that disposes the World