Search Unity

AssemblyResolutionException and halved performance with Burst and Assembly Definition

Discussion in 'Burst' started by ponpal, Oct 20, 2020.

  1. ponpal

    ponpal

    Joined:
    Nov 14, 2017
    Posts:
    6
    I've created a script which contains a simple Burst job:

    Code (CSharp):
    1. [BurstCompile(CompileSynchronously = true)]
    2.     struct SinVertices : IJobParallelFor
    3.     {
    4.         public NativeArray<float3> pos;
    5.         public NativeArray<float3> pos_original;
    6.         public float t;
    7.  
    8.         public void Execute(int i)
    9.         {
    10.             pos[i] = pos_original[i] * math.abs(math.sin(t));
    11.         }
    12.     }
    This runs as expected in the editor and in a standalone. Now I am trying to use an Assembly Definition to make Unity generate a DLL for my script, and use that DLL in the Unity project instead of the C# script file. This has worked well for normal C# scripts, but when Burst is used in the compiled DLL I get the following error in the Unity console:

    The script still runs as expected, but performance is reduced by 50%. I've included Unity.Burst and Unity.Mathematics in my Assembly Definition References, as I would get other errors otherwise. Why do I get the error above and why is performance reduced?
     
  2. ponpal

    ponpal

    Joined:
    Nov 14, 2017
    Posts:
    6
    After some more testing, it is clear that the performance is reduced due to the fact that my jobs aren't compiled with Burst, because the Burst compiler fails to resolve my assembly (ScriptAssembly). When removing the [BurstCompile] attribute from my jobs everything works as expected, although obviously much slower.

    I still can't figure out why the above error happens with [BurstCompile] enabled though, since the jobs are themselves part of ScriptAssembly. Any ideas?