Search Issue Tracker

Fixed in 2018.2

Fixed in 5.6, 2017.1, 2017.2, 2017.3, 2018.1

Won't Fix in 5.5

Votes

30

Found in

5.4.3p2

Issue ID

878407

Regression

No

[Android] PhysX crash when calling Physics.OverlapBoxNonAlloc or OverlapBox

Mobile

-

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

Comments (11)

  1. Cde44805abc7629bec4db77ee8a92597?d=mm

    dmytro-hreshchik

    Apr 02, 2018 13:38

    I have this crash with OverlapCapsuleNonAlloc and OverlapBoxNonAlloc in version 2017.3.0f3.

  2. 162782902a85928256d1d1e7b617ab78?d=mm

    roberto_sc

    Feb 28, 2018 23:02

    Have this crash and also with OverlapCapsule in 2017.2.0.

  3. 88280ce878af552d033172956d82c677?d=mm

    Dvorgaz

    Dec 21, 2017 16:54

    I have this crash with OverlapCapsule in version 2017.3.0f3.

  4. 4ab7b4fc7963f46d7d0313c40f90b341?d=mm

    daxiongmao

    Oct 13, 2017 07:11

    Seeing this with capsule check on both versions of 2017

  5. B6d5e6943dcbc2c367eb46ca382bc8cf?d=mm

    forrestthewoods

    Aug 17, 2017 18:25

    Update: this bug has not been fixed in 2017.1.0f3

  6. B6d5e6943dcbc2c367eb46ca382bc8cf?d=mm

    forrestthewoods

    Aug 10, 2017 17:00

    Does anyone know if this has been fixed in Unity 2017?

  7. 3b0cd7ba9bd3e86d4d73d0af9dde472f?d=mm

    Whipexx

    Jul 05, 2017 16:57

    Still occurring on unity 5.6.2; although it only happens consistently when the collider that gets hit is a trigger collider.

  8. 5031625094223b8cf90c3ad824044158?d=mm

    Pin-Bender

    Jun 29, 2017 18:12

    Why is this priority 5? It's a reproducible crash bug for a critical API on a common platform. (We are also encountering this issue on 5.6.1p4, btw.)

  9. 02e297d8c9ef6a68f22ed1aafe658ecc?d=mm

    nindim

    Jun 16, 2017 16:16

    I'm having the same issue as this with Physics.OverlapCapsuleNonAlloc and Unity 5.6.1p3, random crashes on Android within a few minutes every playthrough.

    Some conversation about this bug here:

    https://forum.unity3d.com/threads/solved-unfixable-bug-random-crashes-within-overlapbox-on-android.410868/

    It's marked as solved but only because the OP wrote his own collision detection system :/

  10. D763befb3c7a6d426700b6b927eda65f?d=mm

    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;
    }
    }

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.