#Obscure internal safety violation

1 messages · Page 1 of 1 (latest)

thorn pier
#

I was just testing something and doing a loop


            foreach (var w in World.All)
            {
                w.EntityManager.CompleteAllTrackedJobs();
            }```

completing all world dependencies and I'm noticing a couple of these errors when it's done from editor world (presentation group).

> InvalidOperationException: The previously scheduled job AsyncLoadSceneOperation:AsyncLoadSceneJob writes to the Unity.Entities.EntityManager AsyncLoadSceneJob.Transaction.m_Manager. You must call JobHandle.Complete() on the job AsyncLoadSceneOperation:AsyncLoadSceneJob, before you can write to the Unity.Entities.EntityManager safely.

 I don't know if it hints at a problem or not, but thought someone should know
urban iris
#

No, this makes sense but the error message could probably be less cryptic.
The worlds that do scene loading in the background use ExclusiveEntityTransaction, which is basically equivalent to delegating ownership of the EntityManager to a job. While this transaction is active, the "main thread" manager cannot be used. Here, you're calling a function on all of the managers and the error you're getting indicates that you ran into one that is currently delegated to an exclusive entity transaction used by AsyncLoadSceneJob.