NullReferenceException: Object reference not set to an instance of an object

I am sometimes getting this exception :

NullReferenceException: Object reference not set to an instance of an object
Pathfinding.Poly2Tri.DTSweep.FinalizationPolygon (Pathfinding.Poly2Tri.DTSweepContext tcx) (at <07aca9e84ffe412bbfb50d0962eb64f2>:0)
Pathfinding.Poly2Tri.DTSweep.Triangulate (Pathfinding.Poly2Tri.DTSweepContext tcx) (at <07aca9e84ffe412bbfb50d0962eb64f2>:0)
Pathfinding.Poly2Tri.P2T.Triangulate (Pathfinding.Poly2Tri.TriangulationContext tcx) (at <07aca9e84ffe412bbfb50d0962eb64f2>:0)
Pathfinding.Poly2Tri.P2T.Triangulate (Pathfinding.Poly2Tri.TriangulationAlgorithm algorithm, Pathfinding.Poly2Tri.Triangulatable t) (at <07aca9e84ffe412bbfb50d0962eb64f2>:0)
Pathfinding.Poly2Tri.P2T.Triangulate (Pathfinding.Poly2Tri.Polygon p) (at <07aca9e84ffe412bbfb50d0962eb64f2>:0)
Pathfinding.Graphs.Navmesh.TileHandler.CutPoly (Pathfinding.Int3[] verts, System.Int32[] tris, Pathfinding.Int3[] extraShape, Pathfinding.Util.GraphTransform graphTransform, Pathfinding.IntRect tiles, Pathfinding.Graphs.Navmesh.TileHandler+CutMode mode, System.Int32 perturbate) (at ./Library/PackageCache/com.arongranberg.astar@5.0.9/Graphs/Navmesh/TileHandler.cs:714)
Pathfinding.Graphs.Navmesh.TileHandler+<>c__DisplayClass42_0.b__0 (Pathfinding.IWorkItemContext context, System.Boolean force) (at ./Library/PackageCache/com.arongranberg.astar@5.0.9/Graphs/Navmesh/TileHandler.cs:1199)
Pathfinding.WorkItemProcessor.ProcessWorkItems (System.Boolean force, System.Boolean sendEvents) (at ./Library/PackageCache/com.arongranberg.astar@5.0.9/Core/Misc/WorkItemProcessor.cs:339)
Pathfinding.WorkItemProcessor.ProcessWorkItemsForUpdate (System.Boolean force) (at ./Library/PackageCache/com.arongranberg.astar@5.0.9/Core/Misc/WorkItemProcessor.cs:416)
AstarPath.PerformBlockingActions (System.Boolean force) (at ./Library/PackageCache/com.arongranberg.astar@5.0.9/Core/AstarPath.cs:895)
AstarPath.FlushWorkItems () (at ./Library/PackageCache/com.arongranberg.astar@5.0.9/Core/AstarPath.cs:1125)

Any input on this ? It randomly happens. After adding Cuts in geoms and few links, we are calling

AstarPath.active.navmeshUpdates.ForceUpdate();
AstarPath.active.FlushGraphUpdates();
AstarPath.active.FlushWorkItems();

which cause the exception…

Best

Hi

I think this is sadly a bug in a 3rd party library that I’m using. I am in the process of replacing that library, though, as it’s caused so many problems over the years. I don’t think I’ve seen this particular exception before, though.

This is a blocking issue for us. Is it quite different from v4.0 or should get the same behavior on this part ?
I will check if we can add cuts diferently, to find a workaround on this random error. It seems that pathfinding is no more working after getting it, but I will check if it can catched in some way.

Best

Also, I am getting this kind of errors :

PointOnEdgeException, perturbating vertices slightly.
This is usually fine. It happens sometimes because of rounding errors. Cutting will be retried a few more times.

Is it possible to catch this exception to avoid invalid mesh ? I am no more able to find closest node on mesh after this kind of issue happens.

Best

This exception in particular is already caught. What it does then is that it re-tries cutting with a slight random offset. This is to avoid edge cases that the 3rd party library handles badly, like a vertex touching an edge of the navmesh or another cut exactly. If this failed, you would instead see a message like Too many perturbations aborting. If you don’t, then things should have completed successfully. Not sure why you cannot find the closest node on the navmesh? Do you have any more details about that.

This part hasn’t changed significantly in v5. You’d get the same error.