[4.2.17] Multithreading + graph unloading causes exceptions on some IOS devices

Hi, there’s an issue with graph unloading + multithreading.

If application unloads NavGraph while multithreaded PathProcessor is running, it will cause FloodPath.Initialize to fail with “Index out of bounds” exception. This does not happen on all devices due to multithreading nature (e.g. 2 out of 6).

For example via AstarData.RemoveGraph(NavGraph graph);

As far as I understood, there isn’t a proper PathNode for the GraphNode while attempting to fetch in PathHandler.GetPathNode. (Since all nodes has been unloaded)

Is there a way to check if multithreaded pathfinding is still running to delay graph unload?
I’ve made a temporary workaround to fix exceptions and its almost working, but I’d like to keep package changes to the minimum for future compatibility.

Think I found what’s proper way of unloading graphs.
Something like:

var lock = AstarPath.PausePathfinding();
// Perform graph unload / load
lock.Release();

Need to test it though.

Hi

Hmm, I don’t think this is due to multithreading (calling RemoveGraph already pauses pathfinding), but instead due to the fact that the FloodPath is queued, the graph is removed, and then when it starts calculating the graph doesn’t exist any more.

I’ve added some additional error checking to the FloodPath code now that should just make the path fail if this happens. It will be included in a future update.

1 Like