Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Nominations have been announced for this years Unity Awards. Celebrate the wonderful projects made by your peers this year and get voting! Vote here!
    Dismiss Notice
  6. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  7. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Burst for standalone players

Discussion in 'Entity Component System and C# Job system' started by xoofx, Jul 10, 2018.

  1. xoofx

    xoofx

    Unity Technologies

    Joined:
    Nov 5, 2016
    Posts:
    84
    It's an internal error, something is not handled properly in burst on a particular construct (involving likely calling a generic instance of a struct through an interface call). If you can isolate the issue with a simple project and submit a bug, we will have a look at it. Thanks!
     
  2. eric_funktroniclabs

    eric_funktroniclabs

    Joined:
    Oct 4, 2018
    Posts:
    6
    Bug submitted, and I've also put the min case up on github: https://github.com/efruchter/BrokenJob_Nov26

    Here's the offending code, for your convenience:

    Code (CSharp):
    1. using Unity.Burst;
    2. using Unity.Collections;
    3. using Unity.Jobs;
    4. using Unity.Mathematics;
    5.  
    6. [BurstCompile]
    7. public struct BrokenJob : IJob
    8. {
    9.     public NativeArray<float3> GrabConstraints;
    10.  
    11.     [ReadOnly] public float3x3 LeftHandPosition, RightHandPosition;
    12.  
    13.     public void Execute()
    14.     {
    15.         for (int grabIndex = 0; grabIndex < GrabConstraints.Length; grabIndex++)
    16.         {
    17.             bool isLeft = grabIndex == 0 || grabIndex == 2;
    18.             var pos = isLeft ? LeftHandPosition.c0 : RightHandPosition.c0;
    19.             int grabStatKey = isLeft ? 1 : 2;
    20.         }
    21.     }
    22. }
    I've noticed that if I remove the 3rd line "grabStatKey", it compiles. I have a custom blittable Bool1 struct that is a "byte" internally, and swapping "bool" with my "bool1" also fixes the compilation.
     
    Last edited: Nov 29, 2018
  3. Sylmerria

    Sylmerria

    Joined:
    Jul 2, 2012
    Posts:
    161
    Hi,

    When I want build on Win x64, I have this error :
    Code (CSharp):
    1. System.Exception: C:\Users\sylme\Desktop\Test iso\test iso\Library\PackageCache\com.unity.burst@0.2.4-preview.37\.Runtime\bcl.exe did not run properly!
    2.   at UnityEditorInternal.Runner.RunProgram (UnityEditor.Utils.Program p, System.String exe, System.String args, System.String workingDirectory, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser) [0x0011f] in C:\buildslave\unity\build\Editor\Mono\BuildPipeline\BuildUtils.cs:130
    3.   at UnityEditorInternal.Runner.RunManagedProgram (System.String exe, System.String args, System.String workingDirectory, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser, System.Action`1[T] setupStartInfo) [0x00063] in C:\buildslave\unity\build\Editor\Mono\BuildPipeline\BuildUtils.cs:73
    4.   at Unity.Burst.Editor.BurstAotCompiler.OnPostBuildPlayerScriptDLLs (UnityEditor.Build.Reporting.BuildReport report) [0x0054f] in C:\Users\sylme\Desktop\Test iso\test iso\Library\PackageCache\com.unity.burst@0.2.4-preview.37\Editor\BurstAotCompiler.cs:236
    5. UnityEngine.Debug:LogError(Object)
    6. Unity.Burst.Editor.BurstAotCompiler:OnPostBuildPlayerScriptDLLs(BuildReport) (at Library/PackageCache/com.unity.burst@0.2.4-preview.37/Editor/BurstAotCompiler.cs:240)
    7. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    This job is unit tested so I know it works in editor with burst and of course I have no try/catch in my ECS world
    Can you add line where burst crash in furtur ?

    Job code :

    Code (CSharp):
    1.         [BurstCompile]
    2.         public struct DistributionLinkDemandToOfferJob : IJob
    3.         {
    4.             #region Implementation of IJob
    5.  
    6.             /// <inheritdoc />
    7.  
    8.             // ReSharper disable once FunctionComplexityOverflow
    9.             public void Execute()
    10.             {
    11.                 foreach (var currentDemandIndex in DemandOrder)
    12.                 {
    13.                     var demandChunk      = DemandChunks[currentDemandIndex.x];
    14.                     var demandResumArray = demandChunk.GetNativeArray(DemandResumACC);
    15.  
    16.                     _demandResum = demandResumArray[currentDemandIndex.y];
    17.  
    18.                     if (_demandResum.FillByLinkedDemand)
    19.                         continue;
    20.  
    21.                     int bestScore = -999;
    22.  
    23.                     for (int offerChunkIndex = 0; offerChunkIndex < GoodOfferChunk.Length; offerChunkIndex++)
    24.                     {
    25.                         var offerArray = OfferChunks[GoodOfferChunk[offerChunkIndex]].GetNativeArray(OfferResumACC);
    26.  
    27.                         for (int offerArrayIndex = 0; offerArrayIndex < offerArray.Length; offerArrayIndex++)
    28.                         {
    29.                             if (offerArray[offerArrayIndex].Reserved)
    30.                                 continue;
    31.  
    32.                             var currentScore = GetScoreOffer(offerArray[offerArrayIndex]);
    33.  
    34.                             if (bestScore >= currentScore)
    35.                                 continue;
    36.  
    37.                             bestScore       = currentScore;
    38.                             _betterOffer[0] = GoodOfferChunk[offerChunkIndex];
    39.                             _betterOffer[1] = offerArrayIndex;
    40.                         }
    41.                     }
    42.  
    43.                     //if score inf -2 again, it means that any offer is valid so cute this resource
    44.                     if (bestScore < -1) //-1 is not valid beause an offer can be not valid for this demand but good for next
    45.                         return;
    46.  
    47.                     var offerResumArray = OfferChunks[_betterOffer.x].GetNativeArray(OfferResumACC);
    48.                     var oTraget         = offerResumArray[_betterOffer.y];
    49.                     oTraget.Reserved                = true;
    50.                     offerResumArray[_betterOffer.y] = oTraget;
    51.  
    52.                     PreAgreementList.Add(new PreAgreement { DemandIndex = currentDemandIndex, OfferIndex = _betterOffer });
    53.                 }
    54.             }
    55.  
    56.             #endregion
    57.  
    58.             private int GetScoreOffer(OfferResum offer)
    59.             {
    60.                 if (offer.AmountSum < 1F || _demandResum.CarrierCameFromMe == false && offer.CarrierCount == 0)
    61.                     return -1;
    62.  
    63.                 int score = ((int)offer.Priority + 1) * 2000;
    64.  
    65.                 //distance of vector 100,100,100
    66.                 const float maxDistanceForValue = 1F / 173.20508F;
    67.  
    68.                 score += (int)(1000F * (1F - math.clamp(math.distance(_demandResum.Position, offer.Position) * maxDistanceForValue, 0F, 1F)));
    69.  
    70.                 var tuple = CalcAmountResource(offer.AmountFree);
    71.  
    72.                 int amountResource = tuple.Sum, amountValue = tuple.Value;
    73.  
    74.                 if (_demandResum.InternalStorageAccepted)
    75.                 {
    76.                     tuple = CalcAmountResource(offer.AmountInternal);
    77.  
    78.                     amountResource += tuple.Sum;
    79.                     amountValue    += tuple.Value;
    80.                 }
    81.  
    82.                 if (amountResource < 1F)
    83.                     return -1;
    84.  
    85.                 score += math.min(15 * amountValue, 1000);
    86.                 score += math.min(15 * amountResource, 500);
    87.  
    88.                 return score;
    89.             }
    90.  
    91.             /// <summary>
    92.             /// Calcul amount sum and amount value
    93.             /// </summary>
    94.             /// <param name="offer"></param>
    95.             /// <returns></returns>
    96.             private (int Sum, int Value) CalcAmountResource(OfferAmount offer)
    97.             {
    98.                 int sum = 0, value = 0;
    99.  
    100.                 var qualMin = _demandResum.QualityMinimun;
    101.                 var qualMax = _demandResum.QualityMaximum;
    102.  
    103.                 if (qualMin == QualityResource.Poor)
    104.                 {
    105.                     sum   += offer.AmountPoor;
    106.                     value += offer.AmountPoor;
    107.                 }
    108.  
    109.                 if (qualMin <= QualityResource.Basic && qualMax >= QualityResource.Basic)
    110.                 {
    111.                     sum   += offer.AmountBasic;
    112.                     value += offer.AmountBasic * 2;
    113.                 }
    114.  
    115.                 if (qualMin <= QualityResource.Good && qualMax >= QualityResource.Good)
    116.                 {
    117.                     sum   += offer.AmountGood;
    118.                     value += offer.AmountGood * 3;
    119.                 }
    120.  
    121.                 if (qualMin <= QualityResource.Excellent && qualMax >= QualityResource.Excellent)
    122.                 {
    123.                     sum   += offer.AmountExcellent;
    124.                     value += offer.AmountExcellent * 4;
    125.                 }
    126.  
    127.                 if (qualMin <= QualityResource.Divin && qualMax == QualityResource.Divin)
    128.                 {
    129.                     sum   += offer.AmountDivin;
    130.                     value += offer.AmountDivin * 5;
    131.                 }
    132.  
    133.                 return (sum, value);
    134.             }
    135.  
    136.             #region Variables
    137.  
    138.             [ReadOnly]
    139.             public NativeArray<ArchetypeChunk> DemandChunks;
    140.             [ReadOnly]
    141.             public NativeArray<ArchetypeChunk> OfferChunks;
    142.  
    143.             [ReadOnly]
    144.             public NativeArray<int2> DemandOrder;
    145.             [ReadOnly]
    146.             public NativeList<int> GoodOfferChunk;
    147.  
    148.             [ReadOnly]
    149.             public ArchetypeChunkComponentType<DemandResum> DemandResumACC;
    150.             public ArchetypeChunkComponentType<OfferResum> OfferResumACC;
    151.  
    152.             //output
    153.             [WriteOnly]
    154.             public NativeList<PreAgreement> PreAgreementList;
    155.  
    156.             private int2                    _betterOffer;
    157.             private DemandResum             _demandResum;
    158.  
    159.             #endregion
    160.         }
    161.  
     
  4. capyvara

    capyvara

    Joined:
    Mar 11, 2010
    Posts:
    63
    Just a heads up, updating to the latest Xcode command line tools fixed the problem, maybe the clang version did't accepted symlinks to .tbd's ?

    I see you use /usr/bin/clang directly so this needs a dependency on the command line tools directly, instead may be better to use xcrun clang in order to run the compiler, etc?
     
    Last edited: Dec 17, 2018 at 5:33 AM