Been struggling with figuring out this crash in my saving system. The specific part that is having issues is the CopyEntitiesFrom call before the smiley.
var builder = new EntityQueryBuilder(Allocator.Temp);
builder
.WithAny<SaveTag, Prefab>()
.WithOptions(EntityQueryOptions.IncludePrefab | EntityQueryOptions.IncludePrefab);
using var saveQuery = builder.Build(originalEm);
Debug.Log($"Completing savequery dependency");
saveQuery.CompleteDependency();
Debug.Log($"Getting entity array");
using var entities = saveQuery.ToEntityArray(Allocator.Temp);
Debug.Log($"Copying entities");
entityManager.CopyEntitiesFrom(originalEm, entities);
Debug.Log($":)");
With the error:
0x00007FF9B290C0A8 (lib_burst_generated) [C:\build\output\unity\unity\Runtime\Jobs\Managed\IJobParallelFor.cs:47] Unity.Jobs.IJobParallelForExtensions.ParallelForJobStruct`1<Unity.Entities.EntityManager.RemapChunksFilteredJob>.Execute(ref Unity.Entities.EntityManager.RemapChunksFilteredJob jobData, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, ref Unity.Jobs.LowLevel.Unsafe.JobRanges ranges, int jobIndex) -> void_7435d70d723590c51e89202ae2f9be71 from UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
0x00007FF9B290B376 (lib_burst_generated) 133cdc8adea96c01df559b08afa2ef56_avx2
0x00007FF9B2982217 (lib_burst_generated) 133cdc8adea96c01df559b08afa2ef56
I haven't managed to find a 100% consistent repro, so at first I thought the issue was caused by some other job running at the same time that I wasn't completing the dependency for, but I've made sure to complete all dependencies and it still happens. I've also tried running the following code on both entity managers before calling the code above:
entityManager.ExclusiveEntityTransactionDependency.Complete();
entityManager.EndExclusiveEntityTransaction();
entityManager.CompleteAllTrackedJobs();
Is there anything I can do to get a better error or disable burst on the job?