Search Unity

Burst: Unexpected Exception

Discussion in 'Data Oriented Technology Stack' started by illinar, Dec 16, 2018.

  1. illinar

    illinar

    Joined:
    Apr 6, 2011
    Posts:
    557

    Unexpected exception Burst.Compiler.IL.CompilerException: Unexpected exception ---> Burst.Compiler.IL.CompilerException: Error while processing function `System.Int32 Unity.Entities.TypeManager::GetTypeIndex<T>()` ---> Burst.Compiler.IL.CompilerException: Unexpected error while processing `IL_0001: ldsfld System.Int32 Unity.Entities.TypeManager/StaticTypeLookup`1<T>::typeIndex` at C:\Users\illinar\AppData\Local\Unity\cache\packages\packages.unity.com\com.unity.entities@0.0.12-preview.21\Unity.Entities\Types\TypeManager.cs(110,13) ---> System.NotSupportedException: Loading from a static field `System.Int32 Unity.Entities.TypeManager/StaticTypeLookup`1<T>::typeIndex` is not supported by burst
    at Burst.Compiler.IL.ILVisitor.NotSupported (Burst.Compiler.IL.Syntax.ILInstruction inst) [0x0016b] in <37bebafd236f4ccd943dc039a926a017>:0
    at Burst.Compiler.IL.ILVisitor.Ldsfld (Burst.Compiler.IL.Syntax.ILInstruction inst) [0x0006c] in <37bebafd236f4ccd943dc039a926a017>:0
    at Burst.Compiler.IL.ILVisitor.CompileInternal (Burst.Compiler.IL.Syntax.ILInstruction inst) [0x004de] in <37bebafd236f4ccd943dc039a926a017>:0
    at Burst.Compiler.IL.ILVerifier.CompileInternal (Burst.Compiler.IL.Syntax.ILInstruction inst) [0x00018] in <37bebafd236f4ccd943dc039a926a017>:0
    at Burst.Compiler.IL.ILVisitor.Compile (Burst.Compiler.IL.Syntax.ILInstruction inst) [0x0001e] in <37bebafd236f4ccd943dc039a926a017>:0
    at Burst.Compiler.IL.ILVisitor.ProcessBlock (Burst.Compiler.IL.Syntax.ILBlock block) [0x0009a] in <37bebafd236f4ccd943dc039a926a017>:0
    --- End of inner exception stack trace ---
    at Burst.Compiler.IL.ILVisitor.ProcessBlock (Burst.Compiler.IL.Syntax.ILBlock block) [0x000e9] in <37bebafd236f4ccd943dc039a926a017>:0
    at Burst.Compiler.IL.ILVisitor.ProcessBlocks () [0x0002e] in <37bebafd236f4ccd943dc039a926a017>:0
    at Burst.Compiler.IL.ILVisitor.ProcessFunctionBody (Burst.Compiler.IL.Syntax.ILFunction function) [0x00103] in <37bebafd236f4ccd943dc039a926a017>:0
    at Burst.Compiler.IL.ILVisitor.VisitPendingFunctions () [0x0000e] in <37bebafd236f4ccd943dc039a926a017>:0
    --- End of inner exception stack trace ---
    at Burst.Compiler.IL.ILVisitor.VisitPendingFunctions () [0x00033] in <37bebafd236f4ccd943dc039a926a017>:0
    at Burst.Compiler.IL.ILVisitor.VisitEntryPointFunction (Burst.Compiler.IL.MethodReferenceWithHash methodReference) [0x00066] in <37bebafd236f4ccd943dc039a926a017>:0
    at Burst.Compiler.IL.ILVisitor.VisitEntryPointFunction (Burst.Backend.Module module, Burst.Compiler.IL.MethodReferenceWithHash methodReference) [0x0001a] in <37bebafd236f4ccd943dc039a926a017>:0
    at Burst.Compiler.IL.ILVerifier.VisitEntryPointFunction (Burst.Backend.Module module, Burst.Compiler.IL.MethodReferenceWithHash methodReference) [0x00000] in <37bebafd236f4ccd943dc039a926a017>:0
    --- End of inner exception stack trace ---
    at Burst.Compiler.IL.ILVerifier.VisitEntryPointFunction (Burst.Backend.Module module, Burst.Compiler.IL.MethodReferenceWithHash methodReference) [0x0001f] in <37bebafd236f4ccd943dc039a926a017>:0
    at Burst.Compiler.IL.ILHash.CompileHash (Burst.Backend.Module module, Burst.Compiler.IL.MethodReferenceWithHash methodReference) [0x00000] in <37bebafd236f4ccd943dc039a926a017>:0
    at Burst.Compiler.IL.NativeCompiler.ComputeHash () [0x000ea] in <37bebafd236f4ccd943dc039a926a017>:0
    at Burst.Compiler.IL.Jit.JitCompiler.CompileMethod (Mono.Cecil.MethodReference methodReference, Burst.Compiler.IL.Jit.JitOptions jitOptions) [0x000aa] in <37bebafd236f4ccd943dc039a926a017>:0
    at Burst.Compiler.IL.Jit.JitCompilerService.Compile (Burst.Compiler.IL.Jit.JitCompilerService+CompileJob job) [0x002b2] in <37bebafd236f4ccd943dc039a926a017>:0
    While compiling job: System.Void Unity.Entities.JobChunkExtensions/JobChunkLiveFilter_Process`1<ProjectileRaycastSystem/Job>::Execute(Unity.Entities.JobChunkExtensions/JobDataLiveFilter`1<T>&,System.IntPtr,System.IntPtr,Unity.Jobs.LowLevel.Unsafe.JobRanges&,System.Int32)

    Code (CSharp):
    1. [BurstCompile]
    2.     private struct Job : IJobChunk
    3.     {
    4.         [ReadOnly] public ArchetypeChunkComponentType<PreviousFixedPosition> PreviousFixedPositioType;
    5.         [ReadOnly] public ArchetypeChunkComponentType<RaycastSettings> RaycastSettingsType;
    6.         [ReadOnly] public ArchetypeChunkComponentType<LocalToWorld> LocalToWorldType;
    7.         [ReadOnly] public ArchetypeChunkEntityType EntityType;
    8.         [ReadOnly] public EntityCommandBuffer.Concurrent commandBuffer;
    9.  
    10.         public void Execute(ArchetypeChunk chunk, int chunkIndex)
    11.         {
    12.             var previousFixedPositionArray = chunk.GetNativeArray(PreviousFixedPositioType);
    13.             var raycastSettingsArray = chunk.GetNativeArray(RaycastSettingsType);
    14.             var localToWorldArray = chunk.GetNativeArray(LocalToWorldType);
    15.             var entityArray = chunk.GetNativeArray(EntityType);
    16.  
    17.             for (int i = 0; i < chunk.Count; ++i)
    18.             {
    19.                 var raycastCommand = new RaycastCommand();
    20.                 raycastCommand.layerMask = raycastSettingsArray[i].LayerMask;
    21.                 raycastCommand.from = localToWorldArray[i].Value.Position() - previousFixedPositionArray[i].Value;
    22.                 raycastCommand.direction = (float3)raycastCommand.from - previousFixedPositionArray[i].Value;
    23.                 raycastCommand.distance = math.length(raycastCommand.distance);
    24.                 commandBuffer.AddComponent<Raycast>(chunkIndex + i, entityArray[i], new Raycast { Command = raycastCommand });
    25.             }
    26.         }
    27.     }

    Without burst attribute, it executes and does its work. This is the line that causes the exception:

    commandBuffer.AddComponent<Raycast>(chunkIndex + i, entityArray[i], new Raycast { Command = raycastCommand });
     
    Last edited: Dec 16, 2018
  2. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,261
    All EntityCommandBuffer methods that involves a type does not work with Burst

    (UT should already sticky a thread called "Things that does not work yet" ..)
     
  3. illinar

    illinar

    Joined:
    Apr 6, 2011
    Posts:
    557
    Okay, that explains everything. No [Burst] for now then. Thank you.
     
  4. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    1,370
    Only Destroy allowed in Bursted job.
     
    illinar likes this.