Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Bug Burst crash on iOS at creating a IJobParallelForTransform job

Discussion in '2020.2 Beta' started by Skjalg, Nov 20, 2020.

  1. Skjalg

    Skjalg

    Joined:
    May 25, 2009
    Posts:
    211
    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.


    Code (CSharp):
    1. [BurstCompile]
    2.     public struct ObjectMoveJob : IJobParallelForTransform
    3.     {
    4.         [ReadOnly]
    5.         public NativeArray<ObjectMove.ObjectData> ObjectData;
    6.         public NativeArray<ObjectMove.ObjectMoveData> ObjectMoveData;
    7.         [ReadOnly]
    8.         public NativeArray<float3> Waypoints;
    9.         public float DeltaTime;
    10.    
    11.         public void Execute(int index, TransformAccess transform)
    12.         {
    13.             var moveData = ObjectMoveData[index];
    14.             int currentWaypoint = moveData.CurrentWaypoint;
    15.             bool reverseDirection = moveData.ReverseDirection;
    16.             bool loop = ObjectData[index].Loop;
    17.             float rotationCorrection = ObjectData[index].RotationCorrection;
    18.             float speed = ObjectData[index].MoveSpeed;
    19.             var pos = transform.position;
    20.             var transformPosition = new float3(pos.x, pos.y, pos.z);
    21.  
    22.             if (currentWaypoint < ObjectData[index].EndWPIndex && currentWaypoint >= ObjectData[index].StartWPIndex)
    23.             {
    24.                 var waypoint = Waypoints[currentWaypoint];
    25.                 var target = new float3(waypoint.x, waypoint.y, waypoint.z) + ObjectData[index].Offset + ObjectData[index].Shift;
    26.  
    27.                 if (math.distance(target, transformPosition) < 0.1f)
    28.                 {
    29.                     currentWaypoint = reverseDirection ? currentWaypoint - 1 : currentWaypoint + 1;
    30.                 }
    31.                 else
    32.                 {
    33.                     var moveDirection = target - transformPosition;
    34.                     //Never rotate up or down
    35.                     moveDirection.y = 0;
    36.                     var look = quaternion.LookRotation(moveDirection, new float3(0, 1, 0));
    37.                
    38.                     //Rotate by rotation correction. Used by surfers
    39.                     var offset = quaternion.RotateY(math.radians(rotationCorrection));
    40.                     var rotation = math.mul(look, offset);
    41.                    
    42.  
    43.                     transform.position = MoveTowards(transformPosition, target, speed * DeltaTime);
    44.                     transform.rotation = math.slerp(transform.rotation, rotation, DeltaTime * ObjectData[index].RotationSpeed);
    45.                 }
    46.             }
    47.             else
    48.             {
    49.                 if (loop)
    50.                 {
    51.                     if (currentWaypoint >= ObjectData[index].EndWPIndex)
    52.                     {
    53.                         currentWaypoint = ObjectData[index].StartWPIndex;
    54.                     }
    55.                     else if (currentWaypoint <= ObjectData[index].StartWPIndex)
    56.                     {
    57.                         currentWaypoint = ObjectData[index].EndWPIndex - 1;
    58.                     }
    59.                 }
    60.                 else
    61.                 {
    62.                     reverseDirection = !reverseDirection;
    63.                     if (reverseDirection)
    64.                     {
    65.                         currentWaypoint -= 1;
    66.                     }
    67.                     else
    68.                     {
    69.                         currentWaypoint += 1;
    70.                     }
    71.                 }
    72.                 //Log($"2  reverseDirection = {reverseDirection}  currentWaypoint = {currentWaypoint} start: {ObjectData[index].StartWPIndex} end: {ObjectData[index].EndWPIndex}");
    73.             }
    74.  
    75.             moveData.CurrentWaypoint = currentWaypoint;
    76.             moveData.ReverseDirection = reverseDirection;
    77.             ObjectMoveData[index] = moveData;
    78.         }
    79.  
    80.         private static float3 MoveTowards(
    81.             float3 current,
    82.             float3 target,
    83.             float maxDistanceDelta)
    84.         {
    85.             float num1 = target.x - current.x;
    86.             float num2 = target.y - current.y;
    87.             float num3 = target.z - current.z;
    88.             float num4 = (float) ((double) num1 * (double) num1 + (double) num2 * (double) num2 + (double) num3 * (double) num3);
    89.             if ((double) num4 == 0.0 || (double) maxDistanceDelta >= 0.0 && (double) num4 <= (double) maxDistanceDelta * (double) maxDistanceDelta)
    90.                 return target;
    91.             float num5 = (float) math.sqrt((double) num4);
    92.             return new float3(current.x + num1 / num5 * maxDistanceDelta, current.y + num2 / num5 * maxDistanceDelta, current.z + num3 / num5 * maxDistanceDelta);
    93.         }
    94.     }
     
  2. Skjalg

    Skjalg

    Joined:
    May 25, 2009
    Posts:
    211
    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
     
  3. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    Current released Burst version is 1.4.1 - you may want to check it out.
     
  4. Skjalg

    Skjalg

    Joined:
    May 25, 2009
    Posts:
    211
    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
     
  5. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    Could you try disabling engine code stripping in Player settings -> Other?
     
  6. Klausology

    Klausology

    Joined:
    Aug 29, 2017
    Posts:
    131
    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
     

    Attached Files:

  7. tim_jones

    tim_jones

    Unity Technologies

    Joined:
    May 2, 2019
    Posts:
    287
  8. Klausology

    Klausology

    Joined:
    Aug 29, 2017
    Posts:
    131
  9. NuclearCookieTF

    NuclearCookieTF

    Joined:
    Mar 29, 2021
    Posts:
    17
    I had a similar issue and the link.xml fixed it, thanks!
     
    kevinetourneau likes this.