Bug? RecastMeshObj bounds access for dead objects

Hi,

we are using the latest Astar beta version and have a yet rare problem which kills the game (session) for our players (since the complete pathfinding dies and the log is spammed with exceptions after that). We are unable to reproduce it right now. But maybe there is an idea out what causes the issue.

Here is the stacktrace (after that many more exceptions are incoming, but this is the first and triggering one I guess):

NullReferenceException
  at (wrapper managed-to-native) UnityEngine.Component.GetComponentFastPath(UnityEngine.Component,System.Type,intptr)
  at UnityEngine.Component.GetComponent[T] () [0x00021] in <9ad13387a0344bd38d4219986dee29f5>:0 
  at Pathfinding.RecastMeshObj.RecalculateBounds () [0x00000] in <2e0e17de775e4ae9ba35f56a3b6f108e>:0 
  at Pathfinding.RecastMeshObj.GetBounds () [0x00008] in <2e0e17de775e4ae9ba35f56a3b6f108e>:0 
  at Pathfinding.RecastMeshObj.GetAllInBounds (System.Collections.Generic.List`1[T] buffer, UnityEngine.Bounds bounds) [0x000a9] in <2e0e17de775e4ae9ba35f56a3b6f108e>:0 
  at Pathfinding.Recast.RecastMeshGathererBurst.CollectRecastMeshObjs () [0x00006] in <2e0e17de775e4ae9ba35f56a3b6f108e>:0 
  at Pathfinding.RecastGraph+BuildTilesSettings.CollectMeshes () [0x000a3] in <2e0e17de775e4ae9ba35f56a3b6f108e>:0 
  at Pathfinding.RecastGraph+BuildTilesSettings.Schedule (Pathfinding.Jobs.DisposeArena arena) [0x00024] in <2e0e17de775e4ae9ba35f56a3b6f108e>:0 
  at Pathfinding.RecastGraph+<ScanAllTilesBurst>d__53.MoveNext () [0x00086] in <2e0e17de775e4ae9ba35f56a3b6f108e>:0 
  at Pathfinding.RecastGraph+<ScanInternal>d__48.MoveNext () [0x00091] in <2e0e17de775e4ae9ba35f56a3b6f108e>:0 
  at AstarPath+<ScanGraph>d__145.MoveNext () [0x00124] in <2e0e17de775e4ae9ba35f56a3b6f108e>:0 
  at AstarPath+<ScanInternal>d__144.MoveNext () [0x0024b] in <2e0e17de775e4ae9ba35f56a3b6f108e>:0 
  at AstarPath.Scan (Pathfinding.NavGraph[] graphsToScan) [0x00031] in <2e0e17de775e4ae9ba35f56a3b6f108e>:0 
  at AstarScanManager+<scanningRoutine>d__26.MoveNext () [0x00074] in <828dd42d04914c8aa4960029bd0ea9a3>:0 
  at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00026] in <9ad13387a0344bd38d4219986dee29f5>:0 

I reviewed the RecastMeshObj script a bit and followed the stacktrace. Since the trace is not traveling via .QueryInBounds we are talking about dynamic recast mesh obj GetBounds access here. And this means that somehow a dynamic mesh obj didn’t deregister from the dynamicMeshObj list. Or there is a race condition between OnDisable (which is the only list removal point?) and the rescanning (somehow?).

Maybe an additional hint: We have two different scenes with different Astar objects. BUT only one scene is loaded at a time (SceneManager.LoadSceneAsync(sceneName) → LoadSceneMode is Single).

I’d love to provide better information or even a repro case, but I had no luck at all.

Best regards
Bennet

Hmmm, are you possibly setting the dynamic field at runtime?