Search Unity

Crash in middle game randomly caused by SimulationCallbackReceiver:: onContact (on device only)

Discussion in 'Physics' started by obula-zombot, Mar 20, 2019.

  1. obula-zombot

    obula-zombot

    Joined:
    Dec 17, 2018
    Posts:
    5
    Hi all,
    Our game crashes in middle game(battle) randomly and I can't find any solution so far.
    The log below is fetched from logcat of Android Studio.
    It looks like caused by
    from physx and I don't know what related in Unity.
    In our game, there are a lot of bullets flying while battling.
    I use raycast to detect bullet hit, perhaps hundreds(max) raycast in single frame (or less, I didn't count it)
    We also have a lot of BoxColliders on players and destroy them during gameplay.

    The framerate is OK for mid range devices (ex: 30+ fps on Xiaomi 5s plus mostly)

    I found a similar issue reported:
    https://issuetracker.unity3d.com/is...ceiver-oncontact-when-objects-are-destructing

    but still don't know how to solve it or something I should avoid.
    Any suggestions are welcome, thank you.

    BTW, Unity version: 2018.3.8f1

    Obula

    Code (JavaScript):
    1. 2019-03-20 12:29:08.381 11140-11187/com.ZombotStudio.TurboSquad E/CRASH: pid: 11140, tid: 11187, name: UnityMain  >>> com.ZombotStudio.TurboSquad <<<
    2. 2019-03-20 12:29:08.392 11140-11187/com.ZombotStudio.TurboSquad E/CRASH:     #01  pc 0048d638  /data/app/com.ZombotStudio.TurboSquad-hp3GIXR3VWS6DGsOr3_HWA==/lib/arm/libunity.so (SimulationCallbackReceiver::onContact(physx::PxContactPairHeader const&, physx::PxContactPair const*, unsigned int)+732)
    3. 2019-03-20 12:29:08.392 11140-11187/com.ZombotStudio.TurboSquad E/CRASH:     #02  pc 013be2c0  /data/app/com.ZombotStudio.TurboSquad-hp3GIXR3VWS6DGsOr3_HWA==/lib/arm/libunity.so (physx::Sc::Scene::fireQueuedContactCallbacks(bool)+288)
    4. 2019-03-20 12:29:08.392 11140-11187/com.ZombotStudio.TurboSquad E/CRASH:     #03  pc 01360058  /data/app/com.ZombotStudio.TurboSquad-hp3GIXR3VWS6DGsOr3_HWA==/lib/arm/libunity.so (physx::NpScene::fetchResults(bool, unsigned int*)+128)
    5. 2019-03-20 12:29:08.392 11140-11187/com.ZombotStudio.TurboSquad E/CRASH:     #04  pc 00457c90  /data/app/com.ZombotStudio.TurboSquad-hp3GIXR3VWS6DGsOr3_HWA==/lib/arm/libunity.so (PhysicsManager::Simulate(int, float)+2480)
    6. 2019-03-20 12:29:08.392 11140-11187/com.ZombotStudio.TurboSquad E/CRASH:     #05  pc 00456758  /data/app/com.ZombotStudio.TurboSquad-hp3GIXR3VWS6DGsOr3_HWA==/lib/arm/libunity.so (PhysicsManager::InitializeClass()::FixedUpdatePhysicsFixedUpdateRegistrator::Forward()+64)
    7. 2019-03-20 12:29:08.392 11140-11187/com.ZombotStudio.TurboSquad E/CRASH:     #06  pc 00a136e0  /data/app/com.ZombotStudio.TurboSquad-hp3GIXR3VWS6DGsOr3_HWA==/lib/arm/libunity.so (ExecutePlayerLoop(NativePlayerLoopSystem*)+96)
    8. 2019-03-20 12:29:08.392 11140-11187/com.ZombotStudio.TurboSquad E/CRASH:     #07  pc 00a1373c  /data/app/com.ZombotStudio.TurboSquad-hp3GIXR3VWS6DGsOr3_HWA==/lib/arm/libunity.so (ExecutePlayerLoop(NativePlayerLoopSystem*)+188)
    9. 2019-03-20 12:29:08.392 11140-11187/com.ZombotStudio.TurboSquad E/CRASH:     #08  pc 00a13940  /data/app/com.ZombotStudio.TurboSquad-hp3GIXR3VWS6DGsOr3_HWA==/lib/arm/libunity.so (PlayerLoop()+272)
    10. 2019-03-20 12:29:08.392 11140-11187/com.ZombotStudio.TurboSquad E/CRASH:     #09  pc 00c92f9c  /data/app/com.ZombotStudio.TurboSquad-hp3GIXR3VWS6DGsOr3_HWA==/lib/arm/libunity.so (UnityPlayerLoop()+528)
    11. 2019-03-20 12:29:08.392 11140-11187/com.ZombotStudio.TurboSquad E/CRASH:     #10  pc 00ca2760  /data/app/com.ZombotStudio.TurboSquad-hp3GIXR3VWS6DGsOr3_HWA==/lib/arm/libunity.so (nativeRender(_JNIEnv*, _jobject*)+52)
    12. 2019-03-20 12:29:08.424 11140-11187/com.ZombotStudio.TurboSquad E/MessageQueue: IdleHandler threw exception
    13.     java.lang.Error: signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 43154b38
    14.     Build fingerprint: 'Xiaomi/natrium/natrium:8.0.0/OPR1.170623.032/V10.2.2.0.OBGMIXM:user/release-keys'
    15.     Revision: '0'
    16.     pid: 11140, tid: 11187, name: UnityMain  >>> com.ZombotStudio.TurboSquad <<<
    17.         r0 c7d7e5f0  r1 9313ca90  r2 43154b38  r3 bb7bc04c
    18.         r4 bb7bc054  r5 3eb3731a  r6 00000000  r7 c7d7e62c
    19.         r8 9313ca90  r9 433d2810  sl 3f24b644  fp 3f2e3a64
    20.         ip c798bccc  sp c7d7e5b0  lr c649a63c  pc 43154b38  cpsr 00002bb3
    21.  
    22.         at dalvik-main space (region space) (deleted).30554b38(Native Method)
    23.         at libunity.SimulationCallbackReceiver::onContact(physx::PxContactPairHeader const&, physx::PxContactPair const*, unsigned int)(onContact:732)
    24.         at libunity.physx::Sc::Scene::fireQueuedContactCallbacks(bool)(Sc:288)
    25.         at libunity.physx::NpScene::fetchResults(bool, unsigned int*)(NpScene:128)
    26.         at libunity.PhysicsManager::Simulate(int, float)(Simulate:2480)
    27.         at libunity.PhysicsManager::InitializeClass()::FixedUpdatePhysicsFixedUpdateRegistrator::Forward()(InitializeClass:64)
    28.         at libunity.ExecutePlayerLoop(NativePlayerLoopSystem*)(ExecutePlayerLoop:96)
    29.         at libunity.ExecutePlayerLoop(NativePlayerLoopSystem*)(ExecutePlayerLoop:188)
    30.         at libunity.PlayerLoop()(PlayerLoop:272)
    31.         at libunity.UnityPlayerLoop()(UnityPlayerLoop:528)
    32.         at libunity.nativeRender(_JNIEnv*, _jobject*)(nativeRender:52)
    33.         at base.oatexec(oatexec)
     
    Last edited: Mar 20, 2019
  2. obula-zombot

    obula-zombot

    Joined:
    Dec 17, 2018
    Posts:
    5
    Is it caused by raycasting? or colliders interactions?
     
  3. obula-zombot

    obula-zombot

    Joined:
    Dec 17, 2018
    Posts:
    5
    I just have new testing result.
    If I don't destroy GameObjects in scene, it won't crash.
     
  4. obula-zombot

    obula-zombot

    Joined:
    Dec 17, 2018
    Posts:
    5
    Hey guys, I found a temporary solution.
    I added a flag to confirm that I received collision event, like this:
    Code (CSharp):
    1. private void OnCollisionEnter(Collision other)
    2. {
    3.     isReadyToDestroy = true;
    4. }
    I checked the flag before I destroying it.
    I have tested couple hours and didn't crash once.

    If you're facing the same problem, you can try this.
    Hope it can help you.