Crash in Build - Poly2Tri

I received a report from a playtest where someone had a crash, and looking into the player log & crash dump, the crash occurs inside pathfinding code! It appears that somehow an IndexOutOfRange exception occurs in an array lookup in DelaunayTriangle.PointCWFrom(), see screenshot for call stack & (stripped) log.

A* pathfinding version: 4.3.46
Unity version: 2020.3.21f1

Additional A* usage details:

  • We’re using 2 recast graphs, mostly for 2 different sizes
  • We’re using RichAI primarily, but also a few ABPath.Construct() to measure distances
  • The level may have been reloaded a few times, but crash did not occur right before/after this, but during general gameplay.

Note that this isn’t a crash that occurs all the time or anything, we’ve been using the pathfinding tool in builds for a few months now and haven’t noticed any crashes related to it before.

Player.log.txt (10.7 KB)

The issue is very replicatable with or without Rich AI.

Turning off navmesh updates with:
AstarPath.active.navmeshUpdates.updateInterval = -1f;

will hide the issues. Which confirms that the issue is with the navmesh update system.

I posted more details in Crashes killing Unity When using Navmesh Cuts with Recast

So in summary if two NavMesh cuts have overlapping vertices. And there are many navmesh cuts with this scenario we end up with the stack overflow crash in Pathfinding.Poly2Tri

If we ensure that no two NavMesh cuts have overlapping vertices then the crash never happens.