Graph scan crashes the app on Android

Hello there!

I’ve been using Unity 4.5.3 and A* Pathfinding 3.5.2 for my project. And I’ve been updating the grid graph in runtime like this:

// rescan the pathfinding graph
GridGraph graph =; = graphCenter; // some new grapth center
graph.width = graphWidth; // some new graph width
graph.depth = graphDepth; // some new graph depth

Everything worked like a charm. Now I’ve upgraded to Unity 5. This code still works fine in Unity editor, but it crashes the app on Android when the Scan() method is executed.

Upgrading to A* Pathfinding 3.6 didn’t help. The situation is exactly the same - everything is ok in Unity, but the app crashes on the Android phone.

Could you give me some advice on how to resolve this?

1 Like


Try the latest beta (3.6.8) and see if it still crashes. If it does, it would be very helpful to see the log so that we can determine what crashes it.

Hi Aron!

After some dancing with adb I figured out that it all finally crashed in GraphCollision.Check() method. To be precise, in Physics.CheckCapsule():

position += up*collisionOffset;
switch (type) {
    case ColliderType.Capsule:
        // <-- "then it all crashes down..."
        return !Physics.CheckCapsule (position, position+upheight,finalRadius,mask); 
    case ColliderType.Sphere:
        return !Physics.CheckSphere (position, finalRadius,mask);

The interesting thing is that the Scan() method works ok one time in the beginning of the game. Everything crashes only on the second scan. As for values passed to the Physics.CheckCapsule(), they don’t seem suspicious to me, for example:

position: (-50.5, 0.0, -50.5)
position+upheight: (-50.5, 2.0, -50.5)
finalRadius: 0.5

Another thing I’ve noticed is that this node-scanning loop in GridGraph.ScanInternal() exectues ok during the first scan. But on the second scan it may crash when z==0 and x==0, x==1 or x==2.

for (int z = 0; z < depth; z ++) 
    for (int x = 0; x < width; x++) 
        GridNode node = nodes[z*width+x];

        node.NodeInGridIndex = z*width+x;
        UpdateNodePositionCollision (node,x,z);

So maybe it’s some kind of overflow, I really don’t know.

And yet another interesting thing is that it all works ok if I build it for Windows (desktop).

All this stuff is quite confusing, so I’ll appreciate any help.

P.S. As for your proposal to upgrade to version 3.6.8. After importing the package I got the following error message:

“Assets/AstarPathfindingProject/Core/AstarData.cs(162,82): error CS0246: The type or namespace name `LayerGridGraph’ could not be found. Are you missing a using directive or an assembly reference?”.

Looks like we have a layerGridGraph shortcut, but we don’t have the LayerGridGraph itself :wink: So I had to comment a couple of “LayerGridGraph-related” lines. And finally - it didn’t help. Still we have a crash :frowning:


Ok. If it crashes inside a physics call then it is likely a Unity bug. Is it possible for you to upgrade to a more recent unity version?

Looks like I’m using the latest (5.1.1f1). Should I report it as a Unity bug?

Sounds like a bug.
If you have the professional version of Unity you can try the 5.2 beta.

From 5.1.2 release notes

(697543) - Physics: Fixed issue in PhysX where PhysX would hang on certain Android devices.

Hello Aron!

Thank you very much for this information. Unfortunately, upgrading to 5.1.2 didn’t help in my case. Feeling really frustrated about it. Well, I’ll keep debugging. Maybe it’s some unique “feature” of my own code (or my device).

You could try it on another device or you could try to switch the collision detection mode from capsule to ray or sphere.

Aron, thank you for the advices.

Totally agree. The graph rescan itself doesn not crash the app. It crashes only when I instantiate some “new lands” and then try to rescan. So maybe it relates somehow to the number of physical bodies in the scene.

Didn’t help. I’ve tried it on a tablet with different Android version. The same thing.

Yeah! I haven’t tested it thoroughly yet, but it looks like with the “sphere” collider it works just fine :slight_smile:

I think that in my case it’s not an issue and I can continue with the “sphere” collision testing. But still it’s a workaround. And if there really is a problem in Physics.CheckCapsule(), it would be nice to have it fixed.

If I have time I’ll try to make a simplest project that crashes. Then it can be used in a bug report, I guess.

Hi Aron,

Loving the package, just wanted to let you know I recently ran into what looks like this same issue. Your suggested solution worked of switching to ray or sphere instead of capsule worked, just thought I’d chime in anyways as an FYI.

I’m using:
Unity v5.1.2p2 Personal
Pathfinding project v3.7.3
Building for Samsung S6 (GearVR)

When I don’t have AStarPathfinding on, there’s no problems. When AStarPathfinding is on, I have the same issue where it does the initial scan fine, but subsequent scans trigger a crash for the whole app. The crash is triggered by;

Hm. Annoying bug this. And really odd that it scans correctly the first time but not later… Maybe some later added rigidbodies that it crashes on.
Do you think you could send a bug report to Unity so that they can replicate it easily? The more bug reports the better (and hopefully it will be fixed faster).

Also do you think you can try with the Unity 5.2 beta. I cannot find anything in the release notes other than

Android: Fixed crash affecting some PowerVR 544 devices

But I guess it’s worth a try.

Same here :frowning: and i can’t fight it. Android only. Used Last (3.7.5 beta) version of A*, last Unity (5.3). Randomly crashed when new entity is added to the scene and .Scan called.

Any help please? We already released a project on mobile and need to fix it ASAP.

I/DEBUG (26081): backtrace:
I/DEBUG (26081): #00 pc 00000000
I/DEBUG (26081): #01 pc 001f1b78 /mnt/asec/com.Magisterion.DragonStones-18/lib/arm/ (CastFilter::preFi
lter(physx::PxFilterData const&, physx::PxShape const*, physx::PxRigidActor const*, physx::PxFlags<physx::PxHitFlag::Enu
m, unsigned short>&)+96)
I/DEBUG (26081): #02 pc 00a67b10 /mnt/asec/com.Magisterion.DragonStones-18/lib/arm/ (MultiQueryCallbac
kphysx::PxOverlapHit::invoke(float&, physx::Sq::PrunerPayload const*, unsigned int)+940)
I/DEBUG (26081): #03 pc 00bc3bec /mnt/asec/com.Magisterion.DragonStones-18/lib/arm/ (_ZN28BucketPruner
I/DEBUG (26081): #04 pc 00bc93b0 /mnt/asec/com.Magisterion.DragonStones-18/lib/arm/ (physx::Sq::Bucket
PrunerCore::overlap(physx::Sq::ShapeData const&, physx::Sq::PrunerCallback&) const+2844)
I/DEBUG (26081): #05 pc 00bbc10c /mnt/asec/com.Magisterion.DragonStones-18/lib/arm/ (physx::Sq::AABBPr
uner::overlap(physx::Sq::ShapeData const&, physx::Sq::PrunerCallback&) const+228)
I/DEBUG (26081): #06 pc 00a69138 /mnt/asec/com.Magisterion.DragonStones-18/lib/arm/ (bool physx::NpSce
neQueries::multiQueryphysx::PxOverlapHit(physx::MultiQueryInput const&, physx::PxHitCallbackphysx::PxOverlapHit&, ph
ysx::PxFlags<physx::PxHitFlag::Enum, unsigned short>, physx::PxQueryCache const*, physx::PxQueryFilterData const&, physx
::PxQueryFilterCallback*, physx::BatchQueryFilterData*) const+484)
I/DEBUG (26081): #07 pc 00a697e4 /mnt/asec/com.Magisterion.DragonStones-18/lib/arm/ (physx::NpSceneQue
ries::overlap(physx::PxGeometry const&, physx::PxTransform const&, physx::PxHitCallbackphysx::PxOverlapHit&, physx::Px
QueryFilterData const&, physx::PxQueryFilterCallback*) const+144)
I/DEBUG (26081): #08 pc 001cecfc /mnt/asec/com.Magisterion.DragonStones-18/lib/arm/ (PhysicsManager::C
apsuleTest(Vector3f, Vector3f, float, int, QueryTriggerInteraction)+344)
I/DEBUG (26081): #09 pc 0054e1f4 /mnt/asec/com.Magisterion.DragonStones-18/lib/arm/ (Physics_CUSTOM_IN
TERNAL_CALL_CheckCapsule(Vector3f const&, Vector3f const&, float, int, QueryTriggerInteraction)+180)
I/DEBUG (26081): #10 pc 0001cafc


It looks like that is a unity bug caused by calling Physics.CheckCapsule. I would report the bug to Unity (possibly include a link to this thread). In the meantime you can switch the collision checking in the grid graph settings from Capsule to Sphere or Ray.

Thanks for the help, Sphere collider works properly

Hi guys.
Thanks for sharing this. I have the same problem but with Windows Phone 10 in Unity 5.3.1p4.
It always crashes whey the game is doing heavy process like loading our scene and buildings.
If I wait like 10 seconds, the scan process works fine.

Right now I am changing my capsule colliers and commenting this code to avoid crashes as aron suggested.

When it crashes on windows 10 device, it does not give me any description about the error.
Just give me “The program ‘[1708] DungeonBattle.exe’ has exited with code -XXXXX (XXXXX).” that I didn’t save the code.


Have you followed the advice for windows phone here:

Hi Aron.
Yes, I did everything. Everything is working fine, except when I have some capsule collider in the scene.


Hi!! just leting you know that this error still happens, changing to sphere solved it for me, but here’s the error log i got from the apk:

java.lang.Error: FATAL EXCEPTION [UnityMain]
Unity version     : 5.3.4f1
Device model      : motorola XT1039
Device fingerprint: motorola/peregrine_retes/peregrine:5.1/LPB23.13-17.3/3:user/release-keys

Caused by: java.lang.Error: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000088
Build fingerprint: 'motorola/peregrine_retes/peregrine:5.1/LPB23.13-17.3/3:user/release-keys'
Revision: 'p2d0'
pid: 7127, tid: 7156, name: UnityMain  >>> com.Journey.BartenderTales <<<
r0 00000000  r1 b9d1aef0  r2 b9d1aef0  r3 b9bae930
r4 a4e39ad8  r5 a4e39b38  r6 b9d1aef0  r7 b9bae930
r8 b9cd5880  r9 a4e390a4  sl 00000000  fp 00000000
ip a51d0a58  sp a4e39008  lr a595a60c  pc a51d0a84  cpsr 4c2f312e

at libunity.00295a84(Native Method)
at libunity.00a1f608(Native Method)
at libunity.00b7b6dc(Native Method)
at libunity.00b80ea0(Native Method)
at libunity.00b73bfc(Native Method)
at libunity.00a20c30(Native Method)
at libunity.00a212dc(Native Method)
at libunity.0026edf4(Native Method)
at libunity.0026ecc0(Native Method)
at libunity.00580d4c(Native Method)
at Unknown.0000967c(Unknown Source)
at Physics.INTERNAL_CALL_CheckCapsule(Native Method)
at Physics.CheckCapsule(<0x0006c>:108)
at GraphCollision.Check(<0x00223>:547)
at GridGraph.UpdateNodePositionCollision(<0x0044b>:1099)
at GridGraph.ScanInternal(<0x00333>:819)
at AstarPath.ScanLoop(<0x00a4b>:2635)
at AstarPath.Scan(<0x0001f>:31)
at UpgradeManager.botonBuildearNuevo(<0x00283>:643)
at InvokableCall`1.Invoke(<0x000af>:175)
at CachedInvokableCall`1.Invoke(<0x00027>:39)
at InvokableCallList.Invoke(<0x00093>:147)
at UnityEventBase.Invoke(<0x00037>:55)
at UnityEvent.Invoke(<0x0001f>:31)
at Button.Press(<0x00053>:83)
at Button.OnPointerClick(<0x0002f>:47)
at ExecuteEvents.Execute(<0x00043>:67)
at ExecuteEvents.Execute(<0x001db>:475)
at StandaloneInputModule.ProcessTouchPress(<0x003e3>:995)
at StandaloneInputModule.ProcessTouchEvents(<0x0011f>:287)
at StandaloneInputModule.Process(<0x00077>:119)
at EventSystem.Update(<0x00193>:403)`

i hope it helps!! BTW, i’ve the 3.8.2 free version of the A* Pathfinding Project


Thanks for the report. Unfortunately there is not much I can do about it.
It would be really nice if you could submit a bug report to Unity so that they might get around to fixing this at some point.