IndexOutOfRangeException

I have these two errors on Android. What could be causing them?

Message: IndexOutOfRangeException: Index was outside the bounds of the array.
Exception: IndexOutOfRangeException: Index was outside the bounds of the array.
	at Pathfinding.HierarchicalGraph+JobRecalculateComponents.RemoveHierarchicalNode(<00000000000000000000000000000000>)
	at Pathfinding.HierarchicalGraph+JobRecalculateComponents.RemoveHierarchicalNode(<00000000000000000000000000000000>)
	at Pathfinding.HierarchicalGraph+JobRecalculateComponents.Execute(<00000000000000000000000000000000>)
	at Pathfinding.HierarchicalGraph.RecalculateIfNecessary(<00000000000000000000000000000000>)
	at Pathfinding.WorkItemProcessor.ProcessWorkItems(<00000000000000000000000000000000>)
	at AstarPath.PerformBlockingActions(<00000000000000000000000000000000>)
	at AstarPath.Update(<00000000000000000000000000000000>)
	at Pathfinding.HierarchicalGraph.RecalculateIfNecessary(Unknown Source)
	at Pathfinding.WorkItemProcessor.ProcessWorkItems(Unknown Source)
	at AstarPath.PerformBlockingActions(Unknown Source)
	at AstarPath.Update(Unknown Source)
Reported at:
Message: IndexOutOfRangeException: Index was outside the bounds of the array.
Exception: IndexOutOfRangeException: Index was outside the bounds of the array.
	at Pathfinding.HierarchicalGraph+JobRecalculateComponents.FloodFill(<00000000000000000000000000000000>)
	at Pathfinding.HierarchicalGraph+JobRecalculateComponents.Execute(<00000000000000000000000000000000>)
	at Pathfinding.HierarchicalGraph.RecalculateIfNecessary(<00000000000000000000000000000000>)
	at Pathfinding.WorkItemProcessor.ProcessWorkItems(<00000000000000000000000000000000>)
	at AstarPath.PerformBlockingActions(<00000000000000000000000000000000>)
	at AstarPath.Update(<00000000000000000000000000000000>)
	at Pathfinding.HierarchicalGraph.RecalculateIfNecessary(Unknown Source)
	at Pathfinding.WorkItemProcessor.ProcessWorkItems(Unknown Source)
	at AstarPath.PerformBlockingActions(Unknown Source)
	at AstarPath.Update(Unknown Source)
Reported at:

Hi

Which version of the package are you using?

I use A* Pathfinding Project v5.0.9

Interesting. Does it only happen on android, or can you replicate it in the editor too?

Only Android. We found it after updating the asset to version 5.0.5
Unity 2022.3.22f1

Can you reliably replicate this? How often does it happen?

Approximately 1% of players (~100 players per week). We can’t reproduce it, we see it only in production :frowning:

Hmm. Sounds incredibly hard to debug, I’m afraid. I think this is a multithreading race condition, but without being able to reproduce it at all, it’s incredibly hard to track down.

Hello, have you figured out how to fix this?
I also have the same problem

09-25 13:50:59.773 10085 10825 E Unity : IndexOutOfRangeException: Index was outside the bounds of the array.
09-25 13:50:59.773 10085 10825 E Unity : at Pathfinding.HierarchicalGraph+JobRecalculateComponents.FloodFill (Pathfinding.HierarchicalGraph hGraph) [0x00000] in <00000000000000000000000000000000>:0
09-25 13:50:59.773 10085 10825 E Unity : at Pathfinding.HierarchicalGraph+JobRecalculateComponents.Execute () [0x00000] in <00000000000000000000000000000000>:0
09-25 13:50:59.773 10085 10825 E Unity : at Pathfinding.WorkItemProcessor.EnsureValidFloodFill () [0x00000] in <00000000000000000000000000000000>:0
09-25 13:50:59.773 10085 10825 E Unity : at Pathfinding.WorkItemProcessor.ProcessWorkItems (System.Boolean force, System.Boolean sendEvents) [0x00000] in <00000000000000000000000000000000>:0
09-25 13:50:59.773 10085 10825 E Unity : at AstarPath.PerformBlockingActions (System.Boolean force) [0x00000] in <00000000000000000000000000000000>:0
09-25 13:50:59.773 10085 10825 E Unity : at AstarPath.Update () [0x00000] in <00000000000000000000000000000000>:0
09-25 13:50:59.773 10085 10825 E Unity : Pathfinding.WorkItemProcessor:EnsureValidFloodFill()
09-25 13:50:59.773 10085 10825 E Unity : Pathfinding.WorkItemProcessor:ProcessWorkItems(Boolean, Boolean)
09-25 13:50:59.773 10085 10825 E Unity : AstarPath:PerformBlockingActions(Boolean)
09-25 13:50:59.773 10085 10825 E Unity : AstarPath:Update()

We can reliably reproduce this on a specific device: OnePlus 10R 5G. Tested with these devices: Galaxy A32, OnePlus 10R, iPhone SE2, Galaxy S24 and only OnePlus got the problem.
I can’t reproduce it on Editor…
For some reason I feel like it’s because I disabled AIPath (AIPath.enabled = false) abruptly and this happened. I’m not entirely sure about this but I did fix one problem related to this when I want to disable AIPath, I fixed it by doing AIPath.SetPath(null) and also turning off RVOController.

Context: I use Recast Graph and NavmeshCut on player when attacking and turn it off if not attacking. My monsters just use normal RVO no NavmeshCut. Not sure if this helps.
A Star version 5.1.6

Additionally I also got this crash with this log:

09-25 14:32:47.691 11728 11798 E Unity : IndexOutOfRangeException: Index was outside the bounds of the array.
09-25 14:32:47.691 11728 11798 E Unity : at Pathfinding.HierarchicalGraph+JobRecalculateComponents.FloodFill (Pathfinding.HierarchicalGraph hGraph) [0x00000] in <00000000000000000000000000000000>:0
09-25 14:32:47.691 11728 11798 E Unity : at Pathfinding.HierarchicalGraph+JobRecalculateComponents.Execute () [0x00000] in <00000000000000000000000000000000>:0
09-25 14:32:47.691 11728 11798 E Unity :
09-25 14:32:47.711 11728 11797 E Unity : Exception: SlabAllocator cannot allocate more than MaxAllocationSize elements.
09-25 14:32:47.711 11728 11797 E Unity : at Pathfinding.Util.SlabAllocator1[T].ElementsToSizeIndex (System.Int32 nElements) [0x00000] in <00000000000000000000000000000000>:0 09-25 14:32:47.711 11728 11797 E Unity : at Pathfinding.Util.SlabAllocator1[T].Realloc (System.Int32& allocatedIndex, System.Int32 nElements) [0x00000] in <00000000000000000000000000000000>:0
09-25 14:32:47.711 11728 11797 E Unity : at Pathfinding.Util.SlabAllocator1+List[T].RemoveAt (System.Int32 index) [0x00000] in <00000000000000000000000000000000>:0 09-25 14:32:47.711 11728 11797 E Unity : at Pathfinding.HierarchicalGraph+JobRecalculateComponents.RemoveHierarchicalNode (Pathfinding.HierarchicalGraph hGraph, System.Int32 hierarchicalNode, System.Boolean removeAdjacentSmallNodes) [0x00000] in <00000000000000000000000000000000>:0 09-25 14:32:47.711 11728 11797 E Unity : at Pathfinding.HierarchicalGraph+JobRecalculateComponents.RemoveHierarchicalNode (Pathfinding.HierarchicalGraph hGraph, System.Int32 hierarchicalNode, System.Boolean removeAdjacentSmallNodes) [0x00000] in <00000000000000000000000000000000>:0 09-25 14:32:47.711 11728 11797 E Unity : at Pathfinding.HierarchicalGraph+ 09-25 14:32:47.713 11728 11797 E Unity : IndexOutOfRangeException: Index was outside the bounds of the array. 09-25 14:32:47.713 11728 11797 E Unity : at Pathfinding.Graphs.Navmesh.NavmeshTile.GetVertex (System.Int32 index) [0x00000] in <00000000000000000000000000000000>:0 09-25 14:32:47.713 11728 11797 E Unity : at Pathfinding.NavmeshBase.GetVertex (System.Int32 index) [0x00000] in <00000000000000000000000000000000>:0 09-25 14:32:47.713 11728 11797 E Unity : at Pathfinding.TriangleMeshNode.GetVertices (Pathfinding.Int3& v0, Pathfinding.Int3& v1, Pathfinding.Int3& v2) [0x00000] in <00000000000000000000000000000000>:0 09-25 14:32:47.713 11728 11797 E Unity : at Pathfinding.NavmeshEdges+JobCalculateObstacles.CalculateBoundingBox (Pathfinding.HierarchicalGraph hGraph, System.Int32 hierarchicalNode) [0x00000] in <00000000000000000000000000000000>:0 09-25 14:32:47.713 11728 11797 E Unity : at Pathfinding.NavmeshEdges+JobCalculateObstacles.Execute (System.Int32 startIndex, System.Int32 count) [0x00000] in <00000000000000000000000000000000>:0 09-25 14:32:47.713 11728 11797 E Unity : at Unity.Jobs.IJobParallelForBatchExtensions+JobParallelForBatchProducer1[T].Execute (T& jobData, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges

Hi

If you can reliably reproduce it, that sounds great!
If you are interested, we could set up a voice call to try to debug this.

I don’t think so. The exception comes from a graph update or a graph scan.

1 Like

I found this in the 2023.2 release notes, which looks HIGHLY relevant, assuming you are using IL2CPP:

Any chance you could upgrade to 2023.2.19f1 or higher?

1 Like

Hi, thank you so much for the quick response!
Could it possibly be because of NavmeshCut? We were testing with a version where I turned off a logic where NavmeshCut would be turned on at the start of the player attacking, and turned off when player stop attacking. In that version, the crash doesn’t seem to happen anymore, if that helps you debug the case. If I’m correct it would cause a graph update right? There’s no graph scan in the scene whatsoever so we can rule that out.
I really appreciate that you could setup a voice call for the debug! If it possible I would love to do that if we can’t find out the cause through text exchange!

1 Like

Yes we’re using IL2CPP, let me try to see if I could upgrade to 2023.2.19f1 or higher then test to see if there’s a problem with this! Thank you so much for the help!

1 Like

Navmesh cuts do cause graph updates, yes.

1 Like

Hello! Just an update.
We’ve been trying to upgrade Unity and make a build. It’s quite hard to upgrade because of various reasons, a lot of weird API problems and conflicts with some SDK after upgrade, but we’ll try our best to test it with 2023.2.19f1 or higher and let you know about it as soon as possible.

Though it’s without a doubt constant use of NavmeshCut caused this. We’ve tested many times with and without NavmeshCut feature. It only happens in 3 Android devices we tested for now, OnePlus 10R, Lenovo Legion Y70, OPPO Reno 8 . It will crash during battle when NavmeshCut is constantly turning off/on.

Is there any way you can think of for me to temporarily fix this? I can’t use RVO because the pathfinding logic around other characters is kind of weird a lot of the time.

If you would like to do any test to help debugging, please do let me know.

Hello, I’ve finished upgrading and making a build with 2023.2.20f1. Version ‘2023.2.20f1 (0e25a174756c)’, Build type ‘Development’, Scripting Backend ‘il2cpp’, CPU ‘arm64-v8a’, Stripping ‘Enabled’
Device Model ‘OPPO PGBM10’, OS ‘Android OS 13 (API 33)’
The device crashes with the same log:

09-30 15:27:15.473 21012 22806 E Unity   : IndexOutOfRangeException: Index was outside the bounds of the array.
09-30 15:27:15.473 21012 22806 E Unity   :   at Pathfinding.HierarchicalGraph+JobRecalculateComponents.FloodFill (Pathfinding.HierarchicalGraph hGraph) [0x00000] in <00000000000000000000000000000000>:0
09-30 15:27:15.473 21012 22806 E Unity   :   at Pathfinding.HierarchicalGraph+JobRecalculateComponents.Execute () [0x00000] in <00000000000000000000000000000000>:0
09-30 15:27:15.473 21012 22806 E Unity   :   at Pathfinding.HierarchicalGraph.RecalculateIfNecessary () [0x00000] in <00000000000000000000000000000000>:0
09-30 15:27:15.473 21012 22806 E Unity   :   at Pathfinding.WorkItemProcessor.ProcessWorkItems (System.Boolean force, System.Boolean sendEvents) [0x00000] in <00000000000000000000000000000000>:0
09-30 15:27:15.473 21012 22806 E Unity   :   at AstarPath.PerformBlockingActions (System.Boolean force) [0x00000] in <00000000000000000000000000000000>:0
09-30 15:27:15.473 21012 22806 E Unity   :   at AstarPath.Update () [0x00000] in <00000000000000000000000000000000>:0
09-30 15:27:15.473 21012 22806 E Unity   : Pathfinding.HierarchicalGraph:RecalculateIfNecessary()
09-30 15:27:15.473 21012 22806 E Unity   : Pathfinding.WorkItemProcessor:ProcessWorkItems(Boolean, Boolean)
09-30 15:27:15.473 21012 22806 E Unity   : AstarPath:PerformBlockingActions(Boolean)
09-30 15:27:15.473 21012 22806 E Unity   : AstarPath:Update()

I have an object NavmeshCut, after NavmeshCut in that object is turned off(disabled), this error happened and game crashed right away. So I assume it’s not Unity’s problem.
Please take a look and if you need help debugging please let me know. If you need my discord to talk easier please add jakecat666.

For now I can only fix the crash by using RVO lock instead of NavmeshCut for the devices with issues. And do not turn off NavmeshCut for that specific object or don’t use NavmeshCut on that object. No crash happens at all after that.

Hi

I’ve sent you a message on Discord.

1 Like

I am get the same error with version 5.2.4 and unity 2022.3.51f

There is the log:

IndexOutOfRangeException: Index was outside the bounds of the array.
at Pathfinding.HierarchicalGraph+JobRecalculateComponents.RemoveHierarchicalNode (Pathfinding.HierarchicalGraph hGraph, System.Int32 hierarchicalNode, System.Boolean removeAdjacentSmallNodes) [0x00000] in <00000000000000000000000000000000>:0
at Pathfinding.HierarchicalGraph+JobRecalculateComponents.RemoveHierarchicalNode (Pathfinding.HierarchicalGraph hGraph, System.Int32 hierarchicalNode, System.Boolean removeAdjacentSmallNodes) [0x00000] in <00000000000000000000000000000000>:0
at Pathfinding.HierarchicalGraph+JobRecalculateComponents.Execute () [0x00000] in <00000000000000000000000000000000>:0
at Unity.Jobs.IJobExtensions+JobStruct`1+ExecuteJobFunction[T].Invoke (T& data, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) [0x00000] in <00000000000000000000000000000000>:0
at Pathfinding.WorkItemProcessor.ProcessWorkItems (System.Boolean force, System.Boolean sendEvents) [0x00000] in <00000000000000000000000000000000>:0
at AstarPath.PerformBlockingActions (System.Boolean force) [0x00000] in <00000000000000000000000000000000>:0
at AstarPath.Update () [0x00000] in <00000000000000000000000000000000>:0
Pathfinding.WorkItemProcessor:ProcessWorkItems(Boolean, Boolean)
AstarPath:PerformBlockingActions(Boolean)
AstarPath:Update()

IndexOutOfRangeException: Index was outside the bounds of the array.
at Pathfinding.HierarchicalGraph+JobRecalculateComponents.FloodFill (Pathfinding.HierarchicalGraph hGraph) [0x00000] in <00000000000000000000000000000000>:0
at Pathfinding.HierarchicalGraph+JobRecalculateComponents.Execute () [0x00000] in <00000000000000000000000000000000>:0
at Unity.Jobs.IJobExtensions+JobStruct`1+ExecuteJobFunction[T].Invoke (T& data, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) [0x00000] in <00000000000000000000000000000000>:0
at Pathfinding.WorkItemProcessor.ProcessWorkItems (System.Boolean force, System.Boolean sendEvents) [0x00000] in <00000000000000000000000000000000>:0
at AstarPath.PerformBlockingActions (System.Boolean force) [0x00000] in <00000000000000000000000000000000>:0
at AstarPath.Update () [0x00000] in <00000000000000000000000000000000>:0
Pathfinding.WorkItemProcessor:ProcessWorkItems(Boolean, Boolean)
AstarPath:PerformBlockingActions(Boolean)
AstarPath:Update()

Remote connection stopped for Id 3.
FishNet.Managing.Server.ServerManager:Transport_OnRemoteConnectionState(RemoteConnectionStateArgs)
FishNet.Object.NetworkBehaviour:g__WriteSyncType|212_0(Dictionary`2, <>c__DisplayClass212_0&)
FishNet.Transporting.Multipass.Multipass:IterateIncoming(Boolean)
FishNet.Managing.Transporting.TransportManager:IterateIncoming(Boolean)
FishNet.Managing.Timing.TimeManager:TryIterateData(Boolean)
FishNet.Managing.Timing.TimeManager:IncreaseTick()
FishNet.Managing.Timing.TimeManager:TickUpdate()

IndexOutOfRangeException: Index was outside the bounds of the array.
at Pathfinding.HierarchicalGraph+JobRecalculateComponents.RemoveHierarchicalNode (Pathfinding.HierarchicalGraph hGraph, System.Int32 hierarchicalNode, System.Boolean removeAdjacentSmallNodes) [0x00000] in <00000000000000000000000000000000>:0
at Pathfinding.HierarchicalGraph+JobRecalculateComponents.RemoveHierarchicalNode (Pathfinding.HierarchicalGraph hGraph, System.Int32 hierarchicalNode, System.Boolean removeAdjacentSmallNodes) [0x00000] in <00000000000000000000000000000000>:0
at Pathfinding.HierarchicalGraph+JobRecalculateComponents.Execute () [0x00000] in <00000000000000000000000000000000>:0
at Unity.Jobs.IJobExtensions+JobStruct`1+ExecuteJobFunction[T].Invoke (T& data, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) [0x00000] in <00000000000000000000000000000000>:0
at Pathfinding.WorkItemProcessor.ProcessWorkItems (System.Boolean force, System.Boolean sendEvents) [0x00000] in <00000000000000000000000000000000>:0
at AstarPath.PerformBlockingActions (System.Boolean force) [0x00000] in <00000000000000000000000000000000>:0
at AstarPath.Update () [0x00000] in <00000000000000000000000000000000>:0
Pathfinding.WorkItemProcessor:ProcessWorkItems(Boolean, Boolean)
AstarPath:PerformBlockingActions(Boolean)
AstarPath:Update()

@YefersonCC Do you think you could try upgrading to a newer version of Unity, and see if you can still replicate the issue?