Multithreaded Pathfinding on iOS


There is a crash or failure when I set the thread count to anything but None. The failure only happens when I run my application on an iOS device and call UpdateGraphNoBlock. I get an ‘Array out of bounds’ message.

Please help.


I would need a bit more information.
What version are you using? What exact error message are you getting? What build settings are you using? IL2CPP?

Unity 4.7.0f1-Standard Version A*Path

We are using IL2CPP


SynchronizationLockException: Object is not locked.
at System.Threading.Monitor.Exit (System.Object obj) [0x00000] in :0
at AstarPath.RegisterSafeUpdate (.OnVoidDelegate callback, Boolean threadSafe) [0x00000] in :0
at AstarPath.QueueGraphUpdates () [0x00000] in :0
at AstarPath+c__Iterator6.MoveNext () [0x00000] in :0


There is currently one version on the Asset Store (3.7), updating pending review. One version (3.8) that was released on this website a few days ago, and two versions before that (3.7.4 and the 3.7.5 beta) also released on this website.

It does unfortunately look like a Unity/ILCPP bug. The only lock code in that method is

lock (safeUpdateLock) {
	OnThreadSafeCallback += callback;

And it’s hard to see how that should ever fail with that exception.
Do you think you can try to tweak IL2CPP settings a bit to see if you can get rid of it?
Also, is this exception repeatable or do you only get it once in a while?

Also. The exception you posted is not an array out of bounds exception.

Thanks for the quick response.

I’m using 3.7.4

The exception happens every time I call the method. It is a tower defense game, so I cannot place towers with multithreaded pathfinding.

What IL2CPP settings would you recommend I change?


Not sure exactly what would affect it, but from what I remember there is some sort of dev/release toggle in the build settings. Maybe try that one.