Graph scan crashes the app on Android

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:

Hi

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).

Odd…
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 AstarPath.active.UpdateGraphs(bounds);

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/libunity.so (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/libunity.so (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/libunity.so (_ZN28BucketPruner
OverlapTraversalI16OBBAABBTest_SIMDLb0EEclERKN5physx2Sq16BucketPrunerCoreERKS0_RNS3_14PrunerCallbackERKNS2_9PxBounds3E.p
art.26+2260)
I/DEBUG (26081): #04 pc 00bc93b0 /mnt/asec/com.Magisterion.DragonStones-18/lib/arm/libunity.so (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/libunity.so (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/libunity.so (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/libunity.so (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/libunity.so (PhysicsManager::C
apsuleTest(Vector3f, Vector3f, float, int, QueryTriggerInteraction)+344)
I/DEBUG (26081): #09 pc 0054e1f4 /mnt/asec/com.Magisterion.DragonStones-18/lib/arm/libunity.so (Physics_CUSTOM_IN
TERNAL_CALL_CheckCapsule(Vector3f const&, Vector3f const&, float, int, QueryTriggerInteraction)+180)
I/DEBUG (26081): #10 pc 0001cafc

Hi

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.

Hi

Have you followed the advice for windows phone here: http://arongranberg.com/astar/docs/iphone.php?

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

Thanks

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

Hi

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.

Also having this problem.

Here’s one thread in Unity on it:

https://forum.unity3d.com/threads/physx-crash-on-android-only-physics_custom_internal_call_checkcapsule.331106/

They basically refuse to fix it without a repro case, “play my huge game until my 3rd party pathfinder randomly causes this crash” isn’t really a repro case, so I doubt Unity will ever fix it.

Seems like the pathfinder need to work around this issue? Switch the capsule test to multiple sphere tests? idk…

Hello,

I just wanted to report that we’re also fighting with this issue. Unity 5.5.3f1 and AStar 3.8.1. This is the crash log:

E/CRASH (29284): #11 pc 0000b8ec ( (wrapper managed-to-native) UnityEngine.Physics:INTERNAL_CALL_CheckCapsule (UnityEngine.Vector3&,UnityEngine.Vector3&,single,int,UnityEngine.QueryTriggerInteraction) + 0x6c (0x9f05a880 0x9f05a930) [0xa3f1eee0 - Unity Root Domain]+47340)

E/CRASH (29284): #12 il … at (wrapper managed-to-native) UnityEngine.Physics.INTERNAL_CALL_CheckCapsule (UnityEngine.Vector3&,UnityEngine.Vector3&,single,int,UnityEngine.QueryTriggerInteraction) <0xffffffff>
E/CRASH (29284): #13 il 0000006c at UnityEngine.Physics.CheckCapsule (UnityEngine.Vector3,UnityEngine.Vector3,single,int) <0x0006c>
E/CRASH (29284): #14 il 00000247 at Pathfinding.GraphCollision.Check (UnityEngine.Vector3) <0x00247>
E/CRASH (29284): #15 il 00000427 at Pathfinding.GridGraph.UpdateNodePositionCollision (Pathfinding.GridNode,int,int,bool) <0x00427>
E/CRASH (29284): #16 il 0000035b at Pathfinding.GridGraph.ScanInternal (OnScanStatus) <0x0035b>
E/CRASH (29284): #17 il 00000a43 at AstarPath.ScanLoop (OnScanStatus) <0x00a43>
E/CRASH (29284): #18 il 0000001f at AstarPath.Scan () <0x0001f>
E/CRASH (29284): #19 il 00000623 at AstarPath.Awake () <0x00623>

Later in the same log:

E/AndroidRuntime(29284): FATAL EXCEPTION: UnityMain

E/AndroidRuntime(29284): Process: be.diekeure.kweetet, PID: 29284

E/AndroidRuntime(29284): java.lang.Error: FATAL EXCEPTION [UnityMain]

E/AndroidRuntime(29284): Unity version : 5.5.3f1

E/AndroidRuntime(29284): Device model : LENOVO Lenovo TB2-X30F

E/AndroidRuntime(29284): Device fingerprint: Lenovo/TB2-X30F/TB2-X30F:5.1.1/LenovoTB2-X30F/TB2-X30F_S000014_151118_ROW:user/release-keys

E/AndroidRuntime(29284):

E/AndroidRuntime(29284): Caused by: java.lang.Error: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 004a0048

E/AndroidRuntime(29284): Build fingerprint: ‘Lenovo/TB2-X30F/TB2-X30F:5.1.1/LenovoTB2-X30F/TB2-X30F_S000014_151118_ROW:user/release-keys’

E/AndroidRuntime(29284): Revision: ‘0’

E/AndroidRuntime(29284): pid: 29284, tid: 29302, name: UnityMain >>> be.diekeure.kweetet <<<

E/AndroidRuntime(29284): r0 a48dc0d4 r1 b9b1a480 r2 004a0049 r3 b9a24c00

E/AndroidRuntime(29284): r4 a48dcb88 r5 a48dcbe8 r6 b9b1a480 r7 b9a24c00

E/AndroidRuntime(29284): r8 baa49550 r9 00000000 sl 00000000 fp a48dc9e8

E/AndroidRuntime(29284): ip a4e298e8 sp a48dc0c0 lr a4e29920 pc 004a0048 cpsr 3242546f

E/AndroidRuntime(29284):

E/AndroidRuntime(29284): at Unknown.004a0048(Unknown Source)

E/AndroidRuntime(29284): at libunity.0044b91c(Native Method)

E/AndroidRuntime(29284): at libunity.00ba1e60(Native Method)

E/AndroidRuntime(29284): at libunity.00cc3d40(Native Method)

E/AndroidRuntime(29284): at libunity.00cc9270(Native Method)

E/AndroidRuntime(29284): at libunity.00cbcc38(Native Method)

E/AndroidRuntime(29284): at libunity.00ba360c(Native Method)

E/AndroidRuntime(29284): at libunity.00ba3c74(Native Method)

E/AndroidRuntime(29284): at libunity.0042dce0(Native Method)

E/AndroidRuntime(29284): at libunity.0042dbac(Native Method)

E/AndroidRuntime(29284): at libunity.00661f34(Native Method)

E/AndroidRuntime(29284): at Unknown.0000b8ec(Unknown Source)

E/AndroidRuntime(29284): at Physics.INTERNAL_CALL_CheckCapsule(Native Method)

E/AndroidRuntime(29284): at Physics.CheckCapsule(<0x0006c>:108)

E/AndroidRuntime(29284): at GraphCollision.Check(<0x00247>:583)

E/AndroidRuntime(29284): at GridGraph.UpdateNodePositionCollision(<0x00427>:1063)

E/AndroidRuntime(29284): at GridGraph.ScanInternal(<0x0035b>:859)

E/AndroidRuntime(29284): at AstarPath.ScanLoop(<0x00a43>:2627)

E/AndroidRuntime(29284): at AstarPath.Scan(<0x0001f>:31)

E/AndroidRuntime(29284): at AstarPath.Awake(<0x00623>:1571)

E/AndroidRuntime(29284): at Object.runtime_invoke_void__this__(Native Method)

E/AndroidRuntime(29284): at libmono.00021d6b(Native Method)

E/AndroidRuntime(29284): at libmono.mono_runtime_invoke(mono_runtime_invoke:136)

E/AndroidRuntime(29284): at libunity.004ad084(Native Method)

E/AndroidRuntime(29284): at libunity.00470198(Native Method)

E/AndroidRuntime(29284): at libunity.00470540(Native Method)

E/AndroidRuntime(29284): at libunity.004700b0(Native Method)

E/AndroidRuntime(29284): at libunity.004b0b7c(Native Method)

E/AndroidRuntime(29284): at libunity.0032f964(Native Method)

E/AndroidRuntime(29284): at libunity.0032f558(Native Method)

E/AndroidRuntime(29284): at libunity.0032f334(Native Method)

E/AndroidRuntime(29284): at libunity.003301e0(Native Method)

We had a previous case of this problem and then it was caused by two capsulecolliders on the same position, maybe that helps to find a solution?

Thx,
Alex