- Astar Pro 5.3.4
- Unity 2022.3.57f1
Getting an error in some cases with navmesh cuts that end up cutting the navmesh from their top or bottom faces.
This happens due to a very big max step height (7m) in my case, but can probably happen with normal slopes.
The error is easily reproduced and causes the triangulation of a tile to fail, leaving no navmesh behind for the tile in question, along with every other tile that were going to be updated with a work item as it interrupts the ProcessWorkItem
function.
This means that if the error happens while scanning (even outside playmode) or during runtime when updating using GraphUpdateObjects
, you can end up with many missing tiles!
As a side effect from the uncaught exception, memory leaks occur, the more work items were enqueued, the more leaks!
(Only logs them on domain reload if they happened before, added a shortcut to force a domain reload with Ctrl+Alt+R, or Tools > Domain Manual Refresh)
Here is a reproduction project:
Start the project, the objects are activated on a timer, specific ones trigger the error.
If you tick “Set Activated All” on the either/both of the “Error Triggerers” objects
Then start play mode, the error causes many extra tiles to also be missing.
(Note there is some variance in which tiles completes and which is missing when comparing different play mode sessions, probably due to parallelization)
If you stay outside of play mode and trigger a scan with the problematic objects active, the error happens during the scan, preventing it from completing and leaving all tiles after the first problem one missing.
Here is the stack trace
IndexOutOfRangeException: Index was outside the bounds of the array.
Pathfinding.Graphs.Navmesh.TileHandler.ClipAgainstHalfPlane (Pathfinding.Collections.UnsafeSpan`1[T] clipIn, Unity.Collections.NativeList`1[T] clipOut, Pathfinding.Graphs.Navmesh.TileHandler+Point64Wrapper a, Pathfinding.Graphs.Navmesh.TileHandler+Point64Wrapper b) (at ./Library/PackageCache/com.arongranberg.astar@5.3.4/Graphs/Navmesh/TileHandler.cs:1213)
Pathfinding.Graphs.Navmesh.TileHandler.ClipAgainstHorizontalHalfPlane (Pathfinding.Collections.UnsafeSpan`1[Pathfinding.Graphs.Navmesh.TileHandler+Point64Wrapper]& contourVertices, Unity.Collections.NativeList`1[T] scratchVertices, System.Int32 h, Pathfinding.Int3 a, Pathfinding.Int3 b, Pathfinding.Int3 c, System.Boolean preserveBelow) (at ./Library/PackageCache/com.arongranberg.astar@5.3.4/Graphs/Navmesh/TileHandler.cs:1239)
Pathfinding.Graphs.Navmesh.TileHandler.CutTiles$BurstManaged (Pathfinding.Collections.UnsafeSpan`1[Unity.Collections.LowLevel.Unsafe.UnsafeList`1[Pathfinding.Collections.UnsafeSpan`1[Pathfinding.Int3]]]& tileVertices, Pathfinding.Collections.UnsafeSpan`1[Unity.Collections.LowLevel.Unsafe.UnsafeList`1[Pathfinding.Collections.UnsafeSpan`1[System.Int32]]]& tileTriangles, Pathfinding.Collections.UnsafeSpan`1[Unity.Collections.LowLevel.Unsafe.UnsafeList`1[Pathfinding.Collections.UnsafeSpan`1[System.Int32]]]& tileTags, UnityEngine.Vector2Int& tileSize, Pathfinding.Graphs.Navmesh.TileHandler+CutCollection& cutCollection, Pathfinding.Collections.UnsafeSpan`1[Pathfinding.Graphs.Navmesh.TileMesh+TileMeshUnsafe]& output, Unity.Collections.Allocator allocator) (at ./Library/PackageCache/com.arongranberg.astar@5.3.4/Graphs/Navmesh/TileHandler.cs:690)
Pathfinding.Graphs.Navmesh.TileHandler+CutTiles_00000B52$BurstDirectCall.Invoke (Pathfinding.Collections.UnsafeSpan`1[Unity.Collections.LowLevel.Unsafe.UnsafeList`1[Pathfinding.Collections.UnsafeSpan`1[Pathfinding.Int3]]]& tileVertices, Pathfinding.Collections.UnsafeSpan`1[Unity.Collections.LowLevel.Unsafe.UnsafeList`1[Pathfinding.Collections.UnsafeSpan`1[System.Int32]]]& tileTriangles, Pathfinding.Collections.UnsafeSpan`1[Unity.Collections.LowLevel.Unsafe.UnsafeList`1[Pathfinding.Collections.UnsafeSpan`1[System.Int32]]]& tileTags, UnityEngine.Vector2Int& tileSize, Pathfinding.Graphs.Navmesh.TileHandler+CutCollection& cutCollection, Pathfinding.Collections.UnsafeSpan`1[Pathfinding.Graphs.Navmesh.TileMesh+TileMeshUnsafe]& output, Unity.Collections.Allocator allocator) (at <9efc8341c282458db93ecd085c338482>:0)
Pathfinding.Graphs.Navmesh.TileHandler.CutTiles (Pathfinding.Collections.UnsafeSpan`1[Unity.Collections.LowLevel.Unsafe.UnsafeList`1[Pathfinding.Collections.UnsafeSpan`1[Pathfinding.Int3]]]& tileVertices, Pathfinding.Collections.UnsafeSpan`1[Unity.Collections.LowLevel.Unsafe.UnsafeList`1[Pathfinding.Collections.UnsafeSpan`1[System.Int32]]]& tileTriangles, Pathfinding.Collections.UnsafeSpan`1[Unity.Collections.LowLevel.Unsafe.UnsafeList`1[Pathfinding.Collections.UnsafeSpan`1[System.Int32]]]& tileTags, UnityEngine.Vector2Int& tileSize, Pathfinding.Graphs.Navmesh.TileHandler+CutCollection& cutCollection, Pathfinding.Collections.UnsafeSpan`1[Pathfinding.Graphs.Navmesh.TileMesh+TileMeshUnsafe]& output, Unity.Collections.Allocator allocator) (at <9efc8341c282458db93ecd085c338482>:0)
Pathfinding.Graphs.Navmesh.TileCutter+JobCutTiles.Execute () (at ./Library/PackageCache/com.arongranberg.astar@5.3.4/Graphs/Navmesh/TileHandler.cs:267)
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 <c3dca0e61d5249b79ac00f7b2c7a01ef>:0)
Sometimes the trace has an extra portion after the shared section above
Case 1 - From AstarPath:Update()
Unity.Jobs.JobHandle:ScheduleBatchedJobsAndComplete(JobHandle&)
Unity.Jobs.JobHandle:Complete()
Pathfinding.Sync.Promise`1:Complete() (at ./Library/PackageCache/com.arongranberg.astar@5.3.4/Core/Sync/Promise.cs:39)
Pathfinding.Graphs.Navmesh.NavmeshUpdateSettings:ReloadDirtyTilesImmediately() (at ./Library/PackageCache/com.arongranberg.astar@5.3.4/Navmesh/NavmeshUpdates.cs:274)
Pathfinding.Graphs.Navmesh.NavmeshUpdateSettings:<ScheduleDirtyTilesReload>b__30_0(IWorkItemContext) (at ./Library/PackageCache/com.arongranberg.astar@5.3.4/Navmesh/NavmeshUpdates.cs:266)
Pathfinding.WorkItemProcessor:ProcessWorkItems(Boolean, Boolean) (at ./Library/PackageCache/com.arongranberg.astar@5.3.4/Core/Misc/WorkItemProcessor.cs:328)
Pathfinding.WorkItemProcessor:ProcessWorkItemsForUpdate(Boolean) (at ./Library/PackageCache/com.arongranberg.astar@5.3.4/Core/Misc/WorkItemProcessor.cs:423)
AstarPath:PerformBlockingActions(Boolean) (at ./Library/PackageCache/com.arongranberg.astar@5.3.4/Core/AstarPath.cs:875)
AstarPath:Update() (at ./Library/PackageCache/com.arongranberg.astar@5.3.4/Core/AstarPath.cs:858)
Case 2 - From ALINE
Unity.Jobs.JobHandle:ScheduleBatchedJobsAndComplete(JobHandle&)
Unity.Jobs.JobHandle:Complete()
Pathfinding.Drawing.ProcessedBuilderData:BuildMeshes(DrawingData) (at ./Library/PackageCache/com.arongranberg.astar@5.3.4/Drawing/DrawingData.cs:358)
Pathfinding.Drawing.ProcessedBuilderDataContainer:SubmitMeshes(DrawingData, Camera, Int32, Boolean, Boolean) (at ./Library/PackageCache/com.arongranberg.astar@5.3.4/Drawing/DrawingData.cs:924)
Pathfinding.Drawing.DrawingData:Render(Camera, Boolean, CommandBufferWrapper, Boolean) (at ./Library/PackageCache/com.arongranberg.astar@5.3.4/Drawing/DrawingData.cs:1611)
Pathfinding.Drawing.DrawingManager:Submit(Camera, CommandBufferWrapper, Boolean, Boolean) (at ./Library/PackageCache/com.arongranberg.astar@5.3.4/Drawing/DrawingManager.cs:712)
Pathfinding.Drawing.DrawingManager:SubmitFrame(Camera, CommandBufferWrapper, Boolean) (at ./Library/PackageCache/com.arongranberg.astar@5.3.4/Drawing/DrawingManager.cs:554)
Pathfinding.Drawing.AlineHDRPCustomPass:Execute(CustomPassContext) (at ./Library/PackageCache/com.arongranberg.astar@5.3.4/Drawing/AlineHDRPCustomPass.cs:34)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
When the error happens after the initial loading when starting play mode, an extra error is logged:
Error during triangulation
Error during triangulation
UnityEngine.Debug:LogError (object)
Pathfinding.Graphs.Navmesh.TileHandler:CutTiles$BurstManaged (Pathfinding.Collections.UnsafeSpan`1<Unity.Collections.LowLevel.Unsafe.UnsafeList`1<Pathfinding.Collections.UnsafeSpan`1<Pathfinding.Int3>>>&,Pathfinding.Collections.UnsafeSpan`1<Unity.Collections.LowLevel.Unsafe.UnsafeList`1<Pathfinding.Collections.UnsafeSpan`1<int>>>&,Pathfinding.Collections.UnsafeSpan`1<Unity.Collections.LowLevel.Unsafe.UnsafeList`1<Pathfinding.Collections.UnsafeSpan`1<int>>>&,UnityEngine.Vector2Int&,Pathfinding.Graphs.Navmesh.TileHandler/CutCollection&,Pathfinding.Collections.UnsafeSpan`1<Pathfinding.Graphs.Navmesh.TileMesh/TileMeshUnsafe>&,Unity.Collections.Allocator) (at ./Packages/com.arongranberg.astar/Graphs/Navmesh/TileHandler.cs:828)
Pathfinding.Graphs.Navmesh.TileHandler/Pathfinding.Graphs.Navmesh.CutTiles_00000AE3$BurstDirectCall:Invoke (Pathfinding.Collections.UnsafeSpan`1<Unity.Collections.LowLevel.Unsafe.UnsafeList`1<Pathfinding.Collections.UnsafeSpan`1<Pathfinding.Int3>>>&,Pathfinding.Collections.UnsafeSpan`1<Unity.Collections.LowLevel.Unsafe.UnsafeList`1<Pathfinding.Collections.UnsafeSpan`1<int>>>&,Pathfinding.Collections.UnsafeSpan`1<Unity.Collections.LowLevel.Unsafe.UnsafeList`1<Pathfinding.Collections.UnsafeSpan`1<int>>>&,UnityEngine.Vector2Int&,Pathfinding.Graphs.Navmesh.TileHandler/CutCollection&,Pathfinding.Collections.UnsafeSpan`1<Pathfinding.Graphs.Navmesh.TileMesh/TileMeshUnsafe>&,Unity.Collections.Allocator)
Pathfinding.Graphs.Navmesh.TileHandler:CutTiles (Pathfinding.Collections.UnsafeSpan`1<Unity.Collections.LowLevel.Unsafe.UnsafeList`1<Pathfinding.Collections.UnsafeSpan`1<Pathfinding.Int3>>>&,Pathfinding.Collections.UnsafeSpan`1<Unity.Collections.LowLevel.Unsafe.UnsafeList`1<Pathfinding.Collections.UnsafeSpan`1<int>>>&,Pathfinding.Collections.UnsafeSpan`1<Unity.Collections.LowLevel.Unsafe.UnsafeList`1<Pathfinding.Collections.UnsafeSpan`1<int>>>&,UnityEngine.Vector2Int&,Pathfinding.Graphs.Navmesh.TileHandler/CutCollection&,Pathfinding.Collections.UnsafeSpan`1<Pathfinding.Graphs.Navmesh.TileMesh/TileMeshUnsafe>&,Unity.Collections.Allocator) (at ./Packages/com.arongranberg.astar/Graphs/Navmesh/TileHandler.cs:527)
Pathfinding.Graphs.Navmesh.TileCutter/JobCutTiles:Execute () (at ./Packages/com.arongranberg.astar/Graphs/Navmesh/TileHandler.cs:267)
Unity.Jobs.IJobExtensions/JobStruct`1<Pathfinding.Graphs.Navmesh.TileCutter/JobCutTiles>:Execute (Pathfinding.Graphs.Navmesh.TileCutter/JobCutTiles&,intptr,intptr,Unity.Jobs.LowLevel.Unsafe.JobRanges&,int)
Unity.Jobs.JobHandle:Complete ()
Pathfinding.Sync.Promise`1<Pathfinding.Graphs.Navmesh.TileCutter/TileCutterOutput>:Complete () (at ./Packages/com.arongranberg.astar/Core/Sync/Promise.cs:39)
Pathfinding.Graphs.Navmesh.NavmeshUpdates/NavmeshUpdateSettings:ReloadDirtyTilesImmediately () (at ./Packages/com.arongranberg.astar/Navmesh/NavmeshUpdates.cs:274)
Pathfinding.Graphs.Navmesh.NavmeshUpdates/NavmeshUpdateSettings:<ScheduleDirtyTilesReload>b__30_0 (Pathfinding.IWorkItemContext) (at ./Packages/com.arongranberg.astar/Navmesh/NavmeshUpdates.cs:266)
Pathfinding.WorkItemProcessor:ProcessWorkItems (bool,bool) (at ./Packages/com.arongranberg.astar/Core/Misc/WorkItemProcessor.cs:328)
Pathfinding.WorkItemProcessor:ProcessWorkItemsForUpdate (bool) (at ./Packages/com.arongranberg.astar/Core/Misc/WorkItemProcessor.cs:423)
AstarPath:PerformBlockingActions (bool) (at ./Packages/com.arongranberg.astar/Core/AstarPath.cs:875)
AstarPath:Update () (at ./Packages/com.arongranberg.astar/Core/AstarPath.cs:858)