Search Issue Tracker
Fixed in 2018.2.X
Fixed in 5.6.X, 2017.1.X, 2017.2.X, 2017.3.X, 2018.1.X
Won't Fix in 5.5.X
Votes
30
Found in
5.4.3p2
Issue ID
878407
Regression
No
[Android] PhysX crash when calling Physics.OverlapBoxNonAlloc or OverlapBox
How to reproduce:
1. Open the attached project
2. Build and run on Android device
3. Play the game, use skills by pressing any of the 4 round buttons at the bottom of the screen
Result: after few minutes (till reaching level 4) application crashes
Note: User calls Physics.OverlapBoxNonAlloc ( UnityEngine.Physics.OverlapBox also lead to crash) in PhysicsSystem.cs. Application doesn't crash if that part in the script is commented
Reproducible: 5.4.3p2, 5.4.4p2, 5.5.1p3
Haven't been able to test on 5.3.7p4 because project has too many scripting errors.
Haven't been able to reproduce on 5.6.0b7 because after project is loaded I get an error "APIUpdater encountered some issues and was not able to finish.", which leads to unsuccessful building with an error "Error building Player because scripts have compile errors in the editor"
DUT (reproducible):
LG G5 [LG-H850], Qualcomm Snapdragon 820, Adreno 530, OS 6.0.1
Also tested on iPhone 6+ (iOS 10.1), application doesn't work there
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Select Preset "None" icon changes after switching tabs
- [Android] Crash when using xxHash3 and targeting the ARMv7 Architecture with IL2CPP Scripting Backend
- GameObject reference in a Script Component becomes missing when unpacking a variant of another Prefab variant
- Project Settings vertical separator position is not synchronized with the mouse position when dragging it horizontally
- Crash on PhysicsDebugDraw::SelectFiltering::Update when entering play mode with Physics Debug window docked and unfocused
Bunzaga
Feb 21, 2017 11:35
For the short term, this returns true if a hit was detected, and false there was no hit:
using UnityEngine;
public static class CollisionCheck
{
private static Vector3 _AB = new Vector3(); // Direction A to B
private static float[] _R = new float[9]; // 3x3 Rotation
private static float[] _AbsR = new float[9]; // 3x3 Rotation
private static Vector3 _AX = new Vector3(); // A Axis
private static Vector3 _BX = new Vector3(); // B Axis
private static Vector3 _v1 = new Vector3();
private static Vector3 _v2 = new Vector3();
private static Vector3 _v3 = new Vector3();
private static float[] _aRot = new float[9];
private static float[] _bRot = new float[9];
private static float ar = 0.0f, br = 0.0f;
private static float[] _identityMatrix = new float[9] { 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f };
// Adapted from: http://www.gamasutra.com/view/feature/131790/simple_intersection_tests_for_games.php?print=1
public static bool Box_Box (Vector3 aPos, Vector3 aSize, Quaternion aQuat, Vector3 bPos, Vector3 bSize, Quaternion bQuat)
{
ar = 0.0f;
br = 0.0f;
QuaternionToFloatArray(aQuat, _aRot);
QuaternionToFloatArray(bQuat, _bRot);
for (int i = 0, i1 = 0; i < 3; i++, i1 += 3)
{
_AX.Set(_aRot[i1], _aRot[i1 + 1], _aRot[i1 + 2]);
for (int j = 0, j1 = 0; j < 3; j++, j1 += 3)
{
_BX.Set(_bRot[j1], _bRot[j1 + 1], _bRot[j1 + 2]);
_R[i1 + j] = Vector3.Dot(_AX, _BX);
}
}
_AB = bPos - aPos;
_v1.Set(_aRot[0], _aRot[1], _aRot[2]);
_v2.Set(_aRot[3], _aRot[4], _aRot[5]);
_v3.Set(_aRot[6], _aRot[7], _aRot[8]);
_AB.Set(Vector3.Dot(_AB, _v1), Vector3.Dot(_AB, _v2), Vector3.Dot(_AB, _v3));
for (int i = 0; i < 9; i++)
{
_AbsR[i] = Mathf.Abs(_R[i]) + 0.001f;
}
// Test axes L = A0, L = A1, L = A2
for (int i = 0, i1 = 0; i < 3; i++, i1 += 3)
{
ar = aSize[i];
br = (bSize[0] * _AbsR[i1]) + (bSize[1] * _AbsR[i1 + 1]) + (bSize[2] * _AbsR[i1 + 2]);
if (Mathf.Abs(_AB[i]) > (ar + br)) { return false; }
}
// Test axes L = B0, L = B1, L = B2
for (int i = 0; i < 3; i++)
{
ar = (aSize[0] * _AbsR[i]) + (aSize[1] * _AbsR[i + 3]) + (aSize[2] * _AbsR[i + 6]);
br = bSize[i];
if (Mathf.Abs((_AB[0] * _R[i]) + (_AB[1] * _R[i + 3]) + (_AB[2] * _R[i + 6])) > (ar + br)) { return false; }
}
// Test axis L = A0 x B0
ar = (aSize[1] * _AbsR[6]) + (aSize[2] * _AbsR[3]);
br = (bSize[1] * _AbsR[2]) + (bSize[2] * _AbsR[1]);
if (Mathf.Abs(_AB[2] * _R[3] - _AB[1] * _R[6]) > (ar + br)) { return false; }
// Test axis L = A0 x B1
ar = (aSize[1] * _AbsR[7]) + (aSize[2] * _AbsR[4]);
br = (bSize[0] * _AbsR[2]) + (bSize[2] * _AbsR[0]);
if (Mathf.Abs((_AB[2] * _R[4]) - (_AB[1] * _R[7])) > (ar + br)) { return false; }
// Test axis L = A0 x B2
ar = aSize[1] * _AbsR[8] + aSize[2] * _AbsR[5];
br = bSize[0] * _AbsR[1] + bSize[1] * _AbsR[0];
if (Mathf.Abs((_AB[2] * _R[5]) - (_AB[1] * _R[8])) > (ar + br)) { return false; }
// Test axis L = A1 x B0
ar = (aSize[0] * _AbsR[6]) + (aSize[2] * _AbsR[0]);
br = (bSize[1] * _AbsR[5]) + (bSize[2] * _AbsR[4]);
if (Mathf.Abs((_AB[0] * _R[6]) - (_AB[2] * _R[0])) > (ar + br)) { return false; }
// Test axis L = A1 x B1
ar = (aSize[0] * _AbsR[7]) + (aSize[2] * _AbsR[1]);
br = (bSize[0] * _AbsR[5]) + (bSize[2] * _AbsR[3]);
if (Mathf.Abs((_AB[0] * _R[7]) - (_AB[2] * _R[1])) > (ar + br)) { return false; }
// Test axis L = A1 x B2
ar = (aSize[0] * _AbsR[8]) + (aSize[2] * _AbsR[2]);
br = (bSize[0] * _AbsR[4]) + (bSize[1] * _AbsR[3]);
if (Mathf.Abs((_AB[0] * _R[8]) - (_AB[2] * _R[2])) > (ar + br)) { return false; }
// Test axis L = A2 x B0
ar = (aSize[0] * _AbsR[3]) + (aSize[1] * _AbsR[0]);
br = (bSize[1] * _AbsR[8]) + (bSize[2] * _AbsR[7]);
if (Mathf.Abs((_AB[1] * _R[0]) - (_AB[0] * _R[3])) > (ar + br)) { return false; }
// Test axis L = A2 x B1
ar = (aSize[0] * _AbsR[4]) + (aSize[1] * _AbsR[1]);
br = (bSize[0] * _AbsR[8]) + (bSize[2] * _AbsR[6]);
if (Mathf.Abs((_AB[1] * _R[1]) - (_AB[0] * _R[4])) > (ar + br)) { return false; }
// Test axis L = A2 x B2
ar = (aSize[0] * _AbsR[4]) + (aSize[1] * _AbsR[2]);
br = (bSize[0] * _AbsR[7]) + (bSize[1] * _AbsR[6]);
if (Mathf.Abs((_AB[1] * _R[2]) - (_AB[0] * _R[5])) > (ar + br)) { return false; }
return true;
}
// Adapted from: http://www.mrelusive.com/publications/papers/SIMD-From-Quaternion-to-Matrix-and-Back.pdf
private static float[] QuaternionToFloatArray(Quaternion aQuat, float[] aFlatMatrix3x3 )
{
if(aFlatMatrix3x3 == null) {
aFlatMatrix3x3 = new float[9];
}
aFlatMatrix3x3[0] = 1- (2.0f * (aQuat.y * aQuat.y)) - (2.0f * (aQuat.z * aQuat.z));
aFlatMatrix3x3[1] = (2.0f * (aQuat.x * aQuat.y)) + (2.0f * (aQuat.w * aQuat.z));
aFlatMatrix3x3[2] = (2.0f * (aQuat.x * aQuat.z)) - (2.0f * (aQuat.w * aQuat.y));
aFlatMatrix3x3[3] = (2.0f * (aQuat.x * aQuat.y)) - (2.0f * (aQuat.w * aQuat.z));
aFlatMatrix3x3[4] = 1.0f - (2.0f * (aQuat.x * aQuat.x)) - (2.0f * (aQuat.z * aQuat.z));
aFlatMatrix3x3[5] = (2.0f * (aQuat.y * aQuat.z)) + (2.0f * (aQuat.w * aQuat.x));
aFlatMatrix3x3[6] = (2.0f * (aQuat.x * aQuat.z)) + (2.0f * (aQuat.w * aQuat.y));
aFlatMatrix3x3[7] = (2.0f * (aQuat.y * aQuat.z)) - (2.0f * (aQuat.w * aQuat.x));
aFlatMatrix3x3[8] = 1.0f - (2.0f * (aQuat.x * aQuat.x)) - (2.0f * (aQuat.y * aQuat.y));
return aFlatMatrix3x3;
}
}
Bunzaga
Feb 20, 2017 21:48
I'm using beta 5.6.0b9, I get the same result at times.
It seems to happen more often when I have to destroy the game object which those collision results came from. For example, if I Instantiate a GameObject, check collisions with other existing game objects, based on some collider information (center, size, etc), then want to destroy the newly instantiated GameObject because of the OverlapBox check.
I'll try to create local variables to pass in, like vector3's and stuff, instead of passing the colliders own properties, and see if that helps...
Out of about 20-25 attempts, this was the only one that failed... as it happened, I also dragged my finger across the screen when it failed. I'm not sure if that is a coincidence or not.
F/libc ( 8516): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 8533 (UnityMain)
I/DEBUG ( 366): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG ( 366): Build fingerprint: 'motorola/obake-maxx_verizon/obake-maxx:4.4.4/SU6-7.7/5:user/release-keys'
I/DEBUG ( 366): Revision: 'p300'
I/DEBUG ( 366): pid: 8516, tid: 8533, name: UnityMain >>> com.HashbangGames.DireDungeons <<<
I/DEBUG ( 366): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000
I/DEBUG ( 366): r0 60d58d9c r1 6aae4810 r2 00000000 r3 6a9b2140
I/DEBUG ( 366): r4 60d59884 r5 60d59870 r6 6aae4810 r7 6a9b2140
I/DEBUG ( 366): r8 6ad2e6c0 r9 00000000 sl 00000000 fp 60d596b0
I/DEBUG ( 366): ip 5fa8dfd4 sp 60d58d88 lr 5fa8e00c pc 00000000 cpsr 200e0010
I/DEBUG ( 366): d0 40c000033ffae16a d1 40c0001837174516
I/DEBUG ( 366): d2 33900000376989f4 d3 0000000000000000
I/DEBUG ( 366): d4 0000000000000000 d5 fe7ffffffe7fffff
I/DEBUG ( 366): d6 c201557bc201557b d7 fe7ffffffe7fffff
I/DEBUG ( 366): d8 40738e97bf800000 d9 0000000000000000
I/DEBUG ( 366): d10 0000000000000000 d11 0000000000000000
I/DEBUG ( 366): d12 0000000000000000 d13 0000000000000000
I/DEBUG ( 366): d14 0000000000000000 d15 0000000000000000
I/DEBUG ( 366): d16 0000000000000000 d17 0000000000000000
I/DEBUG ( 366): d18 358637bd3f7f68eb d19 000000003d8b036e
I/DEBUG ( 366): d20 000000003f7f68da d21 000000003d8b02e8
I/DEBUG ( 366): d22 3f80000000000000 d23 0000000080000000
I/DEBUG ( 366): d24 0000000000000000 d25 0000000000000000
I/DEBUG ( 366): d26 00000000c2000004 d27 00000000c0c0001c
I/DEBUG ( 366): d28 0000000000000000 d29 0000000000000000
I/DEBUG ( 366): d30 3efd641d40070089 d31 000000003f800008
I/DEBUG ( 366): scr 2000009f
I/DEBUG ( 366):
I/DEBUG ( 366): backtrace:
I/DEBUG ( 366): #00 pc 00000000 <unknown>
I/DEBUG ( 366): #01 pc 007ed008 /data/app-lib/com.HashbangGames.DireDungeons-1/libunity.so (CastFilter::preFilter(physx::PxFilterData const&, physx::PxShape const*, physx::PxRigidActor const*, physx::PxFlags<physx::PxHitFlag::Enum, unsigned short>&)+52)
I/DEBUG ( 366): #02 pc 0118ee10 /data/app-lib/com.HashbangGames.DireDungeons-1/libunity.so (MultiQueryCallback<physx::PxOverlapHit>::invoke(float&, physx::Sq::PrunerPayload const*, unsigned int)+388)
I/DEBUG ( 366): #03 pc 012b0d08 /data/app-lib/com.HashbangGames.DireDungeons-1/libunity.so (_ZN28BucketPrunerOverlapTraversalI16OBBAABBTest_SIMDLb0EEclERKN5physx2Sq16BucketPrunerCoreERKS0_RNS3_14PrunerCallbackERKNS2_9PxBounds3E.part.26+2260)
I/DEBUG ( 366): #04 pc 012b6238 /data/app-lib/com.HashbangGames.DireDungeons-1/libunity.so (physx::Sq::BucketPrunerCore::overlap(physx::Sq::ShapeData const&, physx::Sq::PrunerCallback&) const+2844)
I/DEBUG ( 366): #05 pc 012a9c00 /data/app-lib/com.HashbangGames.DireDungeons-1/libunity.so (physx::Sq::AABBPruner::overlap(physx::Sq::ShapeData const&, physx::Sq::PrunerCallback&) const+228)
I/DEBUG ( 366): #06 pc 011905bc /data/app-lib/com.HashbangGames.DireDungeons-1/libunity.so (bool physx::NpSceneQueries::multiQuery<physx::PxOverlapHit>(physx::MultiQueryInput const&, physx::PxHitCallback<physx::PxOverlapHit>&, physx::PxFlags<physx::PxHitFlag::Enum, unsigned short>, physx::PxQueryCache const*, physx::PxQueryFilterData const&, physx::PxQueryFilterCallback*, physx::BatchQueryFilterData*) const+496)
I/DEBUG ( 366): #07 pc 01190c24 /data/app-lib/com.HashbangGames.DireDungeons-1/libunity.so (physx::NpSceneQueries::overlap(physx::PxGeometry const&, physx::PxTransform const&, physx::PxHitCallback<physx::PxOverlapHit>&, physx::PxQueryFilterData const&, physx::PxQueryFilterCallback*) const+92)
I/DEBUG ( 366): #08 pc 007cf14c /data/app-lib/com.HashbangGames.DireDungeons-1/libunity.so (Unity::PhysicsQuery::OverlapBoxInternal(Vector3f const&, Vector3f const&, Quaternionf const&, int, QueryTriggerInteraction, physx::PxHitCallback<physx::PxOverlapHit>&)+260)
I/DEBUG ( 366): #09 pc 007cf25c /data/app-lib/com.HashbangGames.DireDungeons-1/libunity.so (Unity::PhysicsQuery::OverlapBoxNonAlloc(Vector3f const&, Vector3f const&, Quaternionf const&, Collider**, int, int, QueryTriggerInteraction)+244)
I/DEBUG ( 366): #10 pc 00abefcc /data/app-lib/com.HashbangGames.DireDungeons-1/libunity.so (Physics_CUSTOM_INTERNAL_CALL_OverlapBoxNonAlloc(Vector3f const&, Vector3f const&, MonoArray*, Quaternionf const&, int, QueryTriggerInteraction)+152)
I/DEBUG ( 366): #11 pc 00005fcc <unknown>
I/DEBUG ( 366):
I/DEBUG ( 366): stack:
I/DEBUG ( 366): 60d58d48 3d8b02e8
I/DEBUG ( 366): 60d58d4c 00000000
I/DEBUG ( 366): 60d58d50 3f7f68da
I/DEBUG ( 366): 60d58d54 80000000
I/DEBUG ( 366): 60d58d58 3f800000
I/DEBUG ( 366): 60d58d5c 00000000
I/DEBUG ( 366): 60d58d60 bf7f68da
I/DEBUG ( 366): 60d58d64 80000000
I/DEBUG ( 366): 60d58d68 3d8b02e8
I/DEBUG ( 366): 60d58d6c 6a1e7ccc
I/DEBUG ( 366): 60d58d70 bd8b02e0
I/DEBUG ( 366): 60d58d74 80000000
I/DEBUG ( 366): 60d58d78 bf7f68dd
I/DEBUG ( 366): 60d58d7c 00000000
I/DEBUG ( 366): 60d58d80 df0027ad
I/DEBUG ( 366): 60d58d84 00000000
I/DEBUG ( 366): #00 60d58d88 3f7f68dd
I/DEBUG ( 366): ........ ........
I/DEBUG ( 366): #01 60d58d88 3f7f68dd
I/DEBUG ( 366): 60d58d8c 00000000
I/DEBUG ( 366): 60d58d90 bd8b02e0
I/DEBUG ( 366): 60d58d94 00000000
I/DEBUG ( 366): 60d58d98 00000000
I/DEBUG ( 366): 60d58d9c bf800000
I/DEBUG ( 366): 60d58da0 00000001
I/DEBUG ( 366): 60d58da4 60d59870 [stack:8533]
I/DEBUG ( 366): 60d58da8 60d58e2c [stack:8533]
I/DEBUG ( 366): 60d58dac 00000007
I/DEBUG ( 366): 60d58db0 60d596b0 [stack:8533]
I/DEBUG ( 366): 60d58db4 6042fe14 /data/app-lib/com.HashbangGames.DireDungeons-1/libunity.so (MultiQueryCallback<physx::PxOverlapHit>::invoke(float&, physx::Sq::PrunerPayload const*, unsigned int)+392)
I/DEBUG ( 366): #02 60d58db8 60d58e2c [stack:8533]
I/DEBUG ( 366): 60d58dbc 3d8b02e8
I/DEBUG ( 366): 60d58dc0 3f800000
I/DEBUG ( 366): 60d58dc4 3f800000
I/DEBUG ( 366): 60d58dc8 00000000
I/DEBUG ( 366): 60d58dcc 00000000
I/DEBUG ( 366): 60d58dd0 00000000
I/DEBUG ( 366): 60d58dd4 00000000
I/DEBUG ( 366): 60d58dd8 00000000
I/DEBUG ( 366): 60d58ddc 00000000
I/DEBUG ( 366): 60d58de0 00000000
I/DEBUG ( 366): 60d58de4 00000000
I/DEBUG ( 366): 60d58de8 60d58e18 [stack:8533]
I/DEBUG ( 366): 60d58dec 00000001
I/DEBUG ( 366): 60d58df0 60d59884 [stack:8533]
I/DEBUG ( 366): 60d58df4 60d58e2c [stack:8533]
I/DEBUG ( 366): ........ ........