Search Unity

[Solved: Unfixable BUG] Random crashes within OverlapBox on android.

Discussion in 'Physics' started by neginfinity, Jun 13, 2016.

  1. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,571
    I'm experiencing random crashes on Android which seem to originate from OverlapBox call.
    For example:
    Code (csharp):
    1.  
    2. I/DEBUG   (  106):     r0 5fae850c  r1 6e3e0610  r2 00000000  r3 65f9d260
    3. I/DEBUG   (  106):     r4 5fae8ffc  r5 5fae8fe8  r6 6e3e0610  r7 65f9d260
    4. I/DEBUG   (  106):     r8 682939d8  r9 5fae8594  sl 00000000  fp 00000000
    5. I/DEBUG   (  106):     ip 5e902c14  sp 5fae84f8  lr 5e902c4c  pc 00000000  cpsr 28000010
    6. I/DEBUG   (  106):     d0  404ccccc3c8a7d38  d1  3ea8fa603fa020e4
    7. I/DEBUG   (  106):     d2  bf7f561236734b39  d3  3ec307c0337f5612
    8. I/DEBUG   (  106):     d4  3f8a25183f8a2518  d5  fe7ffffffe7fffff
    9. I/DEBUG   (  106):     d6  c092a999c092a999  d7  fe7ffffffe7fffff
    10. I/DEBUG   (  106):     d8  00000000bf800000  d9  0000000000000000
    11. I/DEBUG   (  106):     d10 0000000000000000  d11 0000000000000000
    12. I/DEBUG   (  106):     d12 0000000000000000  d13 0000000000000000
    13. I/DEBUG   (  106):     d14 0000000000000000  d15 0000000000000000
    14. I/DEBUG   (  106):     d16 0000000000000000  d17 0000000000000000
    15. I/DEBUG   (  106):     d18 358e37bd3f7f5626  d19 000000003d936226
    16. I/DEBUG   (  106):     d20 337ffffbbf7f5615  d21 000000003d9361a0
    17. I/DEBUG   (  106):     d22 3f800000337f5612  d23 00000000b1936108
    18. I/DEBUG   (  106):     d24 0000000000000000  d25 0000000000000000
    19. I/DEBUG   (  106):     d26 3f8a2516408df1ab  d27 00000000c00d5cf8
    20. I/DEBUG   (  106):     d28 a99800003d9361a0  d29 000000003f7f5615
    21. I/DEBUG   (  106):     d30 c04ff7d8bdbb7732  d31 80000000bfa26213
    22. I/DEBUG   (  106):     scr 8000009b
    23. I/DEBUG   (  106):
    24. I/DEBUG   (  106): backtrace:
    25. I/DEBUG   (  106):     #00  pc 00000000  <unknown>
    26. I/DEBUG   (  106):     #01  pc 002aec48  /mnt/asec/<redacted>/lib/libunity.so (CastFilter::preFilter(physx::PxFilterData const&, physx::PxShape const*, physx::PxRigidActor const*, physx::PxFlags<physx::PxHitFlag::Enum, unsigned short>&)+52)
    27. I/DEBUG   (  106):     #02  pc 00b31c28  /mnt/asec/<redacted>/lib/libunity.so (MultiQueryCallback<physx::PxOverlapHit>::invoke(float&, physx::Sq::PrunerPayload const*, unsigned int)+940)
    28. I/DEBUG   (  106):     #03  pc 00c8dd24  /mnt/asec/<redacted>/lib/libunity.so (_ZN28BucketPrunerOverlapTraversalI16OBBAABBTest_SIMDLb0EEclERKN5physx2Sq16BucketPrunerCoreERKS0_RNS3_14PrunerCallbackERKNS2_9PxBounds3E.part.26+2260)
    29. I/DEBUG   (  106):     #04  pc 00c934e8  /mnt/asec/<redacted>/lib/libunity.so (physx::Sq::BucketPrunerCore::overlap(physx::Sq::ShapeData const&, physx::Sq::PrunerCallback&) const+2844)
    30. I/DEBUG   (  106):     #05  pc 00c86244  /mnt/asec/<redacted>/lib/libunity.so (physx::Sq::AABBPruner::overlap(physx::Sq::ShapeData const&, physx::Sq::PrunerCallback&) const+228)
    31. I/DEBUG   (  106):     #06  pc 00b3372c  /mnt/asec/<redacted>/lib/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+1728)
    32. I/DEBUG   (  106):     #07  pc 00b338fc  /mnt/asec/<redacted>/lib/libunity.so (physx::NpSceneQueries::overlap(physx::PxGeometry const&, physx::PxTransform const&, physx::PxHitCallback<physx::PxOverlapHit>&, physx::PxQueryFilterData const&, physx::PxQueryFilterCallback*) const+144)
    33. I/DEBUG   (  106):     #08  pc 002959b8  /mnt/asec/<redacted>/lib/libunity.so (Unity::PhysicsQuery::OverlapBoxInternal(Vector3f const&, Vector3f const&, Quaternionf const&, int, QueryTriggerInteraction, physx::PxHitCallback<physx::PxOverlapHit>&)+260)
    34. I/DEBUG   (  106):     #09  pc 00287f28  /mnt/asec/<redacted>/lib/libunity.so (PhysicsManager::OverlapBox(Vector3f const&, Vector3f const&, Quaternionf const&, int, QueryTriggerInteraction)+156)
    35. I/DEBUG   (  106):     #10  pc 005d6e18  /mnt/asec/<redacted>/lib/libunity.so (Physics_CUSTOM_INTERNAL_CALL_OverlapBox(Vector3f const&, Vector3f const&, Quaternionf const&, int, QueryTriggerInteraction)+152)
    36.  

    I'm investigating the issue at the moment, but has anyone else experienced this kind of problem?

    The issue is random and cannot be reliably reproduced.

    Unity version 5.3.3f1
     
  2. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,571
    Alright. Despite my attempts to eliminate every possible cause of the issue, and implementing object pooling, the problem refuses to disappear. After multiple calls to physics.OverlapBox, application eventually gets killed by SIGSEGV, SEGV_MAPERR, with stacktrace within libunity.so which originates from one of OverlapBox call. No matter what I do, how I do, it just unavoidably dies.

    So I'll assume it is a unity bug that only manifests itself on android.

    The only remaining workaround for this is replacing physx overlapbox collision queries.with custom collision system.

    (sarcasm)Yay(/sarcasm).
     
  3. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    I'm already made a game for Android/IPhone and WPhone. Android was the most convenient, WPhone was painful.

    1. At first, connect with adb and put that output inside this forum. (The last lines, not all the dump :) )
    2. The biggest problem was the memory allocation, Android with 500MB RAM just allow allocating max 180MB. If you are on the limit, crashes happens.
    3. Custom ROMs are not supported, however this was never a problem for my custom ROMs.

    #00 pc 00000000 <unknown>

    Seems to be a null pointer access, could be caused by not getting more RAM from the OS.
     
  4. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,571
    What specifically are you looking for? Because I have dozen of crashlogs 1 Mb each with loads debug data printed in them. There's no discernable event before the crash, except that ALL the crashes happen within "overlap box".

    Code (csharp):
    1.  
    2. D/dalvikvm( 9926): GC_CONCURRENT freed 1333K, 37% free 5843K/9196K, paused 1ms+18ms, total 58ms
    3. D/dalvikvm( 9926): GC_CONCURRENT freed 313K, 35% free 6011K/9196K, paused 5ms+2ms, total 45ms
    4. E/dalvikvm( 9926): adjustAdaptiveCoef max=4194304, min=1048576, ut=568
    5. D/dalvikvm( 9926): GC_CONCURRENT freed 306K, 33% free 6216K/9196K, paused 7ms+34ms, total 107ms
    6. D/dalvikvm( 9926): WAIT_FOR_CONCURRENT_GC blocked 3ms
    7. D/dalvikvm(19181): GC_CONCURRENT freed 457K, 28% free 6712K/9220K, paused 33ms+2ms, total 180ms
    8. D/dalvikvm(24013): GC_CONCURRENT freed 512K, 29% free 7215K/10036K, paused 45ms+13ms, total 421ms
    9. D/dalvikvm(24013): GC_CONCURRENT freed 435K, 28% free 7254K/10036K, paused 7ms+6ms, total 108ms
    10. D/dalvikvm(24013): GC_CONCURRENT freed 458K, 28% free 7313K/10036K, paused 10ms+3ms, total 100ms
    11. D/dalvikvm(24013): GC_CONCURRENT freed 547K, 28% free 7278K/10036K, paused 12ms+48ms, total 130ms
    12. I/ActivityManager(  499): Process com.sec.android.daemonapp (pid 9708) (adj 13) has died.
    13. I/ActivityManager(  499): Process com.droid27.senseflipclockweather (pid 9858) (adj 11) has died.
    14. I/ActivityManager(  499): Process com.android.providers.calendar (pid 9250) (adj 13) has died.
    15. D/dalvikvm(24013): GC_CONCURRENT freed 495K, 27% free 7370K/10036K, paused 9ms+19ms, total 132ms
    16. D/dalvikvm(24013): GC_CONCURRENT freed 561K, 27% free 7380K/10036K, paused 8ms+12ms, total 137ms
    17. I/ActivityManager(  499): Process com.sec.spp.push:RemoteDlcProcess (pid 9899) (adj 13) has died.
    18. I/ActivityManager(  499): Process com.bellshare.beweatherfree (pid 9838) (adj 11) has died.
    19. I/ActivityManager(  499): Process android.process.media (pid 9942) (adj 11) has died.
    20. D/dalvikvm(24013): GC_CONCURRENT freed 621K, 28% free 7296K/10036K, paused 22ms+11ms, total 97ms
    21. D/dalvikvm( 2996): GC_CONCURRENT freed 2108K, 32% free 19796K/28968K, paused 6ms+8ms, total 146ms
    22. D/dalvikvm(  905): GC_CONCURRENT freed 277K, 33% free 6095K/9048K, paused 4ms+10ms, total 200ms
    23. D/dalvikvm( 1361): GC_CONCURRENT freed 1482K, 36% free 10124K/15796K, paused 18ms+9ms, total 159ms
    24. D/dalvikvm(19181): GC_CONCURRENT freed 413K, 28% free 6715K/9240K, paused 5ms+2ms, total 45ms
    25. D/dalvikvm(  499): GC_EXPLICIT freed 1264K, 21% free 29444K/36928K, paused 10ms+38ms, total 395ms
    26. D/dalvikvm(10165): Late-enabling CheckJNI
    27. D/dalvikvm(10165): GC_CONCURRENT freed 671K, 32% free 5759K/8452K, paused 6ms+9ms, total 48ms
    28. D/dalvikvm(10184): Late-enabling CheckJNI
    29. I/dalvikvm(10184): Turning on JNI app bug workarounds for target SDK version 12...
    30. I/dalvikvm(10184): Could not find method android.view.Display.getState, referenced from method com.droid27.senseflipclockweather.e.a
    31. W/dalvikvm(10184): VFY: unable to resolve virtual method 14397: Landroid/view/Display;.getState ()I
    32. D/dalvikvm(10184): VFY: replacing opcode 0x6e at 0x001a
    33. I/dalvikvm(10184): Could not find method android.app.AlarmManager.setExactAndAllowWhileIdle, referenced from method com.droid27.senseflipclockweather.receivers.a.a
    34. W/dalvikvm(10184): VFY: unable to resolve virtual method 144: Landroid/app/AlarmManager;.setExactAndAllowWhileIdle (IJLandroid/app/PendingIntent;)V
    35. D/dalvikvm(10184): VFY: replacing opcode 0x6e at 0x0081
    36. D/dalvikvm(10184): GC_CONCURRENT freed 671K, 32% free 5799K/8492K, paused 7ms+3ms, total 80ms
    37. I/dalvikvm(10184): Could not find method android.app.Notification$Builder.setLocalOnly, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zza
    38. W/dalvikvm(10184): VFY: unable to resolve virtual method 291: Landroid/app/Notification$Builder;.setLocalOnly (Z)Landroid/app/Notification$Builder;
    39. D/dalvikvm(10184): VFY: replacing opcode 0x6e at 0x00c8
    40. I/dalvikvm(10184): DexOpt: access denied from Lcom/google/android/gms/common/GooglePlayServicesUtil; to field Landroid/app/Notification;.extras
    41. W/dalvikvm(10184): VFY: unable to resolve instance field 34
    42. D/dalvikvm(10184): VFY: replacing opcode 0x54 at 0x00e7
    43. I/dalvikvm(10184): Could not find method android.os.UserManager.getApplicationRestrictions, referenced from method com.google.android.gms.common.zze.zzaq
    44. W/dalvikvm(10184): VFY: unable to resolve virtual method 1657: Landroid/os/UserManager;.getApplicationRestrictions (Ljava/lang/String;)Landroid/os/Bundle;
    45. D/dalvikvm(10184): VFY: replacing opcode 0x6e at 0x0012
    46. E/dalvikvm(10184): Could not find class 'android.app.AppOpsManager', referenced from method com.google.android.gms.common.zze.zzb
    47. W/dalvikvm(10184): VFY: unable to resolve check-cast 32 (Landroid/app/AppOpsManager;) in Lcom/google/android/gms/common/zze;
    48. D/dalvikvm(10184): VFY: replacing opcode 0x1f at 0x000e
    49. I/dalvikvm(10184): Could not find method android.content.pm.PackageManager.getPackageInstaller, referenced from method com.google.android.gms.common.zze.zzi
    50. W/dalvikvm(10184): VFY: unable to resolve virtual method 607: Landroid/content/pm/PackageManager;.getPackageInstaller ()Landroid/content/pm/PackageInstaller;
    51. D/dalvikvm(10184): VFY: replacing opcode 0x6e at 0x000b
    52. I/dalvikvm(10184): Could not find method android.app.AlarmManager.getNextAlarmClock, referenced from method com.droid27.senseflipclockweather.d.a
    53. W/dalvikvm(10184): VFY: unable to resolve virtual method 143: Landroid/app/AlarmManager;.getNextAlarmClock ()Landroid/app/AlarmManager$AlarmClockInfo;
    54. D/dalvikvm(10184): VFY: replacing opcode 0x6e at 0x0719
    55. D/dalvikvm(10184): GC_CONCURRENT freed 453K, 33% free 5746K/8492K, paused 7ms+11ms, total 66ms
    56. D/dalvikvm(10184): GC_CONCURRENT freed 243K, 31% free 5891K/8492K, paused 3ms+4ms, total 35ms
    57. I/DEBUG   (  109): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    58. I/DEBUG   (  109): Build fingerprint: 'samsung/espressorfxx/espressorf:4.2.2/JDQ39/P3100XWDMK1:user/release-keys'
    59. I/DEBUG   (  109): Revision: '10'
    60. I/DEBUG   (  109): pid: 7485, tid: 7513, name: UnityMain  >>> <redacted> <<<
    61. I/DEBUG   (  109): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000
    62. I/ActivityManager(  499): Process com.sec.android.app.keyguard (pid 9808) (adj 9) has died.
    63. I/ActivityManager(  499): Process com.bellshare.beweatherfree (pid 10165) (adj 11) has died.
    64. I/ActivityManager(  499): Process com.droid27.senseflipclockweather (pid 10184) (adj 13) has died.
    65. I/DEBUG   (  109):     r0 5fb49c68  r1 6608bc20  r2 5f1c36d0  r3 00000000
    66. I/DEBUG   (  109):     r4 5fb4a6e4  r5 5fb4a6d0  r6 6608bc20  r7 670fd670
    67. I/DEBUG   (  109):     r8 65115788  r9 5fb49c7c  sl 00000000  fp 00000000
    68. I/DEBUG   (  109):     ip 5e952c74  sp 5fb49bd8  lr 5f1c36e4  pc 00000000  cpsr 28000010
    69. I/DEBUG   (  109):     d0  3f80000936393df6  d1  00000000358637c4
    70. I/DEBUG   (  109):     d2  bf8e06c2bf8e06c2  d3  3c257e00f5454086
    71. I/DEBUG   (  109):     d4  bf9d9163bf9d9163  d5  fe7ffffffe7fffff
    72. I/DEBUG   (  109):     d6  bf8e06c2bf8e06c2  d7  fe7ffffffe7fffff
    73. I/DEBUG   (  109):     d8  00000000bf800000  d9  0000000000000000
    74. I/DEBUG   (  109):     d10 0000000000000000  d11 0000000000000000
    75. I/DEBUG   (  109):     d12 0000000000000000  d13 0000000000000000
    76. I/DEBUG   (  109):     d14 0000000000000000  d15 0000000000000000
    77. I/DEBUG   (  109):     d16 0000000000000000  d17 0000000000000000
    78. I/DEBUG   (  109):     d18 36393df63f800008  d19 0000000035c637c4
    79. I/DEBUG   (  109):     d20 35ec442ebf800000  d21 00000000b500000e
    80. I/DEBUG   (  109):     d22 bf800001b5ec442e  d23 00000000ab500000
    81. I/DEBUG   (  109):     d24 0000000000000000  d25 0000000000000000
    82. I/DEBUG   (  109):     d26 3f9d91543f8e06cb  d27 80000000403faebc
    83. I/DEBUG   (  109):     d28 2980000034c00000  d29 00000000bf800000
    84. I/DEBUG   (  109):     d30 754540a16c54eec8  d31 800000007545409f
    85. I/DEBUG   (  109):     scr 8000009f
    86. I/DEBUG   (  109):
    87. I/DEBUG   (  109): backtrace:
    88. I/DEBUG   (  109):     #00  pc 00000000  <unknown>
    89. I/DEBUG   (  109):     #01  pc 00b216e0  /mnt/asec/<redacted>-1/lib/libunity.so (physx::Ext::Joint<physx::PxD6Joint, physx::PxD6JointGeneratedValues>::getBreakForce(float&, float&) const+16)
    90. I/DEBUG   (  109):     #02  pc 002b0ca8  /mnt/asec/<redacted>-1/lib/libunity.so (CastFilter::preFilter(physx::PxFilterData const&, physx::PxShape const*, physx::PxRigidActor const*, physx::PxFlags<physx::PxHitFlag::Enum, unsigned short>&)+52)
    91. I/DEBUG   (  109):     #03  pc 00b44a98  /mnt/asec/<redacted>-1/lib/libunity.so (MultiQueryCallback<physx::PxOverlapHit>::invoke(float&, physx::Sq::PrunerPayload const*, unsigned int)+940)
    92. I/DEBUG   (  109):     #04  pc 00ca0b8c  /mnt/asec/<redacted>-1/lib/libunity.so (_ZN28BucketPrunerOverlapTraversalI16OBBAABBTest_SIMDLb0EEclERKN5physx2Sq16BucketPrunerCoreERKS0_RNS3_14PrunerCallbackERKNS2_9PxBounds3E.part.26+2260)
    93. I/DEBUG   (  109):     #05  pc 00ca6350  /mnt/asec/<redacted>-1/lib/libunity.so (physx::Sq::BucketPrunerCore::overlap(physx::Sq::ShapeData const&, physx::Sq::PrunerCallback&) const+2844)
    94. I/DEBUG   (  109):     #06  pc 00c990ac  /mnt/asec/<redacted>-1/lib/libunity.so (physx::Sq::AABBPruner::overlap(physx::Sq::ShapeData const&, physx::Sq::PrunerCallback&) const+228)
    95. I/DEBUG   (  109):     #07  pc 00b4659c  /mnt/asec/<redacted>-1/lib/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+1728)
    96. I/DEBUG   (  109):     #08  pc 00b4676c  /mnt/asec/<redacted>-1/lib/libunity.so (physx::NpSceneQueries::overlap(physx::PxGeometry const&, physx::PxTransform const&, physx::PxHitCallback<physx::PxOverlapHit>&, physx::PxQueryFilterData const&, physx::PxQueryFilterCallback*) const+144)
    97. I/DEBUG   (  109):     #09  pc 00297a18  /mnt/asec/<redacted>-1/lib/libunity.so (Unity::PhysicsQuery::OverlapBoxInternal(Vector3f const&, Vector3f const&, Quaternionf const&, int, QueryTriggerInteraction, physx::PxHitCallback<physx::PxOverlapHit>&)+260)
    98. I/DEBUG   (  109):     #10  pc 00289e60  /mnt/asec/<redacted>-1/lib/libunity.so (PhysicsManager::OverlapBoxNonAlloc(Vector3f const&, Vector3f const&, Quaternionf const&, Collider**, int, int, QueryTriggerInteraction)+160)
    99. I/DEBUG   (  109):     #11  pc 005e3c18  /mnt/asec/<redacted>-1/lib/libunity.so (Physics_CUSTOM_INTERNAL_CALL_OverlapBoxNonAlloc(Vector3f const&, Vector3f const&, MonoArray*, Quaternionf const&, int, QueryTriggerInteraction)+204)
    100. I/DEBUG   (  109):     #12  pc 0000caec  <unknown>
    101. I/DEBUG   (  109):
    102. I/DEBUG   (  109): stack:
    103. I/DEBUG   (  109):          5fb49b98  00000000  
    104. I/DEBUG   (  109):          5fb49b9c  00000000  
    105. I/DEBUG   (  109):          5fb49ba0  00000000  
    106. I/DEBUG   (  109):          5fb49ba4  00000000  
    107. I/DEBUG   (  109):          5fb49ba8  00000000  
    108. I/DEBUG   (  109):          5fb49bac  00000000  
    109. I/DEBUG   (  109):          5fb49bb0  00000000  
    110. I/DEBUG   (  109):          5fb49bb4  00000000  
    111. I/DEBUG   (  109):          5fb49bb8  00000000  
    112. I/DEBUG   (  109):          5fb49bbc  00000000  
    113. I/DEBUG   (  109):          5fb49bc0  00000000  
    114. I/DEBUG   (  109):          5fb49bc4  00000000  
    115. I/DEBUG   (  109):          5fb49bc8  00000000  
    116. I/DEBUG   (  109):          5fb49bcc  00000000  
    117. I/DEBUG   (  109):          5fb49bd0  df0027ad  
    118. I/DEBUG   (  109):          5fb49bd4  00000000  
    119. I/DEBUG   (  109):     #00  5fb49bd8  670fd670  
    120. I/DEBUG   (  109):          ........  ........
    121. I/DEBUG   (  109):     #01  5fb49bd8  670fd670  
    122. I/DEBUG   (  109):          5fb49bdc  5e952cac  /mnt/asec/<redacted>-1/lib/libunity.so (CastFilter::preFilter(physx::PxFilterData const&, physx::PxShape const*, physx::PxRigidActor const*, physx::PxFlags<physx::PxHitFlag::Enum, unsigned short>&)+56)
    123. I/DEBUG   (  109):     #02  5fb49be0  00000000  
    124. 't find static field Landroid/os/Build;.SUPPORTED_ABIS
    125. W/dalvikvm(10234): VFY: unable to resolve static field 259 (SUPPORTED_ABIS) in Landroid/os/Build;
    126. D/dalvikvm(10234): VFY: replacing opcode 0x62 at 0x0095
    127. I/dalvikvm(10234): Could not find method android.app.ActivityManager.isLowRamDevice, referenced from method com.google.android.apps.gsa.shared.util.ce.bf
    128. W/dalvikvm(10234): VFY: unable to resolve virtual method 400: Landroid/app/ActivityManager;.isLowRamDevice ()Z
    129. D/dalvikvm(10234): VFY: replacing opcode 0x6e at 0x0010
    130. W/dalvikvm(10234): Unable to resolve superclass of Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession; (505)
    131. W/dalvikvm(10234): Link of class 'Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession;' failed
    132. E/dalvikvm(10234): Could not find class 'com.google.android.apps.gsa.assist.GsaVoiceInteractionSession', referenced from method com.google.android.apps.gsa.assist.GsaVoiceInteractionSession_MembersInjector.au
    133. W/dalvikvm(10234): VFY: unable to resolve check-cast 2945 (Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession;) in Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession_MembersInjector;
    134. D/dalvikvm(10234): VFY: replacing opcode 0x1f at 0x0000
    135. W/dalvikvm(10234): Unable to resolve superclass of Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession; (505)
    136. W/dalvikvm(10234): Link of class 'Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession;' failed
    137. I/dalvikvm(10234): DexOpt: unable to optimize instance field ref 0x4622 at 0x14 in Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession_MembersInjector;.au
    138. W/dalvikvm(10234): Unable to resolve superclass of Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession; (505)
    139. W/dalvikvm(10234): Link of class 'Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession;' failed
    140. I/dalvikvm(10234): DexOpt: unable to optimize instance field ref 0x461e at 0x1e in Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession_MembersInjector;.au
    141. W/dalvikvm(10234): Unable to resolve superclass of Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession; (505)
    142. W/dalvikvm(10234): Link of class 'Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession;' failed
    143. I/dalvikvm(10234): DexOpt: unable to optimize instance field ref 0x4642 at 0x26 in Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession_MembersInjector;.au
    144. W/dalvikvm(10234): Unable to resolve superclass of Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession; (505)
    145. W/dalvikvm(10234): Link of class 'Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession;' failed
    146. I/dalvikvm(10234): DexOpt: unable to optimize instance field ref 0x4643 at 0x2e in Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession_MembersInjector;.au
    147. W/dalvikvm(10234): Unable to resolve superclass of Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession; (505)
    148. W/dalvikvm(10234): Link of class 'Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession;' failed
    149. I/dalvikvm(10234): DexOpt: unable to optimize instance field ref 0x4621 at 0x38 in Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession_MembersInjector;.au
    150. W/dalvikvm(10234): Unable to resolve superclass of Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession; (505)
    151. W/dalvikvm(10234): Link of class 'Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession;' failed
    152. I/dalvikvm(10234): DexOpt: unable to optimize instance field ref 0x4644 at 0x40 in Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession_MembersInjector;.au
    153. W/dalvikvm(10234): Unable to resolve superclass of Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession; (505)
    154. W/dalvikvm(10234): Link of class 'Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession;' failed
    155. I/dalvikvm(10234): DexOpt: unable to optimize instance field ref 0x4620 at 0x48 in Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession_MembersInjector;.au
    156. W/dalvikvm(10234): Unable to resolve superclass of Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession; (505)
    157. W/dalvikvm(10234): Link of class 'Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession;' failed
    158. I/dalvikvm(10234): DexOpt: unable to optimize instance field ref 0x4625 at 0x50 in Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession_MembersInjector;.au
    159. W/dalvikvm(10234): Unable to resolve superclass of Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession; (505)
    160. W/dalvikvm(10234): Link of class 'Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession;' failed
    161. I/dalvikvm(10234): DexOpt: unable to optimize instance field ref 0x4626 at 0x5a in Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession_MembersInjector;.au
    162. W/dalvikvm(10234): Unable to resolve superclass of Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession; (505)
    163. W/dalvikvm(10234): Link of class 'Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession;' failed
    164. I/dalvikvm(10234): DexOpt: unable to optimize instance field ref 0x4627 at 0x64 in Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession_MembersInjector;.au
    165. W/dalvikvm(10234): Unable to resolve superclass of Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession; (505)
    166. W/dalvikvm(10234): Link of class 'Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession;' failed
    167. I/dalvikvm(10234): DexOpt: unable to optimize instance field ref 0x4628 at 0x6c in Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession_MembersInjector;.au
    168. W/dalvikvm(10234): Unable to resolve superclass of Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession; (505)
    169. W/dalvikvm(10234): Link of class 'Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession;' failed
    170. I/dalvikvm(10234): DexOpt: unable to optimize instance field ref 0x4629 at 0x74 in Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession_MembersInjector;.au
    171. W/dalvikvm(10234): Unable to resolve superclass of Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession; (505)
    172. W/dalvikvm(10234): Link of class 'Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession;' failed
    173. I/dalvikvm(10234): DexOpt: unable to optimize instance field ref 0x462a at 0x7e in Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession_MembersInjector;.au
    174. W/dalvikvm(10234): Unable to resolve superclass of Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession; (505)
    175. W/dalvikvm(10234): Link of class 'Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession;' failed
    176. I/dalvikvm(10234): DexOpt: unable to optimize instance field ref 0x462b at 0x88 in Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession_MembersInjector;.au
    177. W/dalvikvm(10234): Unable to resolve superclass of Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession; (505)
    178. W/dalvikvm(10234): Link of class 'Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession;' failed
    179. I/dalvikvm(10234): DexOpt: unable to optimize instance field ref 0x461f at 0x92 in Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession_MembersInjector;.au
    180. W/dalvikvm(10234): Unable to resolve superclass of Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession; (505)
    181. W/dalvikvm(10234): Link of class 'Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession;' failed
    182. I/dalvikvm(10234): DexOpt: unable to optimize instance field ref 0x462c at 0x9c in Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession_MembersInjector;.au
    183. W/dalvikvm(10234): Unable to resolve superclass of Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession; (505)
    184. W/dalvikvm(10234): Link of class 'Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession;' failed
    185. I/dalvikvm(10234): DexOpt: unable to optimize instance field ref 0x462d at 0xa4 in Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession_MembersInjector;.au
    186. W/dalvikvm(10234): Unable to resolve superclass of Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession; (505)
    187. W/dalvikvm(10234): Link of class 'Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession;' failed
    188. I/dalvikvm(10234): DexOpt: unable to optimize instance field ref 0x462e at 0xae in Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession_MembersInjector;.au
    189. W/dalvikvm(10234): Unable to resolve superclass of Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession; (505)
    190. W/dalvikvm(10234): Link of class 'Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession;' failed
    191. I/dalvikvm(10234): DexOpt: unable to optimize instance field ref 0x462f at 0xb8 in Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession_MembersInjector;.au
    192. W/dalvikvm(10234): Unable to resolve superclass of Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession; (505)
    193. W/dalvikvm(10234): Link of class 'Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession;' failed
    194. I/dalvikvm(10234): DexOpt: unable to optimize instance field ref 0x4630 at 0xc2 in Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession_MembersInjector;.au
    195. W/dalvikvm(10234): Unable to resolve superclass of Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession; (505)
    196. W/dalvikvm(10234): Link of class 'Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession;' failed
    197. I/dalvikvm(10234): DexOpt: unable to optimize instance field ref 0x4631 at 0xcc in Lcom/google/android/apps/gsa/assist/GsaVoiceInteractionSession_MembersInjector;.au
    198. W/dalvikvm(10234): Unable to resolve superclass of Lcom/google/android/apps/gsa/tasks/VelvetBackgroundTasksJobService; (154)
    199. W/dalvikvm(10234): Link of class 'Lcom/google/android/apps/gsa/tasks/VelvetBackgroundTasksJobService;' failed
    200. E/dalvikvm(10234): Could not find class 'com.google.android.apps.gsa.tasks.VelvetBackgroundTasksJobService', referenced from method com.google.android.apps.gsa.tasks.l.au
    201. W/dalvikvm(10234): VFY: unable to resolve check-cast 9755 (Lcom/google/android/apps/gsa/tasks/VelvetBackgroundTasksJobService;) in Lcom/google/android/apps/gsa/tasks/l;
    202. D/dalvikvm(10234): VFY: replacing opcode 0x1f at 0x0000
    203. W/dalvikvm(10234): Unable to resolve superclass of Lcom/google/android/apps/gsa/tasks/VelvetBackgroundTasksJobService; (154)
    204. W/dalvikvm(10234): Link of class 'Lcom/google/android/apps/gsa/tasks/VelvetBackgroundTasksJobService;' failed
    205. I/dalvikvm(10234): DexOpt: unable to optimize instance field ref 0x981e at 0x12 in Lcom/google/android/apps/gsa/tasks/l;.au
    206. D/dalvikvm(10234): DexOpt: couldn't find static field Landroid/os/Build;.SUPPORTED_ABIS
    207. W/dalvikvm(10234): VFY: unable to resolve static field 259 (SUPPORTED_ABIS) in Landroid/os/Build;
    208. D/dalvikvm(10234): VFY: replacing opcode 0x62 at 0x0063
    209. D/dalvikvm(10234): GC_CONCURRENT freed 725K, 33% free 5762K/8508K, paused 5ms+4ms, total 48ms
    210. I/dalvikvm(10234): Could not find method android.os.UserManager.getUserProfiles, referenced from method com.google.android.apps.gsa.shared.util.cd.bd
    211. W/dalvikvm(10234): VFY: unable to resolve virtual method 2481: Landroid/os/UserManager;.getUserProfiles ()Ljava/util/List;
    212. D/dalvikvm(10234): VFY: replacing opcode 0x6e at 0x001c
    213. D/dalvikvm(10234): GC_CONCURRENT freed 130K, 29% free 6101K/8508K, paused 7ms+10ms, total 57ms
    214. D/dalvikvm(10234): WAIT_FOR_CONCURRENT_GC blocked 14ms
    215. I/dalvikvm(10234): Could not find method android.app.AlarmManager.setExactAndAllowWhileIdle, referenced from method com.google.android.apps.gsa.search.core.r.c.b
    216. W/dalvikvm(10234): VFY: unable to resolve virtual method 409: Landroid/app/AlarmManager;.setExactAndAllowWhileIdle (IJLandroid/app/PendingIntent;)V
    217. D/dalvikvm(10234): VFY: replacing opcode 0x6e at 0x000e
    218. I/dalvikvm(10234): Could not find method android.app.AlarmManager.setExact, referenced from method com.google.android.apps.gsa.search.core.r.c.setExact
    219. W/dalvikvm(10234): VFY: unable to resolve virtual method 408: Landroid/app/AlarmManager;.setExact (IJLandroid/app/PendingIntent;)V
    220. D/dalvikvm(10234): VFY: replacing opcode 0x6e at 0x000e
    221. I/dalvikvm(10234): Could not find method android.content.Context.checkSelfPermission, referenced from method com.google.android.apps.gsa.d.a.e
    222. W/dalvikvm(10234): VFY: unable to resolve virtual method 949: Landroid/content/Context;.checkSelfPermission (Ljava/lang/String;)I
    223. D/dalvikvm(10234): VFY: replacing opcode 0x6e at 0x0006
    224. I/dalvikvm(10234): Could not find method android.content.IntentFilter.addDataSchemeSpecificPart, referenced from method com.google.android.apps.gsa.search.core.r.Mn
    225. W/dalvikvm(10234): VFY: unable to resolve virtual method 1095: Landroid/content/IntentFilter;.addDataSchemeSpecificPart (Ljava/lang/String;I)V
    226. D/dalvikvm(10234): VFY: replacing opcode 0x6e at 0x0050
    227. I/dalvikvm(10234): Could not find method android.app.Notification$Builder.setLocalOnly, referenced from method com.google.android.gms.common.f.d
    228. W/dalvikvm(10234): VFY: unable to resolve virtual method 607: Landroid/app/Notification$Builder;.setLocalOnly (Z)Landroid/app/Notification$Builder;
    229. D/dalvikvm(10234): VFY: replacing opcode 0x6e at 0x00fe
    230. I/dalvikvm(10234): DexOpt: access denied from Lcom/google/android/gms/common/f; to field Landroid/app/Notification;.extras
    231. W/dalvikvm(10234): VFY: unable to resolve instance field 64
    232. D/dalvikvm(10234): VFY: replacing opcode 0x54 at 0x011d
    233. I/dalvikvm(10234): Could not find method android.app.Notification$Builder.setLocalOnly, referenced from method com.google.android.gms.common.f.e
    234. W/dalvikvm(10234): VFY: unable to resolve virtual method 607: Landroid/app/Notification$Builder;.setLocalOnly (Z)Landroid/app/Notification$Builder;
    235. D/dalvikvm(10234): VFY: replacing opcode 0x6e at 0x00cf
    236. I/dalvikvm(10234): DexOpt: access denied from Lcom/google/android/gms/common/f; to field Landroid/app/Notification;.extras
    237. W/dalvikvm(10234): VFY: unable to resolve instance field 64
    238. D/dalvikvm(10234): VFY: replacing opcode 0x54 at 0x00ee
    239. I/dalvikvm(10234): Could not find method android.content.pm.PackageManager.getPackageInstaller, referenced from method com.google.android.gms.common.h.L
    240. W/dalvikvm(10234): VFY: unable to resolve virtual method 1184: Landroid/content/pm/PackageManager;.getPackageInstaller ()Landroid/content/pm/PackageInstaller;
    241. D/dalvikvm(10234): VFY: replacing opcode 0x6e at 0x000e
    242. I/dalvikvm(10234): Could not find method android.os.UserManager.getApplicationRestrictions, referenced from method com.google.android.gms.common.h.L
    243. W/dalvikvm(10234): VFY: unable to resolve virtual method 2477: Landroid/os/UserManager;.getApplicationRestrictions (Ljava/lang/String;)Landroid/os/Bundle;
    244. D/dalvikvm(10234): VFY: replacing opcode 0x6e at 0x0047
    245. E/dalvikvm(10234): Could not find class 'android.app.AppOpsManager', referenced from method com.google.android.gms.common.h.c
    246. W/dalvikvm(10234): VFY: unable to resolve check-cast 97 (Landroid/app/AppOpsManager;) in Lcom/google/android/gms/common/h;
    247. D/dalvikvm(10234): VFY: replacing opcode 0x1f at 0x0010
    248. W/dalvikvm(10234): Exception Ljava/lang/RuntimeException; thrown while initializing Lcom/google/common/util/concurrent/l;
    249. I/dalvikvm(10234): Could not find method android.service.voice.VoiceInteractionService.isActiveService, referenced from method com.google.android.apps.gsa.w.c.d.a
    250. W/dalvikvm(10234): VFY: unable to resolve static method 2601: Landroid/service/voice/VoiceInteractionService;.isActiveService (Landroid/content/Context;Landroid/content/ComponentName;)Z
    251. D/dalvikvm(10234): VFY: replacing opcode 0x71 at 0x0043
    252. E/dalvikvm(10234): adjustAdaptiveCoef max=4194304, min=1048576, ut=568
    253. D/dalvikvm(10234): GC_CONCURRENT freed 313K, 28% free 6266K/8600K, paused 10ms+79ms, total 122ms
    254. E/dalvikvm(10234): Could not find class 'android.content.pm.LauncherApps', referenced from method com.google.android.apps.gsa.search.shared.multiuser.l.connect
    255. W/dalvikvm(10234): VFY: unable to resolve check-cast 208 (Landroid/content/pm/LauncherApps;) in Lcom/google/android/apps/gsa/search/shared/multiuser/l;
    256. D/dalvikvm(10234): VFY: replacing opcode 0x1f at 0x0089
    257. D/dalvikvm(10273): Late-enabling CheckJNI
    258. D/dalvikvm(19135): GC_CONCURRENT freed 407K, 35% free 5559K/8436K, paused 9ms+17ms, total 352ms
    259. I/ActivityManager(  499): Process <redacted> (pid 7485) (adj 0) has died.
    260. W/ActivityManager(  499): Force removing ActivityRecord{42aa0b98 u0 <redacted>/com.unity3d.player.UnityPlayerActivity}: app died, no saved state
    261. W/ActivityManager(  499): mDVFSHelper.acquire()
    262. W/ActivityManager(  499): mDVFSHelper.release()
    263.  
    264.  
    265.  

    1GB system, memory use 100..150 mb. Crash happens regardless of memory usage, app had no issue running with 300 mb of ram allocation.

    No custom roms.
     
  5. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,571
    I wrote my own collision system and replaced Physics.OverlapBox with my own function.

    Have not experienced any crashes since then. Collision queries take a bit longer, but the program does not die randomly anymore.

    So, it is a physx bug, specific to android.
     
  6. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    The Physics.OverlapBox method is quite new in Unity, I had have to write my own solution with OverlapSphere. Probably OverlapBox is broken. I guess Unity's code looks very similar, because a sphere check is very fast and I guess even with the overhead this solution would be faster than a 'real' box check.

    Code (CSharp):
    1. public static List<Collider> OverlapBox2(Bounds bounds, int layerMask) {
    2.         Vector3 center = bounds.center;
    3.         Vector3 onePoint = new Vector3(center.x + bounds.size.x / 2, center.y + bounds.size.y / 2, center.z + bounds.size.z / 2);
    4.         float radius = Vector3.Distance(center, onePoint);
    5.  
    6.         List<Collider> inBox = new List<Collider>();
    7.         Collider[] hitColliders = Physics.OverlapSphere(center, radius, layerMask);
    8.         foreach (Collider col in hitColliders) {
    9.  
    10.             if (bounds.Intersects(col.bounds)) {
    11.                 // Inside box
    12.                 inBox.Add(col);
    13.             }
    14.         }
    15.  
    16.         return inBox;
    17.     }
    If this doesn't crash for you, then there is a high probability that the OverlapBox is broken.

    The adb output shows the state of your device, also shows the errors, the warnings, what tasks running, what tasks are closed to run your application and much more.
     
    Last edited: Oct 13, 2017
  7. ganaware

    ganaware

    Joined:
    Jun 19, 2015
    Posts:
    6
    We encounterd the same problem for Physics.OverlapBoxNonAlloc() on 5.3.5p1 and 5.4.0f2.
    It must be broken!
     
  8. melkor414

    melkor414

    Joined:
    Mar 11, 2013
    Posts:
    1
    Hi. We have same problem on 5.3.4p1.
    Did anyone posted a bug with this?
     
  9. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,571
    It's been a long time ago, so I forgot if I filed a bug regarding this one. Feel free to do it yourself.

    As I said, in my case I rolled out replacement collision detection system which supported OBBs and nothing more.
     
  10. jfabregat

    jfabregat

    Joined:
    Jun 29, 2016
    Posts:
    3
    I have found a crash with Physics.OverlapBoxNonAlloc() in android, but I have not seen the crash with other Physics.OverlapBox(), is it related with the NonAlloc version or it can be happening in both alloc and non alloc?
     
  11. Bunzaga

    Bunzaga

    Joined:
    Jan 9, 2009
    Posts:
    202
    It happens with both. I've just run into this myself, I assumed it was due to a long ass algorithm for generating a dungeon, so I broke it up into signals and commands (I'm using StrangeIOC), that helped a little, but it still happens when the dungeon generation has to grind a bit longer. I've also tried yield returning if the path has been blocked, etc etc.

    I tried switching to non-alloc version of overlap box, and it did seem to reduce the crash, but it still did happen eventually. It's like the algorithm just isn't releasing memory, so every time you call it, it's adding up and adding up.

    I also should mention, I'm using beta 5.6.0b9, but it seems that doesn't really matter for this case.

    BTW: It has NEVER happened in Editor, just on Android, both on a Pixel, and an older Droid XT1080.
     
  12. Bunzaga

    Bunzaga

    Joined:
    Jan 9, 2009
    Posts:
    202
    In the mean time, this just returns true, if a collision happened, or false if it didn't...
    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public static class CollisionCheck
    4. {
    5.  
    6.     private static Vector3 _AB = new Vector3(); // Direction A to B
    7.     private static float[] _R = new float[9]; // 3x3 Rotation
    8.     private static float[] _AbsR = new float[9]; // 3x3 Rotation
    9.     private static Vector3 _AX = new Vector3(); // A Axis
    10.     private static Vector3 _BX = new Vector3(); // B Axis
    11.  
    12.     private static Vector3 _v1 = new Vector3();
    13.     private static Vector3 _v2 = new Vector3();
    14.     private static Vector3 _v3 = new Vector3();
    15.  
    16.     private static float[] _aRot = new float[9];
    17.     private static float[] _bRot = new float[9];
    18.  
    19.     private static float ar = 0.0f, br = 0.0f;
    20.  
    21.     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 };
    22.  
    23.     // Adapted from: http://www.gamasutra.com/view/feature/131790/simple_intersection_tests_for_games.php?print=1
    24.     public static bool Box_Box (Vector3 aPos, Vector3 aSize, Quaternion aQuat, Vector3 bPos, Vector3 bSize, Quaternion bQuat)
    25.     {
    26.         ar = 0.0f;
    27.         br = 0.0f;
    28.  
    29.         QuaternionToFloatArray(aQuat, _aRot);
    30.         QuaternionToFloatArray(bQuat, _bRot);
    31.  
    32.  
    33.         for (int i = 0, i1 = 0; i < 3; i++, i1 += 3)
    34.         {
    35.             _AX.Set(_aRot[i1], _aRot[i1 + 1], _aRot[i1 + 2]);
    36.             for (int j = 0, j1 = 0; j < 3; j++, j1 += 3)
    37.             {
    38.                 _BX.Set(_bRot[j1], _bRot[j1 + 1], _bRot[j1 + 2]);
    39.                 _R[i1 + j] = Vector3.Dot(_AX, _BX);
    40.             }
    41.         }
    42.  
    43.         _AB = bPos - aPos;
    44.  
    45.         _v1.Set(_aRot[0], _aRot[1], _aRot[2]);
    46.         _v2.Set(_aRot[3], _aRot[4], _aRot[5]);
    47.         _v3.Set(_aRot[6], _aRot[7], _aRot[8]);
    48.  
    49.         _AB.Set(Vector3.Dot(_AB, _v1), Vector3.Dot(_AB, _v2), Vector3.Dot(_AB, _v3));
    50.  
    51.         for (int i = 0; i < 9; i++)
    52.         {
    53.             _AbsR[i] = Mathf.Abs(_R[i]) + 0.001f;
    54.         }
    55.         // Test axes L = A0, L = A1, L = A2
    56.         for (int i = 0, i1 = 0; i < 3; i++, i1 += 3)
    57.         {
    58.             ar = aSize[i];
    59.             br = (bSize[0] * _AbsR[i1]) + (bSize[1] * _AbsR[i1 + 1]) + (bSize[2] * _AbsR[i1 + 2]);
    60.             if (Mathf.Abs(_AB[i]) > (ar + br)) { return false; }
    61.         }
    62.         // Test axes L = B0, L = B1, L = B2
    63.         for (int i = 0; i < 3; i++)
    64.         {
    65.             ar = (aSize[0] * _AbsR[i]) + (aSize[1] * _AbsR[i + 3]) + (aSize[2] * _AbsR[i + 6]);
    66.             br = bSize[i];
    67.             if (Mathf.Abs((_AB[0] * _R[i]) + (_AB[1] * _R[i + 3]) + (_AB[2] * _R[i + 6])) > (ar + br)) { return false; }
    68.         }
    69.         // Test axis L = A0 x B0
    70.         ar = (aSize[1] * _AbsR[6]) + (aSize[2] * _AbsR[3]);
    71.         br = (bSize[1] * _AbsR[2]) + (bSize[2] * _AbsR[1]);
    72.         if (Mathf.Abs(_AB[2] * _R[3] - _AB[1] * _R[6]) > (ar + br)) { return false; }
    73.         // Test axis L = A0 x B1
    74.         ar = (aSize[1] * _AbsR[7]) + (aSize[2] * _AbsR[4]);
    75.         br = (bSize[0] * _AbsR[2]) + (bSize[2] * _AbsR[0]);
    76.         if (Mathf.Abs((_AB[2] * _R[4]) - (_AB[1] * _R[7])) > (ar + br)) { return false; }
    77.         // Test axis L = A0 x B2
    78.         ar = aSize[1] * _AbsR[8] + aSize[2] * _AbsR[5];
    79.         br = bSize[0] * _AbsR[1] + bSize[1] * _AbsR[0];
    80.         if (Mathf.Abs((_AB[2] * _R[5]) - (_AB[1] * _R[8])) > (ar + br)) { return false; }
    81.         // Test axis L = A1 x B0
    82.         ar = (aSize[0] * _AbsR[6]) + (aSize[2] * _AbsR[0]);
    83.         br = (bSize[1] * _AbsR[5]) + (bSize[2] * _AbsR[4]);
    84.         if (Mathf.Abs((_AB[0] * _R[6]) - (_AB[2] * _R[0])) > (ar + br)) { return false; }
    85.         // Test axis L = A1 x B1
    86.         ar = (aSize[0] * _AbsR[7]) + (aSize[2] * _AbsR[1]);
    87.         br = (bSize[0] * _AbsR[5]) + (bSize[2] * _AbsR[3]);
    88.         if (Mathf.Abs((_AB[0] * _R[7]) - (_AB[2] * _R[1])) > (ar + br)) { return false; }
    89.         // Test axis L = A1 x B2
    90.         ar = (aSize[0] * _AbsR[8]) + (aSize[2] * _AbsR[2]);
    91.         br = (bSize[0] * _AbsR[4]) + (bSize[1] * _AbsR[3]);
    92.         if (Mathf.Abs((_AB[0] * _R[8]) - (_AB[2] * _R[2])) > (ar + br)) { return false; }
    93.         // Test axis L = A2 x B0
    94.         ar = (aSize[0] * _AbsR[3]) + (aSize[1] * _AbsR[0]);
    95.         br = (bSize[1] * _AbsR[8]) + (bSize[2] * _AbsR[7]);
    96.         if (Mathf.Abs((_AB[1] * _R[0]) - (_AB[0] * _R[3])) > (ar + br)) { return false; }
    97.         // Test axis L = A2 x B1
    98.         ar = (aSize[0] * _AbsR[4]) + (aSize[1] * _AbsR[1]);
    99.         br = (bSize[0] * _AbsR[8]) + (bSize[2] * _AbsR[6]);
    100.         if (Mathf.Abs((_AB[1] * _R[1]) - (_AB[0] * _R[4])) > (ar + br)) { return false; }
    101.         // Test axis L = A2 x B2
    102.         ar = (aSize[0] * _AbsR[4]) + (aSize[1] * _AbsR[2]);
    103.         br = (bSize[0] * _AbsR[7]) + (bSize[1] * _AbsR[6]);
    104.         if (Mathf.Abs((_AB[1] * _R[2]) - (_AB[0] * _R[5])) > (ar + br)) { return false; }
    105.         return true;
    106.     }
    107.  
    108.     // Adapted from: http://www.mrelusive.com/publications/papers/SIMD-From-Quaternion-to-Matrix-and-Back.pdf
    109.     private static float[] QuaternionToFloatArray(Quaternion aQuat, float[] aFlatMatrix3x3 )
    110.     {
    111.         if(aFlatMatrix3x3 == null) {
    112.             aFlatMatrix3x3 = new float[9];
    113.         }
    114.  
    115.         aFlatMatrix3x3[0] = 1- (2.0f * (aQuat.y * aQuat.y)) - (2.0f * (aQuat.z * aQuat.z));
    116.         aFlatMatrix3x3[1] = (2.0f * (aQuat.x * aQuat.y)) + (2.0f * (aQuat.w * aQuat.z));
    117.         aFlatMatrix3x3[2] = (2.0f * (aQuat.x * aQuat.z)) - (2.0f * (aQuat.w * aQuat.y));
    118.  
    119.         aFlatMatrix3x3[3] = (2.0f * (aQuat.x * aQuat.y)) - (2.0f * (aQuat.w * aQuat.z));
    120.         aFlatMatrix3x3[4] = 1.0f - (2.0f * (aQuat.x * aQuat.x)) - (2.0f * (aQuat.z * aQuat.z));
    121.         aFlatMatrix3x3[5] = (2.0f * (aQuat.y * aQuat.z)) + (2.0f * (aQuat.w * aQuat.x));
    122.  
    123.         aFlatMatrix3x3[6] = (2.0f * (aQuat.x * aQuat.z)) + (2.0f * (aQuat.w * aQuat.y));
    124.         aFlatMatrix3x3[7] = (2.0f * (aQuat.y * aQuat.z)) - (2.0f * (aQuat.w * aQuat.x));
    125.         aFlatMatrix3x3[8] = 1.0f - (2.0f * (aQuat.x * aQuat.x)) - (2.0f * (aQuat.y * aQuat.y));
    126.  
    127.         return aFlatMatrix3x3;
    128.     }
    129. }
    130.  
     
  13. nindim

    nindim

    Joined:
    Jan 22, 2013
    Posts:
    130
    I'm seeing the same issues with Physics.OverlapCapsuleNonAlloc.

    I have filed a bug about it, but no test project with it unfortunately

    Bug Report below, no Issue Tracker ID yet:

    -----------------------------------------------------------------------------------------------------------------------

    Hard crash on Android due to Physics.OverlapCapsuleNonAlloc

    1. Hard crash on Android due to Physics.OverlapCapsuleNonAlloc()


    2. Unfortuantely, I can't attach our project and have not been able to reproduce in a simple test project.

    The problem pretty much occurs on every run through of the game provided we play for a few minutes. When it happens appears to be random.


    3. I am using Physics.OverlapCapsuleNonAlloc() by passing the position of the bottom capsule sphere first, followd by the top sphere. The radius is 0.49 units. The capsule height (total) is 1.47 units. I call this every frame on my player character object.

    The buffer foir the overlapping objects is declared as:

    Collider[] depentrationResults = new Collider[10];

    Generally, only 1 or 2 elements in the buffer are required/used.

    I set the individsual elements of the buffer all to nulll each frame before I call Physics.OverlapCapsuleNonAlloc() in orde to reset them.


    4.

    06-16 15:12:21.078 27814-27830/? A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 27830 (UnityMain)
    06-16 15:12:21.188 200-200/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    06-16 15:12:21.188 200-200/? A/DEBUG: Build fingerprint: 'google/hammerhead/hammerhead:6.0.1/M4B30Z/3437181:user/release-keys'
    06-16 15:12:21.188 200-200/? A/DEBUG: Revision: '11'
    06-16 15:12:21.188 200-200/? A/DEBUG: ABI: 'arm'
    06-16 15:12:21.188 200-200/? A/DEBUG: pid: 27814, tid: 27830, name: UnityMain >>> com.PixelSmashGames.QuikSid <<<
    06-16 15:12:21.188 200-200/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
    06-16 15:12:21.208 200-200/? A/DEBUG: r0 aee3e114 r1 93399750 r2 00000000 r3 952aba30
    06-16 15:12:21.208 200-200/? A/DEBUG: r4 aee3ec24 r5 aee3ebe8 r6 93399750 r7 952aba30
    06-16 15:12:21.208 200-200/? A/DEBUG: r8 92f849a0 r9 00000000 sl 00000000 fp aee3ea28
    06-16 15:12:21.208 200-200/? A/DEBUG: ip a145f7e8 sp aee3e100 lr a145f820 pc 00000000 cpsr a0070010
    06-16 15:12:21.212 200-200/? A/DEBUG: backtrace:
    06-16 15:12:21.213 200-200/? A/DEBUG: #00 pc 00000000 <unknown>
    06-16 15:12:21.213 200-200/? A/DEBUG: #01 pc 004af81c /data/app/com.PixelSmashGames.QuikSid-2/lib/arm/libunity.so
    06-16 15:12:21.213 200-200/? A/DEBUG: #02 pc 00cf73e0 /data/app/com.PixelSmashGames.QuikSid-2/lib/arm/libunity.so
    06-16 15:12:21.213 200-200/? A/DEBUG: #03 pc 00e19358 /data/app/com.PixelSmashGames.QuikSid-2/lib/arm/libunity.so
    06-16 15:12:21.213 200-200/? A/DEBUG: #04 pc 00e1e888 /data/app/com.PixelSmashGames.QuikSid-2/lib/arm/libunity.so
    06-16 15:12:21.213 200-200/? A/DEBUG: #05 pc 00e12250 /data/app/com.PixelSmashGames.QuikSid-2/lib/arm/libunity.so
    06-16 15:12:21.213 200-200/? A/DEBUG: #06 pc 00cf90a8 /data/app/com.PixelSmashGames.QuikSid-2/lib/arm/libunity.so
    06-16 15:12:21.213 200-200/? A/DEBUG: #07 pc 00cf91f4 /data/app/com.PixelSmashGames.QuikSid-2/lib/arm/libunity.so
    06-16 15:12:21.213 200-200/? A/DEBUG: #08 pc 00493ba8 /data/app/com.PixelSmashGames.QuikSid-2/lib/arm/libunity.so
    06-16 15:12:21.213 200-200/? A/DEBUG: #09 pc 0072edcc /data/app/com.PixelSmashGames.QuikSid-2/lib/arm/libunity.so
    06-16 15:12:21.214 200-200/? A/DEBUG: #10 pc 0001e9a4 <unknown>

    This callstack symboicates to:

    #00 NULL UNKNOWN
    #01 CastFilter::preFilter(physx::pxFilterData const&, physx::pxShape const*, physx::pxRigidActor const*, physx::pxFlags<physx::pxHitFlag::Enum, unsigned short>&)
    #02 MultiQueryCallback<physx::pxOverlapHit>::invoke(float&, physx::Sq::prunerPayload const*, unsigned int)
    #03 BucketPrunerOverlapTraversal<OBBAABBTest_SIMD, false>::eek:perator()(physx::Sq::BucketPrunerCore const&, OBBAABBTest_SIMD const&, physx::Sq::prunerCallback&, physx::pxBounds3 const&) [clone .part.26]
    #04 physx::Sq::BucketPrunerCore::eek:verlap(physx::Sq::ShapeData const&, physx::Sq::prunerCallback&) const
    #05 physx::Sq::AABBPruner::eek:verlap(physx::Sq::ShapeData const&, physx::Sq::prunerCallback&) const
    #06 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
    #07 physx::NpSceneQueries::eek:verlap(physx::pxGeometry const&, physx::pxTransform const&, physx::pxHitCallback<physx::pxOverlapHit>&, physx::pxQueryFilterData const&, physx::pxQueryFilterCallback*) const
    #08 Unity::physicsQuery::OverlapCapsuleNonAlloc(Vector3f const&, Vector3f const&, float, Collider**, int, int, QueryTriggerInteraction)
    #09 Physics_CUSTOM_INTERNAL_CALL_OverlapCapsuleNonAlloc(Vector3f const&, Vector3f const&, float, MonoArray*, int, QueryTriggerInteraction)
    #10 UNKNOWN .
     
  14. jknight-nc

    jknight-nc

    Joined:
    Jun 10, 2014
    Posts:
    52
    I'm having this problem on Android as well, using Unity 5.6.0f3. Seems like a pretty fundamental problem.
    Here's the stack trace:

    Code (CSharp):
    1. 07-31 20:50:13.490 14671 14671 F DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
    2. 07-31 20:50:13.490 14671 14671 F DEBUG   :     r0 e407ed34  r1 c5e5bd10  r2 00000000  r3 c5bcdd10
    3. 07-31 20:50:13.490 14671 14671 F DEBUG   :     r4 e407f81c  r5 e407f808  r6 c5e5bd10  r7 c5bcdd10
    4. 07-31 20:50:13.490 14671 14671 F DEBUG   :     r8 ca4079e0  r9 00000000  sl 00000000  fp e407f648
    5. 07-31 20:50:13.490 14671 14671 F DEBUG   :     ip d0dd68cc  sp e407ed20  lr d0dd6904  pc 00000000  cpsr a00d0010
    6. 07-31 20:50:13.510 14671 14671 F DEBUG   :
    7. 07-31 20:50:13.510 14671 14671 F DEBUG   : backtrace:
    8. 07-31 20:50:13.510 14671 14671 F DEBUG   :     #00 pc 00000000  <unknown>
    9. 07-31 20:50:13.510 14671 14671 F DEBUG   :     #01 pc 007f2900  /data/app/com.mycompany.mygame-2/lib/arm/libunity.so (_ZN10CastFilter9preFilterERKN5physx12PxFilterDataEPKNS0_7PxShapeEPKNS0_12PxRigidActorERNS0_7PxFlagsINS0_9PxHitFlag4EnumEtEE+52)
    10. 07-31 20:50:13.510 14671 14671 F DEBUG   :     #02 pc 011a2c70  /data/app/com.mycompany.mygame-2/lib/arm/libunity.so (_ZN18MultiQueryCallbackIN5physx12PxOverlapHitEE6invokeERfPKNS0_2Sq13PrunerPayloadEj+388)
    11. 07-31 20:50:13.510 14671 14671 F DEBUG   :     #03 pc 012c4b68  /data/app/com.mycompany.mygame-2/lib/arm/libunity.so (_ZN28BucketPrunerOverlapTraversalI16OBBAABBTest_SIMDLb0EEclERKN5physx2Sq16BucketPrunerCoreERKS0_RNS3_14PrunerCallbackERKNS2_9PxBounds3E.part.26+2260)
    12. 07-31 20:50:13.510 14671 14671 F DEBUG   :     #04 pc 012ca098  /data/app/com.mycompany.mygame-2/lib/arm/libunity.so (_ZNK5physx2Sq16BucketPrunerCore7overlapERKNS0_9ShapeDataERNS0_14PrunerCallbackE+2844)
    13. 07-31 20:50:13.510 14671 14671 F DEBUG   :     #05 pc 012bda60  /data/app/com.mycompany.mygame-2/lib/arm/libunity.so (_ZNK5physx2Sq10AABBPruner7overlapERKNS0_9ShapeDataERNS0_14PrunerCallbackE+228)
    14. 07-31 20:50:13.510 14671 14671 F DEBUG   :     #06 pc 011a4938  /data/app/com.mycompany.mygame-2/lib/arm/libunity.so (_ZNK5physx14NpSceneQueries10multiQueryINS_12PxOverlapHitEEEbRKNS_15MultiQueryInputERNS_13PxHitCallbackIT_EENS_7PxFlagsINS_9PxHitFlag4EnumEtEEPKNS_12PxQ
    15. ueryCacheERKNS_17PxQueryFilterDataEPNS_21PxQueryFilterCallbackEPNS_20BatchQueryFilterDataE+1804)
    16. 07-31 20:50:13.510 14671 14671 F DEBUG   :     #07 pc 011a4a84  /data/app/com.mycompany.mygame-2/lib/arm/libunity.so (_ZNK5physx14NpSceneQueries7overlapERKNS_10PxGeometryERKNS_11PxTransformERNS_13PxHitCallbackINS_12PxOverlapHitEEERKNS_17PxQueryFilterDataEPNS_21PxQueryF
    17. ilterCallbackE+92)
    18. 07-31 20:50:13.510 14671 14671 F DEBUG   :     #08 pc 007d4954  /data/app/com.mycompany.mygame-2/lib/arm/libunity.so (_ZN5Unity12PhysicsQuery18OverlapBoxInternalERK8Vector3fS3_RK11Quaternionfi23QueryTriggerInteractionRN5physx13PxHitCallbackINS8_12PxOverlapHitEEE+260)
    19. 07-31 20:50:13.510 14671 14671 F DEBUG   :     #09 pc 007d4a64  /data/app/com.mycompany.mygame-2/lib/arm/libunity.so (_ZN5Unity12PhysicsQuery18OverlapBoxNonAllocERK8Vector3fS3_RK11QuaternionfPP8Colliderii23QueryTriggerInteraction+244)
    20. 07-31 20:50:13.511 14671 14671 F DEBUG   :     #10 pc 00ad01fc  /data/app/com.mycompany.mygame-2/lib/arm/libunity.so (_Z47Physics_CUSTOM_INTERNAL_CALL_OverlapBoxNonAllocRK8Vector3fS1_P9MonoArrayRK11Quaternionfi23QueryTriggerInteraction+152)
     
  15. jknight-nc

    jknight-nc

    Joined:
    Jun 10, 2014
    Posts:
    52

    Thank you very much for posting this code.

    I used it to reimplement the OverlapBox API that is broken. It uses an OverlapSphere to get the nearby colliders, and then uses your BoxBox algorithm to see if the box collider is touching the other collider. The other collider is assumed to also be a box collider, if it is not, the collision will not be accurate (it will use the other colliders transform localScale as the box extents).

    Also, I'm relying on this mental calculation I made that the Sphere that fully encompases a box will have a radius of:

    var radius = 0.5f * new Vector3(boxWidth, boxHeight, boxDepth).magnitude;


    Someone please let me know if I'm wrong there. EDIT: I have since confirmed this to be true.

    Here's my blog post about the workaround.

    Here's the code that reimplements OverlapBox.
    It's very fast and is built on top of Bunzaga's collision detection. It works correctly for BoxColliders, and almost for Sphere Colliders. If you need accurate results against Sphere Colliders, update the position and halfExtent calculations with specific code for Shere Colliders.

    Code (CSharp):
    1.  
    2. using UnityEngine;
    3.  
    4. public static class CollisionCheck
    5. {
    6.     private static Vector3 _AB = new Vector3(); // Direction A to B
    7.     private static float[] _R = new float[9]; // 3x3 Rotation
    8.     private static float[] _AbsR = new float[9]; // 3x3 Rotation
    9.     private static Vector3 _AX = new Vector3(); // A Axis
    10.     private static Vector3 _BX = new Vector3(); // B Axis
    11.  
    12.     private static Vector3 _v1 = new Vector3();
    13.     private static Vector3 _v2 = new Vector3();
    14.     private static Vector3 _v3 = new Vector3();
    15.  
    16.     private static float[] _aRot = new float[9];
    17.     private static float[] _bRot = new float[9];
    18.  
    19.     private static float ar = 0.0f, br = 0.0f;
    20.  
    21.     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 };
    22.  
    23.     private static Collider[] sphere_cast_collider_storage = new Collider[32];
    24.  
    25.     public static Vector3 HalfExtentsFromBoxCollider(BoxCollider boxCollider1) {
    26.         return new Vector3(boxCollider1.size.x * boxCollider1.transform.localScale.x * 0.5f, boxCollider1.size.y * boxCollider1.transform.localScale.y * 0.5f, boxCollider1.size.z * boxCollider1.transform.localScale.z * 0.5f);
    27.     }
    28.     public static Vector3 PositionFromCollider(BoxCollider collider) {
    29.         return collider.transform.position + collider.center;
    30.     }
    31.  
    32.     public static int OverlapBox(Vector3 center, Vector3 halfExtents, Quaternion rotation, Collider[] colliderStorage, LayerMask killLayer) {
    33.         var radius = 0.5f * new Vector3(halfExtents.x*2.0f, halfExtents.y*2.0f, halfExtents.z*2.0f).magnitude;
    34.         int numOverlaps = Physics.OverlapSphereNonAlloc(center, radius, sphere_cast_collider_storage, killLayer.value);
    35.         int numBoxOverlaps = 0;
    36.         for (int i = 0; i < numOverlaps; i++) {
    37.             var nearbyCollider = sphere_cast_collider_storage[I];
    38.             //Debug.Log("Testing against " + nearbyCollider.gameObject.name);
    39.             var nearbyBoxCollider = nearbyCollider.GetComponent<BoxCollider>();
    40.             var nearbyColliderHalfExtents = nearbyBoxCollider != null ? HalfExtentsFromBoxCollider(nearbyBoxCollider) : nearbyCollider.transform.localScale * 0.5f;
    41.             var nearbyColliderPosition = nearbyBoxCollider != null ? PositionFromCollider(nearbyBoxCollider) : nearbyCollider.transform.position;
    42.             //Debug.Log("Position: " + nearbyCollider.transform.position);
    43.             //Debug.Log("Rotation: " + nearbyCollider.transform.rotation);
    44.             //Debug.Log("Half Extents: " + nearbyColliderHalfExtents);
    45.             //Debug.Log("Has box: " + (nearbyBoxCollider != null).ToString());
    46.             if (CollisionCheck.Box_Box(center, halfExtents, rotation, nearbyColliderPosition, nearbyColliderHalfExtents, nearbyCollider.transform.rotation)) {
    47.                 colliderStorage[numBoxOverlaps++] = sphere_cast_collider_storage[I];
    48.             }
    49.         }
    50.         return numBoxOverlaps;
    51.     }
    52.  
    53.     // Adapted from: [URL]http://www.gamasutra.com/view/feature/131790/simple_intersection_tests_for_games.php?print=1[/URL]
    54.     public static bool Box_Box (Vector3 aPos, Vector3 aSize, Quaternion aQuat, Vector3 bPos, Vector3 bSize, Quaternion bQuat)
    55.     {
    56.         ar = 0.0f;
    57.         br = 0.0f;
    58.  
    59.         QuaternionToFloatArray(aQuat, _aRot);
    60.         QuaternionToFloatArray(bQuat, _bRot);
    61.  
    62.  
    63.         for (int i = 0, i1 = 0; i < 3; i++, i1 += 3)
    64.         {
    65.             _AX.Set(_aRot[i1], _aRot[i1 + 1], _aRot[i1 + 2]);
    66.             for (int j = 0, j1 = 0; j < 3; j++, j1 += 3)
    67.             {
    68.                 _BX.Set(_bRot[j1], _bRot[j1 + 1], _bRot[j1 + 2]);
    69.                 _R[i1 + j] = Vector3.Dot(_AX, _BX);
    70.             }
    71.         }
    72.  
    73.         _AB = bPos - aPos;
    74.  
    75.         _v1.Set(_aRot[0], _aRot[1], _aRot[2]);
    76.         _v2.Set(_aRot[3], _aRot[4], _aRot[5]);
    77.         _v3.Set(_aRot[6], _aRot[7], _aRot[8]);
    78.  
    79.         _AB.Set(Vector3.Dot(_AB, _v1), Vector3.Dot(_AB, _v2), Vector3.Dot(_AB, _v3));
    80.  
    81.         for (int i = 0; i < 9; i++)
    82.         {
    83.             _AbsR[I] = Mathf.Abs(_R[I]) + 0.001f;
    84.         }
    85.         // Test axes L = A0, L = A1, L = A2
    86.         for (int i = 0, i1 = 0; i < 3; i++, i1 += 3)
    87.         {
    88.             ar = aSize[I];
    89.             br = (bSize[0] * _AbsR[i1]) + (bSize[1] * _AbsR[i1 + 1]) + (bSize[2] * _AbsR[i1 + 2]);
    90.             if (Mathf.Abs(_AB[I]) > (ar + br)) { return false; }
    91.         }
    92.         // Test axes L = B0, L = B1, L = B2
    93.         for (int i = 0; i < 3; i++)
    94.         {
    95.             ar = (aSize[0] * _AbsR[I]) + (aSize[1] * _AbsR[i + 3]) + (aSize[2] * _AbsR[i + 6]);
    96.             br = bSize[I];
    97.             if (Mathf.Abs((_AB[0] * _R[I]) + (_AB[1] * _R[i + 3]) + (_AB[2] * _R[i + 6])) > (ar + br)) { return false; }
    98.         }
    99.         // Test axis L = A0 x B0
    100.         ar = (aSize[1] * _AbsR[6]) + (aSize[2] * _AbsR[3]);
    101.         br = (bSize[1] * _AbsR[2]) + (bSize[2] * _AbsR[1]);
    102.         if (Mathf.Abs(_AB[2] * _R[3] - _AB[1] * _R[6]) > (ar + br)) { return false; }
    103.         // Test axis L = A0 x B1
    104.         ar = (aSize[1] * _AbsR[7]) + (aSize[2] * _AbsR[4]);
    105.         br = (bSize[0] * _AbsR[2]) + (bSize[2] * _AbsR[0]);
    106.         if (Mathf.Abs((_AB[2] * _R[4]) - (_AB[1] * _R[7])) > (ar + br)) { return false; }
    107.         // Test axis L = A0 x B2
    108.         ar = aSize[1] * _AbsR[8] + aSize[2] * _AbsR[5];
    109.         br = bSize[0] * _AbsR[1] + bSize[1] * _AbsR[0];
    110.         if (Mathf.Abs((_AB[2] * _R[5]) - (_AB[1] * _R[8])) > (ar + br)) { return false; }
    111.         // Test axis L = A1 x B0
    112.         ar = (aSize[0] * _AbsR[6]) + (aSize[2] * _AbsR[0]);
    113.         br = (bSize[1] * _AbsR[5]) + (bSize[2] * _AbsR[4]);
    114.         if (Mathf.Abs((_AB[0] * _R[6]) - (_AB[2] * _R[0])) > (ar + br)) { return false; }
    115.         // Test axis L = A1 x B1
    116.         ar = (aSize[0] * _AbsR[7]) + (aSize[2] * _AbsR[1]);
    117.         br = (bSize[0] * _AbsR[5]) + (bSize[2] * _AbsR[3]);
    118.         if (Mathf.Abs((_AB[0] * _R[7]) - (_AB[2] * _R[1])) > (ar + br)) { return false; }
    119.         // Test axis L = A1 x B2
    120.         ar = (aSize[0] * _AbsR[8]) + (aSize[2] * _AbsR[2]);
    121.         br = (bSize[0] * _AbsR[4]) + (bSize[1] * _AbsR[3]);
    122.         if (Mathf.Abs((_AB[0] * _R[8]) - (_AB[2] * _R[2])) > (ar + br)) { return false; }
    123.         // Test axis L = A2 x B0
    124.         ar = (aSize[0] * _AbsR[3]) + (aSize[1] * _AbsR[0]);
    125.         br = (bSize[1] * _AbsR[8]) + (bSize[2] * _AbsR[7]);
    126.         if (Mathf.Abs((_AB[1] * _R[0]) - (_AB[0] * _R[3])) > (ar + br)) { return false; }
    127.         // Test axis L = A2 x B1
    128.         ar = (aSize[0] * _AbsR[4]) + (aSize[1] * _AbsR[1]);
    129.         br = (bSize[0] * _AbsR[8]) + (bSize[2] * _AbsR[6]);
    130.         if (Mathf.Abs((_AB[1] * _R[1]) - (_AB[0] * _R[4])) > (ar + br)) { return false; }
    131.         // Test axis L = A2 x B2
    132.         ar = (aSize[0] * _AbsR[4]) + (aSize[1] * _AbsR[2]);
    133.         br = (bSize[0] * _AbsR[7]) + (bSize[1] * _AbsR[6]);
    134.         if (Mathf.Abs((_AB[1] * _R[2]) - (_AB[0] * _R[5])) > (ar + br)) { return false; }
    135.         return true;
    136.     }
    137.  
    138.     // Adapted from: [URL]http://www.mrelusive.com/publications/papers/SIMD-From-Quaternion-to-Matrix-and-Back.pdf[/URL]
    139.     private static float[] QuaternionToFloatArray(Quaternion aQuat, float[] aFlatMatrix3x3 )
    140.     {
    141.         if(aFlatMatrix3x3 == null) {
    142.             aFlatMatrix3x3 = new float[9];
    143.         }
    144.  
    145.         aFlatMatrix3x3[0] = 1- (2.0f * (aQuat.y * aQuat.y)) - (2.0f * (aQuat.z * aQuat.z));
    146.         aFlatMatrix3x3[1] = (2.0f * (aQuat.x * aQuat.y)) + (2.0f * (aQuat.w * aQuat.z));
    147.         aFlatMatrix3x3[2] = (2.0f * (aQuat.x * aQuat.z)) - (2.0f * (aQuat.w * aQuat.y));
    148.  
    149.         aFlatMatrix3x3[3] = (2.0f * (aQuat.x * aQuat.y)) - (2.0f * (aQuat.w * aQuat.z));
    150.         aFlatMatrix3x3[4] = 1.0f - (2.0f * (aQuat.x * aQuat.x)) - (2.0f * (aQuat.z * aQuat.z));
    151.         aFlatMatrix3x3[5] = (2.0f * (aQuat.y * aQuat.z)) + (2.0f * (aQuat.w * aQuat.x));
    152.  
    153.         aFlatMatrix3x3[6] = (2.0f * (aQuat.x * aQuat.z)) + (2.0f * (aQuat.w * aQuat.y));
    154.         aFlatMatrix3x3[7] = (2.0f * (aQuat.y * aQuat.z)) - (2.0f * (aQuat.w * aQuat.x));
    155.         aFlatMatrix3x3[8] = 1.0f - (2.0f * (aQuat.x * aQuat.x)) - (2.0f * (aQuat.y * aQuat.y));
    156.  
    157.         return aFlatMatrix3x3;
    158.     }
    159. }
    160.  
    161.  
     
    Last edited: Aug 2, 2017
  16. daxiongmao

    daxiongmao

    Joined:
    Feb 2, 2016
    Posts:
    412
    We are seeing the same thing it seems with overlap capsule. Switching to overlap sphere seems to fix it. But after reading some of these forums I wonder if it won't show up again.

    iOS and editor do not have this problem.
    Both versions of unity 2017 have the problem on android. Tried on several android devices with various os versions.
    All seem to crash randomly.
     
  17. jknight-nc

    jknight-nc

    Joined:
    Jun 10, 2014
    Posts:
    52
    Yeah I noticed that OverlapCapsule/CapsuleCast/CheckCapsule are all broken on Android as well. Though they seem to show up on some < 50% of calls.

    Certainly an annoying, long standing problem. I wonder if there's a bug number we can track yet.
     
  18. DavidSWu

    DavidSWu

    Joined:
    Jun 20, 2016
    Posts:
    183
    Thanks for the sample code.
    A few notes:

    - This should probably be collider.bounds.center or collider.transform.TransformPoint(collider.center)
    - The non box approximation could use nearbyCollider.bounds with the identity rotation
    - nearbyCollider.GetComponent<BoxCollider>() should be nearbyCollider as BoxCollider in case there is more than one collider in the gameobject