- A* version: 5.2.4
- Unity version: 2022.3.39
Super randomly, when instantiating an object with a navmesh cut on it, the area that is ‘cut’ is magnitudes larger and removes a large portion of the graph.
I am unable to repro it at all - it just happens randomly. It can happen as I start the game and instantiate an object. Wasn’t able to find any similar questions in the forums either.
Any idea what I should be looking for?

It happened! The blue outlines are the size of the navmesh cut.
This error follows it:
InvalidCastException: Specified cast is not valid.
(wrapper castclass) System.Object.__castclass_with_cache(object,intptr,intptr)
System.Runtime.InteropServices.Marshal.GetDelegateForFunctionPointer[TDelegate] (System.IntPtr ptr) (at <c0b7b90d34a54066a7234dad69255116>:0)
Unity.Burst.FunctionPointer`1[T].get_Invoke () (at ./Library/PackageCache/com.unity.burst@1.8.17/Runtime/FunctionPointer.cs:68)
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 ./Packages/com.arongranberg.astar/Graphs/Navmesh/TileHandler.cs:579)
Pathfinding.Graphs.Navmesh.TileHandler+CutTiles_00000B4A$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 <aa2b8079e88b4ab99dc9a33eed34d7bb>: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 ./Packages/com.arongranberg.astar/Graphs/Navmesh/TileHandler.cs:433)
Pathfinding.Graphs.Navmesh.TileCutter+JobCutTiles.Execute () (at ./Packages/com.arongranberg.astar/Graphs/Navmesh/TileHandler.cs:266)
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 <2d8783c7af0442318483a199a473c55b>:0)
Wow that’s a fun glitch- very fortunate you were able to get the error and a screenshot! I’ll let @aron_granberg know about this one. Any other information you can provide about your set up would be helpful as well! Graph and NavmeshCut settings and info- stuff like that 
1 Like
NavmeshCut settings are completely default. I have two graphs and only one of which the NavMeshCut does not intersect. Everything else is pretty much default!

This sounds like it could potentially be a burst bug. Could you try to see if you can still replicate it using a newer version of Unity?
1 Like
Sorry for the delay! I upgraded to Unity 6 and so far it hasn’t happened despite several attempts at repro which is good news! I will let you know if that changes.
Thanks Aron!
1 Like
Bad news this is happening again.
Unity 6, 5.2.8 and burst 1.8.18
Only happens after the project is open for a while
Has anything changed in your setup since it wasn’t working, any package updates? Or mostly identical? At any rate I’ll tag @aron_granberg back on this.
Nothing I can think of really… its also possible that its been happening and I haven’t noticed. There’s an InvalidCastException error that gets thrown happens regularly with Runtime content manager and its a well known bug so my brain tunes it out. Unfortunately, the navmesh bug throws the same error.
Also the error gets thrown regardless if the burst compiler is on or not
Updated asset to the newest version - still happening occasionally
Gotcha, sorry you’re having this issue
Aron will check this out when he has the availability- for now, if you find anything out new let us know! 
This is, as far as I know, a Unity bug that can happen when, I think, Unity hasn’t recompiled the burst jobs yet. I have no influence over it, I’m afraid, and I know of no workarounds. Restarting the game typically solves it.
1 Like
Yep I figured as much
Thanks!