Possible Bug? Simple IJobChunk won't Burst Compile.

I’m seeing odd Burst behavior with Entities 0.14 and Unity 2020.1.

The code below is a simple example of an IJobChunk, but I can’t seem to get it to Burst compile. It won’t show up in the Burst Inspector:

using Unity.Burst;
using Unity.Jobs;
using Unity.Entities;

namespace Sample
{
    public class MySystem : SystemBase
    {
        EntityQuery query;
        protected override void OnCreate()
        {
            query = GetEntityQuery(ComponentType.ReadWrite<Foo>());
        }

        protected override void OnUpdate()
        {
            Dependency = new ProcessChunks
            {
                FooTypeHandle = GetComponentTypeHandle<Foo>()
            }.Schedule(query, Dependency);
        }

        [BurstCompile]
        struct ProcessChunks : IJobChunk
        {
            public ComponentTypeHandle<Foo> FooTypeHandle;
            public void Execute(ArchetypeChunk chunk, int chunkIndex, int entityOffset)
            {
                var testDataArray = chunk.GetNativeArray(FooTypeHandle);
                testDataArray[0] = new Foo
                {
                    value = 5
                };
            }
        }
    }
}

I feel like maybe I’m being dumb. Is there anything obvious I’m missing here, or should this IJobChunk be able to Burst compile?

And am I correct to think that if “Sample.MySystem.ProcessChunks” doesn’t appear in the Burst Inspector, that Burst isn’t compiling it?

Sincere thanks for any help.

For what it’s worth, if I turn “ProcessChunks” into an IJob, it will Burst compile (it appears in the Burst Inspector):

using Unity.Burst;
using Unity.Jobs;
using Unity.Entities;

namespace Sample
{
    public class MySystem : SystemBase
    {
        protected override void OnUpdate()
        {
            Dependency = new ProcessChunks
            {
                FooTypeHandle = GetComponentTypeHandle<Foo>()
            }.Schedule(Dependency);
        }

        [BurstCompile]
        struct ProcessChunks : IJob
        {
            public ComponentTypeHandle<Foo> FooTypeHandle;

            public void Execute()
            {
             
            }
        }
    }
}

Something else of note: If I scroll through the list of Bursted jobs in the Burst Inspector, none of them seem to be IJobChunks.

There are only IJobs, IJobParallelFors, and IJobBurstSchedulables present, for the most part.

Maybe Unity just doesn’t use IJobChunk internally? I can’t check atm.

They do not show correctly with Burst 1.3.2 but do with 1.3.7 (not sure when it started working again). However, this is only the inspector. If you checked the Profiler Timeline you would see that IJobChunk jobs would be using Burst in both versions.

Thanks!

I actually didn’t know that you could tell if a job is Bursted using the profiler. I’ve probably just never noticed it before. Is it listed with the job’s name, as part of the GUI text that represents the job?

The name is appended with “(Burst)” as seen in this screenshot:

2 Likes