Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

(Case 1210245) Unity Editor crashes when using a generic component with the lambda API

Discussion in 'Entity Component System' started by cjxm, Jan 17, 2020.

  1. cjxm

    cjxm

    Joined:
    Feb 1, 2016
    Posts:
    6
    I'm using the last version of Entities 0.5. Code for reproducing the issue is simple, and authoring is not required to see the crash:

    Code (CSharp):
    1. [assembly: RegisterGenericComponentType(typeof(GenericComponent<int>))]
    2. namespace Assets
    3. {
    4.     public struct GenericComponent<T> : IComponentData
    5.     where T : struct
    6.     {
    7.         public float Value;
    8.     }
    9.  
    10.     public class SystemWithGenericComponent : JobComponentSystem
    11.     {
    12.         protected override JobHandle OnUpdate(JobHandle inputDeps)
    13.         {
    14.             return Entities
    15.                 .ForEach((in GenericComponent<int> cGeneric) =>
    16.                 {
    17.                     // Some work...
    18.                 }).Schedule(inputDeps);
    19.         }
    20.     }
    21. }
    After running any scene the Editor crashes immediately. The editor log shows some exception in Mono:
    * Assertion at ..\mono\mini\method-to-ir.c:8462, condition `!mono_method_check_context_used (cmethod)' not met


    So, if I have Entities.ForEach with a generic component, the entire project will broken. Jobs as structs with generic components are working properly.
     
    BackgroundMover likes this.
  2. cjxm

    cjxm

    Joined:
    Feb 1, 2016
    Posts:
    6
    I'm sorry I unintentionally created the thread in wrong subforum. Can anyone move the thread to DOTS subforum?
     
  3. BackgroundMover

    BackgroundMover

    Joined:
    May 9, 2015
    Posts:
    209
    I can reproduce this. I found another post about Generics in lambdas being unsupported, but the editor crashing seems a bit much!