Search Unity

How do you remove a component from a burst compiled job?

Discussion in 'Burst' started by davenirline, Oct 6, 2018.

  1. davenirline

    davenirline

    Joined:
    Jul 7, 2010
    Posts:
    987
    None of these works:

    Code (CSharp):
    1. // commandBuffer is a EntityCommandBuffer
    2.  
    3. this.commandBuffer.RemoveComponent<Changed>(this.entities[i]);
    4.  
    5. // or
    6.  
    7. this.commandBuffer.RemoveComponent(this.entities[i], ComponentType.Create<Changed>());
    I get the following error (Just the first one. There are lots of errors after this.):

    C:\Users\Marnel\AppData\Local\Unity\cache\packages\staging-packages.unity.com\com.unity.entities@0.0.12-preview.16\Unity.Entities\Types\TypeManager.cs(110,13): error: Loading from a static field `System.Int32 Unity.Entities.TypeManager/StaticTypeLookup`1<T>::typeIndex` is not supported by burst

    While processing function `Unity.Entities.TypeManager, Unity.Entities, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null::GetTypeIndex`1[[CommonEcs.Changed, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]()`

    While compiling job: System.Void Unity.Jobs.IJobExtensions/JobStruct`1<CommonEcs.IdentifySpriteManagerChangedValuesSystem/Job>::Execute(T&,System.IntPtr,System.IntPtr,Unity.Jobs.LowLevel.Unsafe.JobRanges&,System.Int32)

    Compiler exception: 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 <d92c0b1c82064eb3973b213f80129040>:0
    at Burst.Compiler.IL.ILVisitor.Ldsfld (Burst.Compiler.IL.Syntax.ILInstruction inst) [0x0006c] in <d92c0b1c82064eb3973b213f80129040>:0
    at Burst.Compiler.IL.ILVisitor.CompileInternal (Burst.Compiler.IL.Syntax.ILInstruction inst) [0x004de] in <d92c0b1c82064eb3973b213f80129040>:0
    at Burst.Compiler.IL.ILVerifier.CompileInternal (Burst.Compiler.IL.Syntax.ILInstruction inst) [0x00000] in <d92c0b1c82064eb3973b213f80129040>:0


    I looked at the code for EntityCommandBuffer.RemoveComponent() and I see that the generic parameter T is not bounded to struct and IComponentData like how they are in SetComponent() and AddComponent(). Is this the one causing the error?
     
  2. dartriminis

    dartriminis

    Joined:
    Feb 3, 2017
    Posts:
    157
    The EntityCommandBuffer does not currently support burst compiled jobs. Youll have to either use a non-burst job, or queue up the changes and add them to the command buffer later.
     
  3. davenirline

    davenirline

    Joined:
    Jul 7, 2010
    Posts:
    987
    I see. Thanks!
     
  4. GilCat

    GilCat

    Joined:
    Sep 21, 2013
    Posts:
    676
    Will EntityCommandBuffer ever be supported with burst?

    Thanks