Burst crash on iOS at creating a IJobParallelForTransform job

After having gone through and deleted all my sprites to open the project in Unity 2020.2b12 I got it to export an xcode project on for the iOS platform. After running the game for about 20seconds and into the main menu (where I use burst compiled code) it immediately crashes with the strack trace

Unable to find internal function
‘Unity.Burst.LowLevel.BurstCompilerServices::GetOrCreateSharedMemory’ Unity.JobsLowLevel.Unsafe.JobsUtility.CreateJobReflectionDataType(Type, Object, Object, Object) UnityEngine.Jobs.TransformParallelForLoopStruct’1:Initialize() UnityEngine.Jobs.IJobParallelForTransformExtension:Schedule(ObjectMoveJob,TransformAccessArray, JobHandle)

So my understanding is that it crashes immediately when I create a Job which deals with some transforms in a for loop.

[BurstCompile]
    public struct ObjectMoveJob : IJobParallelForTransform
    {
        [ReadOnly]
        public NativeArray<ObjectMove.ObjectData> ObjectData;
        public NativeArray<ObjectMove.ObjectMoveData> ObjectMoveData;
        [ReadOnly]
        public NativeArray<float3> Waypoints;
        public float DeltaTime;
   
        public void Execute(int index, TransformAccess transform)
        {
            var moveData = ObjectMoveData[index];
            int currentWaypoint = moveData.CurrentWaypoint;
            bool reverseDirection = moveData.ReverseDirection;
            bool loop = ObjectData[index].Loop;
            float rotationCorrection = ObjectData[index].RotationCorrection;
            float speed = ObjectData[index].MoveSpeed;
            var pos = transform.position;
            var transformPosition = new float3(pos.x, pos.y, pos.z);

            if (currentWaypoint < ObjectData[index].EndWPIndex && currentWaypoint >= ObjectData[index].StartWPIndex)
            {
                var waypoint = Waypoints[currentWaypoint];
                var target = new float3(waypoint.x, waypoint.y, waypoint.z) + ObjectData[index].Offset + ObjectData[index].Shift;

                if (math.distance(target, transformPosition) < 0.1f)
                {
                    currentWaypoint = reverseDirection ? currentWaypoint - 1 : currentWaypoint + 1;
                }
                else
                {
                    var moveDirection = target - transformPosition;
                    //Never rotate up or down
                    moveDirection.y = 0;
                    var look = quaternion.LookRotation(moveDirection, new float3(0, 1, 0));
               
                    //Rotate by rotation correction. Used by surfers
                    var offset = quaternion.RotateY(math.radians(rotationCorrection));
                    var rotation = math.mul(look, offset);
                   

                    transform.position = MoveTowards(transformPosition, target, speed * DeltaTime);
                    transform.rotation = math.slerp(transform.rotation, rotation, DeltaTime * ObjectData[index].RotationSpeed);
                }
            }
            else
            {
                if (loop)
                {
                    if (currentWaypoint >= ObjectData[index].EndWPIndex)
                    {
                        currentWaypoint = ObjectData[index].StartWPIndex;
                    }
                    else if (currentWaypoint <= ObjectData[index].StartWPIndex)
                    {
                        currentWaypoint = ObjectData[index].EndWPIndex - 1;
                    }
                }
                else
                {
                    reverseDirection = !reverseDirection;
                    if (reverseDirection)
                    {
                        currentWaypoint -= 1;
                    }
                    else
                    {
                        currentWaypoint += 1;
                    }
                }
                //Log($"2  reverseDirection = {reverseDirection}  currentWaypoint = {currentWaypoint} start: {ObjectData[index].StartWPIndex} end: {ObjectData[index].EndWPIndex}");
            }

            moveData.CurrentWaypoint = currentWaypoint;
            moveData.ReverseDirection = reverseDirection;
            ObjectMoveData[index] = moveData;
        }

        private static float3 MoveTowards(
            float3 current,
            float3 target,
            float maxDistanceDelta)
        {
            float num1 = target.x - current.x;
            float num2 = target.y - current.y;
            float num3 = target.z - current.z;
            float num4 = (float) ((double) num1 * (double) num1 + (double) num2 * (double) num2 + (double) num3 * (double) num3);
            if ((double) num4 == 0.0 || (double) maxDistanceDelta >= 0.0 && (double) num4 <= (double) maxDistanceDelta * (double) maxDistanceDelta)
                return target;
            float num5 = (float) math.sqrt((double) num4);
            return new float3(current.x + num1 / num5 * maxDistanceDelta, current.y + num2 / num5 * maxDistanceDelta, current.z + num3 / num5 * maxDistanceDelta);
        }
    }

Some more info. I was using Birst 0.2.10-preview.12 and tried to update to 0.7.0-preview.17 but its the same result

Current released Burst version is 1.4.1 - you may want to check it out.

Yeah sorry my bad, I meant Jobs. I was using Jobs 0.2.10-preview.12 and tried to upgrade to 0.7.0-preview.17

Burst was always at 1.4.1

Could you try disabling engine code stripping in Player settings → Other?

Hello! I am faced with the same/similar(?) error. Installing both jobs (Version 0.7.0-preview.17) and burst (Version 1.4.3) package results in crash on ios device, but not android device. Strip engine code has been turned off. Attached SS showing the error on xcode.

Bug report filed at 1301178

This does look like a code stripping problem. Try editing (or creating) your link.xml file (Unity - Manual: Managed code stripping), and add this:

<assembly fullname="Unity.Burst" preserve="all"/>
4 Likes

Alrighty, I will be trying this out. Thank you!

I had a similar issue and the link.xml fixed it, thanks!

1 Like