ArgumentOutOfRangeException with MORE_LAYERS enabled

  • A* version: 5.3.3, 5.3.7
  • Unity version: 6000.0.39f1

Hi, I am getting the following error when calling ScanAsync() for an active AstarPath. I initially got it on 5.3.3, upgrading to 5.3.7 didn’t resolve the issue.

ArgumentOutOfRangeException: Length must be >= 0

Error only appears when using ASTAR_LEVELGRIDNODE_MORE_LAYERS which I had to enable in the project. Otherwise, the scan completes fine.
Stack trace:

Extra things that I discovered while trying to fix this:

  • I updated com.unity.collections to the latest 2.5.7 version. Project compiles fine, however the issue is still there.
  • When using Editor’s ‘Scan’ button to generate a graph, the same error appears too.
  • Error appears only when generating LayeredGridGraph of any shape.
  • Error is resolved when I set graph size to at most 437x437. Any size of that value or lower successfully generates the graph (initially I had it at 468x468 in that specific level)
  • ASTAR_LARGER_GRIDS doesn’t resolve the issue.

Hi

I think this happens because it is trying to allocate more than 2 GB of memory for some array. This is quite a lot! I would recommend trying out the recast graph instead :stuck_out_tongue:

But in any case, I think I found the issue. I’ll include a fix in the next update.

Thanks for looking into this.

I realized the memory issue after I looked into the profiler. I ended up going back to node size 1 instead of 0.33, and it generates fine now.

In the case of recast graph - does it support the multiple layers of the graph just like Layered Grid Graph? I remember having some issues with FollowerEntity snapping to a graph above, defying the laws of physics :smile:

Yes it does. And it’s quite a bit more memory efficient for large worlds.

Yes it does. And it’s quite a bit more memory efficient for large worlds.

Thank you for the guidance.