Search Unity

Burst 1.1.0 fails to compile NativeHashMap

Discussion in 'Burst' started by snacktime, Jul 11, 2019.

  1. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    I already downgraded but the error is unable to resolve TKey in NativeHashMap.cs line 516.

    It fails in a fairly specific context for me, these are the two context's I saw failures in.

    - Where the hashmap is not declared on the job itself, but is passed in contained in another struct. It fails on methods on that container struct that access the hashmap.
    - where the hashmap is declared on the job, but inside the job it's passed to a static helper method. It's inside that helper method where it's unable to resolve.
     
  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,759
    I'm on 1.1.0 preview 4

    I think I do this exact thing and I have had no issue since upgrading.

    Here is what I'm doing just to make sure I understood right.

    Code (CSharp):
    1.  
    2. [BurstCompile]
    3. public struct ObstructionChangedJob : IJobForEach<DynamicObstruction, LocalToWorld>
    4. {
    5.     public ObstructionChangedImpl Impl;
    6.  
    7.     // ..
    8.  
    9.     /// <inheritdoc />
    10.     public void Execute(ref DynamicObstruction observations, [ReadOnly] [ChangedFilter] ref LocalToWorld localToWorld)
    11.     {
    12.         // ..
    13.  
    14.         this.Impl.Execute(localToWorld.Position.xz);
    15.     }
    16. }
    17.  

    ObstructionChangedImpl containers NativeMultiHashMaps

    Code (CSharp):
    1. public struct ObstructionChangedImpl
    2. {
    3.     // ...
    4.  
    5.     public NativeMultiHashMap<int, Entity>.Concurrent ClearMap;
    6.  
    7.     public NativeMultiHashMap<int, VisionData>.Concurrent VisionMap;
     
  3. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Ya that's basically the pattern but with methods inside ObstructionChangedImpl that do something. However NativeMultiHashMap doesn't fail for me just NativeHashMap. One of my jobs that fails literally has the same pattern but using NativeMultiHashMap several lines above where the NativeHashMap version fails to compile.

    NativeHashMap declares it's own iterator internally, so it seems something goes wrong there, the generics info isn't making it through for some reason.
     
  4. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Easy to repro, bug report is uploading now.

    Case 1168823
     
  5. xoofx

    xoofx

    Unity Technologies

    Joined:
    Nov 5, 2016
    Posts:
    417
    Thanks for the repro, this was a corner case when using a vector type as a key. We have a fix and it should be available in the next release.
     
    eizenhorn likes this.
  6. xoofx

    xoofx

    Unity Technologies

    Joined:
    Nov 5, 2016
    Posts:
    417
    GilCat likes this.