Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

JobSystem: Unexpected error while processing function ...Execute...

Discussion in 'Entity Component System' started by DenVer9, May 23, 2019.

  1. DenVer9

    DenVer9

    Joined:
    Aug 31, 2017
    Posts:
    5
    Hi all.
    Error when working with Jobsystem.
    It appears once, then it works fine. What could be the problem?
    Thanks.


    E:\UnityProjects\project\Assets\Scripts\Dungeoneers\Systems\DungeoneerMovementSystem.cs(63,25): error: Unexpected error while processing function `Assets.Scripts.Dungeoneers.DungeoneerMovementSystem.GroupJob.Execute(Assets.Scripts.Dungeoneers.DungeoneerMovementSystem.GroupJob* this, ref UniqueId EntitieIds, ref Assets.Scripts.Dungeoneers.Entities.Dungeoneer Components, ref DataContent Data)`. Reason: Object reference not set to an instance of an object
    at Assets.Scripts.Dungeoneers.DungeoneerMovementSystem.GroupJob.Execute(Assets.Scripts.Dungeoneers.DungeoneerMovementSystem.GroupJob* this, ref UniqueId EntitieIds, ref Assets.Scripts.Dungeoneers.Entities.Dungeoneer Components, ref DataContent Data) (at E:\UnityProjects\project\Assets\Scripts\Dungeoneers\Systems\DungeoneerMovementSystem.cs:43)
    at Unity.Entities.JobForEachExtensions.JobStruct_Process_CCC`4<Assets.Scripts.Dungeoneers.DungeoneerMovementSystem.GroupJob,UniqueId,Assets.Scripts.Dungeoneers.Entities.Dungeoneer,DataContent>.ExecuteChunk(ref Unity.Entities.JobForEachExtensions.JobStruct_Process_CCC`4<Assets.Scripts.Dungeoneers.DungeoneerMovementSystem.GroupJob,UniqueId,Assets.Scripts.Dungeoneers.Entities.Dungeoneer,DataContent> jobData, System.IntPtr bufferRangePatchData, int begin, int end, Unity.Entities.ArchetypeChunk* chunks, int* entityIndices) (at E:\UnityProjects\project\Library\PackageCache\com.unity.entities@0.0.12-preview.32\Unity.Entities\IJobForEach.gen.cs:2618)
    at Unity.Entities.JobForEachExtensions.JobStruct_Process_CCC`4<Assets.Scripts.Dungeoneers.DungeoneerMovementSystem.GroupJob,UniqueId,Assets.Scripts.Dungeoneers.Entities.Dungeoneer,DataContent>.Execute(ref Unity.Entities.JobForEachExtensions.JobStruct_Process_CCC`4<Assets.Scripts.Dungeoneers.DungeoneerMovementSystem.GroupJob,UniqueId,Assets.Scripts.Dungeoneers.Entities.Dungeoneer,DataContent> jobData, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, ref Unity.Jobs.LowLevel.Unsafe.JobRanges ranges, int jobIndex) (at E:\UnityProjects\project\Library\PackageCache\com.unity.entities@0.0.12-preview.32\Unity.Entities\IJobForEach.gen.cs:2590)
    Internal compiler exception: System.NullReferenceException: Object reference not set to an instance of an object
    at Burst.Compiler.IL.Helpers.CecilExtensions.IsDelegate (Mono.Cecil.TypeDefinition typeDef) [0x0002b] in <4699ce1e4a32410f9b68efcb2d4009cd>:0
    at Burst.Compiler.IL.Syntax.ILBuilder.Call (Mono.Cecil.Cil.Instruction inst, Mono.Cecil.MethodReference methodReference, Burst.Compiler.IL.Syntax.ILExpression thisArgument) [0x00156] in <4699ce1e4a32410f9b68efcb2d4009cd>:0
    at Burst.Compiler.IL.Syntax.ILBuilder.ProcessInstruction (Mono.Cecil.Cil.Instruction inst) [0x003d6] in <4699ce1e4a32410f9b68efcb2d4009cd>:0
    at Burst.Compiler.IL.Syntax.ILBuilder.ProcessInstructions () [0x00099] in <4699ce1e4a32410f9b68efcb2d4009cd>:0
    at Burst.Compiler.IL.Syntax.ILBuilder.ProcessFunctionBody () [0x00080] in <4699ce1e4a32410f9b68efcb2d4009cd>:0
    at Burst.Compiler.IL.Syntax.ILBuilder.CreateFunctionFromRef (Burst.Compiler.IL.Syntax.ILFunctionReference funcRef) [0x000dc] in <4699ce1e4a32410f9b68efcb2d4009cd>:0
    at Burst.Compiler.IL.Syntax.ILBuilder.VisitPendingFunctionReferences () [0x000c1] in <4699ce1e4a32410f9b68efcb2d4009cd>:0
    While compiling job: System.Void Unity.Entities.JobForEachExtensions/JobStruct_Process_CCC`4<Assets.Scripts.Dungeoneers.DungeoneerMovementSystem/GroupJob,UniqueId,Assets.Scripts.Dungeoneers.Entities.Dungeoneer,DataContent>::Execute(Unity.Entities.JobForEachExtensions/JobStruct_Process_CCC`4<T,T0,T1,T2>&,System.IntPtr,System.IntPtr,Unity.Jobs.LowLevel.Unsafe.JobRanges&,System.Int32)

    Code (CSharp):
    1. [BurstCompile]
    2.         public struct GroupJob : IJobForEach<UniqueId, Dungeoneer, DataContent>
    3.         {
    4.             [Unity.Collections.ReadOnly]
    5.             public float Time;
    6.  
    7.             public void Execute([Unity.Collections.ReadOnly]ref UniqueId EntitieIds, ref Dungeoneer Components, [Unity.Collections.ReadOnly]ref DataContent Data)
    8.             {
    9.                 var component = Components;
    10.                 if (component.DisableMovement == 1) return;
    11.  
    12.                 if (component.Position.DistanceTo(component.MovingTo) > PointThreshold)
    13.                 {
    14.                     var _map = new CityMapService();
    15.                     var data = Data.Get<DungeoneerData>();
    16.                     var positionClosesLocation = _map.GetClosestTo(component.Position);
    17.                     var movingToClosesLocation = _map.GetClosestTo(component.MovingTo);
    18.                     var speed = (data.PercentOfBaseMovingSpeed * component.CurrentSpeed / 100f);
    19.                  
    20.                     var path = Pathfinder.Find<ICityLocation>(_map.GetNodes(), positionClosesLocation, movingToClosesLocation,
    21.                         (d) => CalculatePathCost(d, movingToClosesLocation),
    22.                         (d) => _map.GetNeighbours(d));
    23.  
    24.                     Debug.Assert(path != null, "Moving system can't find a path");
    25.                     if (path != null)
    26.                     {
    27.                    (63line error)     var nextLocationPosition = (path.Count > 1) ? path[1].Position : movingToClosesLocation.Position;
    28.  
    29.                         var linePosition = MathfExt.NearestPointOnFiniteLine(positionClosesLocation.Position, nextLocationPosition, component.Position);
    30.  
    31.                         if (linePosition.DistanceTo(component.Position) > PointThreshold)
    32.                         {
    33.                             component.Position = MathfExt.MoveTowards(component.Position, linePosition, speed * Time);
    34.                         }
    35.                         else
    36.                         {
    37.                             component.Position = MathfExt.MoveTowards(component.Position, nextLocationPosition, speed * Time);
    38.                         }
    39.                         Components = component;
    40.                     }
    41.                 }
    42.             }
    43.         }
    44.  
    45.         protected override JobHandle OnUpdate(JobHandle inputDeps)
    46.         {
    47.             var groupJob = new GroupJob()
    48.             {
    49.                 Time = Time.deltaTime
    50.             };
    51.  
    52.             return groupJob.Schedule(this, inputDeps);
    53.         }
     
  2. GilCat

    GilCat

    Joined:
    Sep 21, 2013
    Posts:
    676
    You can't use object references in Burst.
     
    DenVer9 likes this.