Unity 2018.2.18f1
Jobs 0.0.7-preview.5
Collections 0.0.9-preview.10
Mathematics 0.0.12-preview.19
Entities 0.0.12-preview.21
I’m using serveral persistent unity jobs for async background loading. Basically it looks like this:
private struct BackGroundWorkerJob : IJob
{
public void Execute()
{
while (Root.TestJobContainer.backGroundWorkerJobIsActive)
{
Root.TestJobContainer.backGroundWorkerJobWaitHandle.WaitOne();
// Do stuff with system.concurrent queue
}
}
}
As you can see, I invoke the job via System.Threading.EventWaitHandle. I’m using object references in here but I do not need any burst for the background loader so this doesn’t matter to me at all.
This works fine in my working project. But when I did some tests in a separate unity project, I realized this only will work (not working = no execute) if the entities package is installed. Which isn’t acutally a problem to me as I am using the entities package, but I still think this shouldn’t be, as there is no strict dependency between jobs and entities.
To be clear: The job still works fine non-persistent / when using .Complete() each frame, but as I said I need it to be persistent / frame independent.
EDIT: Ok I just realized the warning (not an error and independetly from entities package):
Internal: JobTempAlloc has allocations that are more than 4 frames old - this is not allowed and likely a leak
So I do fear now unity jobs are not allowed to be persistent at all? Which would be a real bummer to me as my project depends on background loading and accessing (readonly) nativearrays.
EDIT 2: As this thread states: [Jobs][Lags] JobTempAlloc has allocations that are more than 4 frames old they plan to fix the warning, so this is a release to me, unity jobs will support async runs. Still I wonder about the entities package dependency…