Hello everyone, I’m currently struggling with ECBSystem. According to the documentation I’ve read, structural changes force the main thread to complete all scheduled jobs. However, with ECB systems, I see that Unity requires registering the dependency of the job with the ECB system.
I looked at Unity’s source code and saw that the OnUpdate of the ECB system is implemented roughly like this:
CompleteDependency();
m_ProducerHandle.Complete();
m_ProducerHandle = new JobHandle();
int length = PendingBuffers.Length;
for (int i = 0; i < length; ++i)
{
var buffer = PendingBuffers[i];
buffer.Playback(EntityManager);
}
What I don’t understand is whether the job completion step before playback is redundant, because when playback happens, all scheduled jobs should already have been completed.
In my mind, the flow would look something like this instead:
int length = PendingBuffers.Length;
for (int i = 0; i < length; ++i)
{
var buffer = PendingBuffers[i];
buffer.Playback(EntityManager);
// Complete all jobs scheduled before Add/Remove/Create/...
}
Am I misunderstanding something here? 