Jobs Errors after update to 4.3.90

Hi there, my project was working perfectly (for path finding at leas! :slight_smile: ) but I needed to upgrade to a higher version of unity for an unrelated reason. I updated path finding to 4.3.90 at the same time, along with Entities to 1.0.16.

After these two upgrades I stated getting the null reference exception described below, followed by another error that appears related to the Jobs system.

Edit: Unity version 2022.3.15f1. I am having a hard time reproducing these errors consistently.

Error 1:

NullReferenceException: Object reference not set to an instance of an object
Pathfinding.HierarchicalGraph+JobRecalculateComponents.Execute () (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Pathfinding/HierarchicalGraph.cs:503)
Unity.Jobs.IJobExtensions+JobStruct`1[T].Execute (T& data, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at <5879d8d225474494bcffdfe64965038e>:0)
Unity.Jobs.JobHandle:ScheduleBatchedJobsAndComplete(JobHandle&)
Unity.Jobs.JobHandle:Complete()
Pathfinding.HierarchicalGraph:RecalculateIfNecessary() (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Pathfinding/HierarchicalGraph.cs:564)
Pathfinding.WorkItemProcessor:EnsureValidFloodFill() (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Misc/WorkItemProcessor.cs:268)
Pathfinding.WorkItemProcessor:ProcessWorkItems(Boolean, Boolean) (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Misc/WorkItemProcessor.cs:362)
Pathfinding.WorkItemProcessor:ProcessWorkItemsForUpdate(Boolean) (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Misc/WorkItemProcessor.cs:416)
AstarPath:PerformBlockingActions(Boolean) (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/AstarPath.cs:904)
AstarPath:Update() (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/AstarPath.cs:887)

Error 2:

UnityException: GetOrCreateTrackerHandleImpl can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.
UnityEditor.Profiling.EditorPerformanceTracker.GetOrCreateTrackerHandle (System.String trackerName, System.Type context) (at <64861216782042de93237b5c061bff1b>:0)
UnityEditor.EventWithPerformanceTracker.GetPerformanceTrackerHandleForEvent (System.String scope, System.Delegate d) (at <64861216782042de93237b5c061bff1b>:0)
UnityEditor.EventWithPerformanceTracker`1+DelegateWithHandle[T].StartTrackerAt (System.Int32 idx, System.String scope) (at <64861216782042de93237b5c061bff1b>:0)
UnityEditor.EventWithPerformanceTracker`1+Enumerator[T].MoveNext () (at <64861216782042de93237b5c061bff1b>:0)
UnityEditor.EditorApplication.Internal_PauseStateChanged (UnityEditor.PauseState state) (at <64861216782042de93237b5c061bff1b>:0)
Unity.Jobs.JobHandle:ScheduleBatchedJobsAndComplete(JobHandle&)
Unity.Jobs.JobHandle:Complete()
Pathfinding.HierarchicalGraph:RecalculateIfNecessary() (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Pathfinding/HierarchicalGraph.cs:564)
Pathfinding.WorkItemProcessor:EnsureValidFloodFill() (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Misc/WorkItemProcessor.cs:268)
Pathfinding.WorkItemProcessor:ProcessWorkItems(Boolean, Boolean) (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Misc/WorkItemProcessor.cs:362)
Pathfinding.WorkItemProcessor:ProcessWorkItemsForUpdate(Boolean) (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Misc/WorkItemProcessor.cs:416)
AstarPath:PerformBlockingActions(Boolean) (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/AstarPath.cs:904)
AstarPath:Update() (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/AstarPath.cs:887)

Error 3

NullReferenceException: Object reference not set to an instance of an object
Pathfinding.NavmeshEdges+JobCalculateObstacles.CalculateObstacles (Pathfinding.HierarchicalGraph hGraph, System.Int32 hierarchicalNode, Pathfinding.Util.SlabAllocator`1[T] obstacleVertexGroups, Pathfinding.Util.SlabAllocator`1[T] obstacleVertices, Unity.Collections.NativeArray`1[T] obstacles, Unity.Collections.NativeList`1[T] edgesScratch) (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Misc/NavmeshEdges.cs:234)
Pathfinding.NavmeshEdges+JobCalculateObstacles.Execute (System.Int32 startIndex, System.Int32 count) (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Misc/NavmeshEdges.cs:157)
Unity.Jobs.IJobParallelForBatchExtensions+JobParallelForBatchProducer`1[T].Execute (T& jobData, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at ./Library/PackageCache/com.unity.collections@2.1.4/Unity.Collections/Jobs/IJobParallelForBatch.cs:58)
Unity.Jobs.JobHandle:ScheduleBatchedJobsAndComplete(JobHandle&)
Unity.Jobs.JobHandle:Complete()
Pathfinding.HierarchicalGraph:RecalculateIfNecessary() (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Pathfinding/HierarchicalGraph.cs:564)
Pathfinding.WorkItemProcessor:EnsureValidFloodFill() (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Misc/WorkItemProcessor.cs:268)
Pathfinding.WorkItemProcessor:ProcessWorkItems(Boolean, Boolean) (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Misc/WorkItemProcessor.cs:362)
Pathfinding.WorkItemProcessor:ProcessWorkItemsForUpdate(Boolean) (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Misc/WorkItemProcessor.cs:416)
AstarPath:PerformBlockingActions(Boolean) (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/AstarPath.cs:904)
AstarPath:Update() (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/AstarPath.cs:887)

A few more seemingly random errors.

InvalidOperationException: A node in a RecastGraph contained a connection to a destroyed TriangleMeshNode.
Pathfinding.HierarchicalGraph+JobRecalculateComponents+<>c.<FindHierarchicalNodeChildren>b__12_0 (Pathfinding.GraphNode neighbour, Pathfinding.HierarchicalGraph+JobRecalculateComponents+Context& context) (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Pathfinding/HierarchicalGraph.cs:427)
Pathfinding.MeshNode.GetConnections[T] (Pathfinding.GraphNode+GetConnectionsWithData`1[T] action, T& data, System.Int32 connectionFilter) (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Nodes/GraphNode.cs:825)
Pathfinding.HierarchicalGraph+JobRecalculateComponents.FindHierarchicalNodeChildren (Pathfinding.HierarchicalGraph hGraph, System.Int32 hierarchicalNode, Pathfinding.GraphNode startNode) (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Pathfinding/HierarchicalGraph.cs:444)
Pathfinding.HierarchicalGraph+JobRecalculateComponents.Execute () (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Pathfinding/HierarchicalGraph.cs:537)
Unity.Jobs.IJobExtensions+JobStruct`1[T].Execute (T& data, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at <5879d8d225474494bcffdfe64965038e>:0)
Unity.Jobs.JobHandle:ScheduleBatchedJobsAndComplete(JobHandle&)
Unity.Jobs.JobHandle:Complete()
Pathfinding.HierarchicalGraph:RecalculateIfNecessary() (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Pathfinding/HierarchicalGraph.cs:564)
Pathfinding.WorkItemProcessor:EnsureValidFloodFill() (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Misc/WorkItemProcessor.cs:268)
Pathfinding.WorkItemProcessor:ProcessWorkItems(Boolean, Boolean) (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Misc/WorkItemProcessor.cs:362)
Pathfinding.WorkItemProcessor:ProcessWorkItemsForUpdate(Boolean) (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Misc/WorkItemProcessor.cs:416)
AstarPath:PerformBlockingActions(Boolean) (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/AstarPath.cs:904)
AstarPath:Update() (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/AstarPath.cs:887)

NullReferenceException: Object reference not set to an instance of an object
Pathfinding.HierarchicalGraph+JobRecalculateComponents.Execute () (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Pathfinding/HierarchicalGraph.cs:503)
Unity.Jobs.IJobExtensions+JobStruct`1[T].Execute (T& data, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at <5879d8d225474494bcffdfe64965038e>:0)
NullReferenceException: Object reference not set to an instance of an object
Pathfinding.NavmeshEdges+JobCalculateObstacles.CalculateObstacles (Pathfinding.HierarchicalGraph hGraph, System.Int32 hierarchicalNode, Pathfinding.Util.SlabAllocator`1[T] obstacleVertexGroups, Pathfinding.Util.SlabAllocator`1[T] obstacleVertices, Unity.Collections.NativeArray`1[T] obstacles, Unity.Collections.NativeList`1[T] edgesScratch) (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Misc/NavmeshEdges.cs:234)
Pathfinding.NavmeshEdges+JobCalculateObstacles.Execute (System.Int32 startIndex, System.Int32 count) (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Misc/NavmeshEdges.cs:157)
Unity.Jobs.IJobParallelForBatchExtensions+JobParallelForBatchProducer`1[T].Execute (T& jobData, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at ./Library/PackageCache/com.unity.collections@2.1.4/Unity.Collections/Jobs/IJobParallelForBatch.cs:58)

Hi

Thank you.
Can you consistently replicate these errors?

No, not really. When they do happen, it is always when I first load a level that has a* running in it.

If it is available my save system will fetch a saved .bytes file, or use the cache as a fallback, so I thought it might be to do with some kind of out of date reference in the cache/save file, but it persists unfortuantely.

Here is another one that I struggled to actually catch as it crashes unity entirely and I couldn’t read the error message:

AssertionException: Assertion failure. Values are equal.
Expected: -2 != -2
UnityEngine.Assertions.Assert.Fail (System.String message, System.String userMessage) (at <5879d8d225474494bcffdfe64965038e>:0)
UnityEngine.Assertions.Assert.AreNotEqual[T] (T expected, T actual, System.String message, System.Collections.Generic.IEqualityComparer`1[T] comparer) (at <5879d8d225474494bcffdfe64965038e>:0)
UnityEngine.Assertions.Assert.AreNotEqual[T] (T expected, T actual, System.String message) (at <5879d8d225474494bcffdfe64965038e>:0)
UnityEngine.Assertions.Assert.AreNotEqual (System.Int32 expected, System.Int32 actual) (at <5879d8d225474494bcffdfe64965038e>:0)
Pathfinding.HierarchicalGraph+JobRecalculateComponents.FindHierarchicalNodeChildren (Pathfinding.HierarchicalGraph hGraph, System.Int32 hierarchicalNode, Pathfinding.GraphNode startNode) (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Pathfinding/HierarchicalGraph.cs:450)
Pathfinding.HierarchicalGraph+JobRecalculateComponents.Execute () (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Pathfinding/HierarchicalGraph.cs:537)
Unity.Jobs.IJobExtensions+JobStruct`1[T].Execute (T& data, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at <5879d8d225474494bcffdfe64965038e>:0)

Any ideas on how to resolve this?

i think my players are having the same issues, heres the log if it helps at all:
Player.txt (87.1 KB)

@aron_granberg any ideas please?

EDIT: I managed to get the errors to stop by disabling a few GraphUpdateScene components I had which were loaded into the scene. Not ideal as i need then to dynamically update at runtime.

Hi

Would it be possible for you to share a scene in which you can replicate the errors in?

Sorry, I can’t. My project is a right mess at the moment, however after some further investigation I think I have figured out what the issue is was:

I had Entities at installed at v1.0.0-pre.47 from when I had A* 4.3.65. I updated to A* 4.3.90.

I then installed ‘Entities Graphics’. This has a dependency and pulls ‘Entities’ up to v1.0.16. The issue then starts to occur when my gameobjects containing GraphUpdateScene (with apply on start) components are added.

I have since rolled back to 4.3.68 and removed entities entirely and the issue has gone. I wonder if there is a safe version of entities I can use.

So you mean that with the older version of entities, and A* 4.3.90, the issue did not happen?

Just updated back to A* 4.3.90 with no entities installed and the issue is back unfortunately, so it possible an issue with the core jobs system in unity 2022.3.15f1 LTS?

The following errors occur when loading GraphUpdateScene components. I have pasted my manifest at the end if it helps

IndexOutOfRangeException: Index was outside the bounds of the array.
Pathfinding.Util.UnsafeSpan`1[T].get_Item (System.Int32 index) (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Collections/Span.cs:70)
Pathfinding.Graphs.Navmesh.NavmeshTile.GetVertex (System.Int32 index) (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Graphs/Navmesh/NavmeshTile.cs:80)
Pathfinding.NavmeshBase.GetVertex (System.Int32 index) (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Graphs/NavmeshBase.cs:183)
Pathfinding.TriangleMeshNode.GetVertices (Pathfinding.Int3& v0, Pathfinding.Int3& v1, Pathfinding.Int3& v2) (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Graphs/Nodes/TriangleMeshNode.cs:118)
Pathfinding.NavmeshEdges+JobCalculateObstacles.CalculateBoundingBox (Pathfinding.HierarchicalGraph hGraph, System.Int32 hierarchicalNode) (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Misc/NavmeshEdges.cs:179)
Pathfinding.NavmeshEdges+JobCalculateObstacles.Execute (System.Int32 startIndex, System.Int32 count) (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Misc/NavmeshEdges.cs:156)
Unity.Jobs.IJobParallelForBatchExtensions+JobParallelForBatchProducer`1[T].Execute (T& jobData, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at ./Library/PackageCache/com.unity.collections@2.1.4/Unity.Collections/Jobs/IJobParallelForBatch.cs:58)
Unity.Jobs.JobHandle:ScheduleBatchedJobsAndComplete(JobHandle&)
Unity.Jobs.JobHandle:Complete()
Pathfinding.HierarchicalGraph:RecalculateIfNecessary() (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Pathfinding/HierarchicalGraph.cs:564)
Pathfinding.WorkItemProcessor:EnsureValidFloodFill() (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Misc/WorkItemProcessor.cs:268)
Pathfinding.WorkItemProcessor:ProcessWorkItems(Boolean, Boolean) (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Misc/WorkItemProcessor.cs:362)
Pathfinding.WorkItemProcessor:ProcessWorkItemsForUpdate(Boolean) (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Misc/WorkItemProcessor.cs:416)
AstarPath:PerformBlockingActions(Boolean) (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/AstarPath.cs:904)
AstarPath:Update() (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/AstarPath.cs:887)


UnityException: GetOrCreateTrackerHandleImpl can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.
UnityEditor.Profiling.EditorPerformanceTracker.GetOrCreateTrackerHandle (System.String trackerName, System.Type context) (at <64861216782042de93237b5c061bff1b>:0)
UnityEditor.EventWithPerformanceTracker.GetPerformanceTrackerHandleForEvent (System.String scope, System.Delegate d) (at <64861216782042de93237b5c061bff1b>:0)
UnityEditor.EventWithPerformanceTracker`1+DelegateWithHandle[T].StartTrackerAt (System.Int32 idx, System.String scope) (at <64861216782042de93237b5c061bff1b>:0)
UnityEditor.EventWithPerformanceTracker`1+Enumerator[T].MoveNext () (at <64861216782042de93237b5c061bff1b>:0)
UnityEditor.EditorApplication.Internal_PauseStateChanged (UnityEditor.PauseState state) (at <64861216782042de93237b5c061bff1b>:0)
Unity.Jobs.JobHandle:ScheduleBatchedJobsAndComplete(JobHandle&)
Unity.Jobs.JobHandle:Complete()
Pathfinding.HierarchicalGraph:RecalculateIfNecessary() (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Pathfinding/HierarchicalGraph.cs:564)
Pathfinding.WorkItemProcessor:EnsureValidFloodFill() (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Misc/WorkItemProcessor.cs:268)
Pathfinding.WorkItemProcessor:ProcessWorkItems(Boolean, Boolean) (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Misc/WorkItemProcessor.cs:362)
Pathfinding.WorkItemProcessor:ProcessWorkItemsForUpdate(Boolean) (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/Misc/WorkItemProcessor.cs:416)
AstarPath:PerformBlockingActions(Boolean) (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/AstarPath.cs:904)
AstarPath:Update() (at ./Library/PackageCache/com.arongranberg.astar@4.3.90/Core/AstarPath.cs:887)
{
  "scopedRegistries": [
    {
      "name": "A* Pathfinding Project",
      "url": "https://arongranberg.com/packages/3f7f06aa636defdf165d9c53ade2b88163e647f418716/",
      "scopes": [
        "com.arongranberg.astar"
      ]
    }
  ],
  "dependencies": {
    "com.arongranberg.astar": "4.3.90",
    "com.unity.2d.sprite": "1.0.0",
    "com.unity.2d.tilemap": "1.0.0",
    "com.unity.2d.tilemap.extras": "3.1.2",
    "com.unity.addressables": "1.21.19",
    "com.unity.animation.rigging": "1.2.1",
    "com.unity.cinemachine": "2.9.7",
    "com.unity.collections": "2.1.4",
    "com.unity.ide.visualstudio": "2.0.22",
    "com.unity.mobile.android-logcat": "1.4.0",
    "com.unity.postprocessing": "3.2.2",
    "com.unity.render-pipelines.core": "14.0.9",
    "com.unity.render-pipelines.universal": "14.0.9",
    "com.unity.splines": "2.5.1",
    "com.unity.test-framework": "1.1.33",
    "com.unity.textmeshpro": "3.0.6",
    "com.unity.timeline": "1.7.6",
    "com.unity.ugui": "1.0.0",
    "com.unity.visualeffectgraph": "14.0.9",
    "com.unity.modules.ai": "1.0.0",
    "com.unity.modules.androidjni": "1.0.0",
    "com.unity.modules.animation": "1.0.0",
    "com.unity.modules.assetbundle": "1.0.0",
    "com.unity.modules.audio": "1.0.0",
    "com.unity.modules.cloth": "1.0.0",
    "com.unity.modules.director": "1.0.0",
    "com.unity.modules.imageconversion": "1.0.0",
    "com.unity.modules.imgui": "1.0.0",
    "com.unity.modules.jsonserialize": "1.0.0",
    "com.unity.modules.particlesystem": "1.0.0",
    "com.unity.modules.physics": "1.0.0",
    "com.unity.modules.physics2d": "1.0.0",
    "com.unity.modules.screencapture": "1.0.0",
    "com.unity.modules.terrain": "1.0.0",
    "com.unity.modules.terrainphysics": "1.0.0",
    "com.unity.modules.tilemap": "1.0.0",
    "com.unity.modules.ui": "1.0.0",
    "com.unity.modules.uielements": "1.0.0",
    "com.unity.modules.umbra": "1.0.0",
    "com.unity.modules.unityanalytics": "1.0.0",
    "com.unity.modules.unitywebrequest": "1.0.0",
    "com.unity.modules.unitywebrequestassetbundle": "1.0.0",
    "com.unity.modules.unitywebrequestaudio": "1.0.0",
    "com.unity.modules.unitywebrequesttexture": "1.0.0",
    "com.unity.modules.unitywebrequestwww": "1.0.0",
    "com.unity.modules.vehicles": "1.0.0",
    "com.unity.modules.video": "1.0.0",
    "com.unity.modules.vr": "1.0.0",
    "com.unity.modules.wind": "1.0.0",
    "com.unity.modules.xr": "1.0.0"
  }
}

Hi

I cannot replicate this. Is it possible for you to replicate this in any of the example scenes? (possibly with minor modifications)

Sure, I’ll do some experimenting and come back to you