azesmway/react-native-unity

Android App crashes if unity is loaded once then app goes to background then foreground again

Opened this issue · 4 comments

There is an app crash in most android devices under these conditions:

  1. Unity is loaded once
  2. App goes to the background
  3. App brought to foreground
  4. try to show UnityView again
  5. Crash

These are the logs I got:

2023-11-28 12:51:00.245 1068-1930/? E/CRASH: Tombstone written to: /storage/emulated/0/Android/data/com.adam.papadam/files/tombstone_01
2023-11-28 12:51:00.245 1068-1930/? Dld: UnityMain
    Process: com.adam.papadam, PID: 1068
    java.lang.Error: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    Version '2021.3.5f1 (40eb3a945986)', Build type 'Release', Scripting Backend 'il2cpp', CPU 'arm64-v8a'
    Build fingerprint: 'samsung/gta8wifieea/gta8wifi:13/TP1A.220624.014/X200XXU3CWI3:user/release-keys'
    Revision: '0'
    ABI: 'arm64'
    Timestamp: 2023-11-28 12:51:00+0200
    pid: 1068, tid: 1930, name: UnityMain  >>> com.adam.papadam <<<
    uid: 10606
    signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x8
    Cause: null pointer dereference
        x0  0000007a50deac30  x1  b400007b0ff30d00  x2  0000007a510e79f0  x3  0000000000000007
        x4  0000000000001000  x5  0000000000001000  x6  0000007bf8d55dd0  x7  0000000000000000
        x8  0000000000000001  x9  0000000000001000  x10 00000000ffffffff  x11 0000007a50f55870
        x12 0000000000000018  x13 00000000ffffffff  x14 0000000000000000  x15 00000000ac3b7fa9
        x16 00000000fd4d61db  x17 0000000000000001  x18 0000007a50e356a8  x19 0000000000000000
        x20 0000000000000000  x21 0000000000000000  x22 0000000000000000  x23 0000000000000000
        x24 0000000000000000  x25 0000000000000000  x26 00000000000002a0  x27 0000007bf8d55dd0
        x28 0000000000001000  x29 0000000000000007
        sp  0000007bf8d55c60  lr  0000007af4941b2c  pc  0000007af494eb54
    
    backtrace:
          #00 pc 0000000000718b54  /data/app/~~K070xjmf5tNeO9A_e4QAag==/com.adam.papadam-m_8UJkx2CiCCp0rKZ13NQA==/lib/arm64/libunity.so (BuildId: d38166709a70af1553b438d0c48ad20748ceeec3)
          #01 pc 000000000070bb28  /data/app/~~K070xjmf5tNeO9A_e4QAag==/com.adam.papadam-m_8UJkx2CiCCp0rKZ13NQA==/lib/arm64/libunity.so (BuildId: d38166709a70af1553b438d0c48ad20748ceeec3)
          #02 pc 000000000070a830  /data/app/~~K070xjmf5tNeO9A_e4QAag==/com.adam.papadam-m_8UJkx2CiCCp0rKZ13NQA==/lib/arm64/libunity.so (BuildId: d38166709a70af1553b438d0c48ad20748ceeec3)
          #03 pc 000000000070a37c  /data/app/~~K070xjmf5tNeO9A_e4QAag==/com.adam.papadam-m_8UJkx2CiCCp0rKZ13NQA==/lib/arm64/libunity.so (BuildId: d38166709a70af1553b438d0c48ad20748ceeec3)
          #04 pc 0000000000708a40  /data/app/~~K070xjmf5tNeO9A_e4QAag==/com.adam.papadam-m_8UJkx2CiCCp0rKZ13NQA==/lib/arm64/libunity.so (BuildId: d38166709a70af1553b438d0c48ad20748ceeec3)
          #05 pc 00000000006e2678  /data/app/~~K070xjmf5tNeO9A_e4QAag==/com.adam.papadam-m_8UJkx2CiCCp0rKZ13NQA==/lib/arm64/libunity.so (BuildId: d38166709a70af1553b438d0c48ad20748ceeec3)
          #06 pc 00000000006e7930  /data/app/~~K070xjmf5tNeO9A_e4QAag==/com.adam.papadam-m_8UJkx2CiCCp0rKZ13NQA==/lib/arm64/libunity.so (BuildId: d38166709a70af1553b438d0c48ad20748ceeec3)
          #07 pc 00000000006e7848  /data/app/~~K070xjmf5tNeO9A_e4QAag==/com.adam.papadam-m_8UJkx2CiCCp0rKZ13NQA==/lib/arm64/libunity.so (BuildId: d38166709a70af1553b438d0c48ad20748ceeec3)
          #08 pc 00000000006cfd3c  /data/app/~~K070xjmf5tNeO9A_e4QAag==/com.adam.papadam-m_8UJkx2CiCCp0rKZ13NQA==/lib/arm64/libunity.so (BuildId: d38166709a70af1553b438d0c48ad20748ceeec3)
          #09 pc 0000000000375dc4  /data/app/~~K070xjmf5tNeO9A_e4QAag==/com.adam.papadam-m_8UJkx2CiCCp0rKZ13NQA==/lib/arm64/libunity.so (BuildId: d38166709a70af1553b438d0c48ad20748ceeec3)
          #10 pc 000000000037658c  /data/app/~~K070xjmf5tNeO9A_e4QAag==/com.adam.papadam-m_8UJkx2CiCCp0rKZ13NQA==/lib/arm64/libunity.so (BuildId: d38166709a70af1553b438d0c48ad20748ceeec3)
          #11 pc 0000000000360c38  /data/app/~~K070xjmf5tNeO9A_e4QAag==/com.adam.papadam-m_8UJkx2CiCCp0rKZ13NQA==/lib/arm64/libunity.so (BuildId: d38166709a70af1553b438d0c48ad20748ceeec3)
          #12 pc 00000000003770c4  /data/app/~~K070xjmf5tNeO9A_e4QAag==/com.adam.papadam-m_8UJkx2CiCCp0rKZ13NQA==/lib/arm64/libunity.so (BuildId: d38166709a70af1553b438d0c48ad20748ceeec3)
          #13 pc 0000000000363ee4  /data/app/~~K070xjmf5tNeO9A_e4QAag==/com.adam.papadam-m_8UJkx2CiCCp0rKZ13NQA==/lib/arm64/libunity.so (BuildId: d38166709a70af1553b438d0c48ad20748ceeec3)
2023-11-28 12:51:00.246 1068-1930/? E/AndroidRuntime:       #14 pc 0000000000379430  /data/app/~~K070xjmf5tNeO9A_e4QAag==/com.adam.papadam-m_8UJkx2CiCCp0rKZ13NQA==/lib/arm64/libunity.so (BuildId: d38166709a70af1553b438d0c48ad20748ceeec3)
          #15 pc 000000000034aa30  /apex/com.android.art/lib64/libart.so (art_quick_generic_jni_trampoline+144) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
          #16 pc 00000000005bcdb0  /apex/com.android.art/lib64/libart.so (nterp_helper+4016) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
          #17 pc 00000000005bbe34  /apex/com.android.art/lib64/libart.so (nterp_helper+52) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
          #18 pc 0000000000f9863c  /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat
    
        at libunity.0x718b54(Native Method)
        at libunity.0x70bb28(Native Method)
        at libunity.0x70a830(Native Method)
        at libunity.0x70a37c(Native Method)
        at libunity.0x708a40(Native Method)
        at libunity.0x6e2678(Native Method)
        at libunity.0x6e7930(Native Method)
        at libunity.0x6e7848(Native Method)
        at libunity.0x6cfd3c(Native Method)
        at libunity.0x375dc4(Native Method)
        at libunity.0x37658c(Native Method)
        at libunity.0x360c38(Native Method)
        at libunity.0x3770c4(Native Method)
        at libunity.0x363ee4(Native Method)
        at libunity.0x379430(Native Method)
        at libart.art_quick_generic_jni_trampoline(art_quick_generic_jni_trampoline:144)
        at libart.nterp_helper(nterp_helper:4016)
        at libart.nterp_helper(nterp_helper:52)
        at boot.0xf9863c(Native Method)

Anyone has any clues?

My app uses Unity with AR mode + wikitude - no such problem, everything runs without problems from any mode

Thanks @azesmway! I tracked down the problem using other information.
So in case someone finds this useful:

  1. The problem disappeared when I unchecked Auto Graphics API setting (Player Settings) and I removed Vulkan.
  2. This regards only MaliGPU android devices.

My app uses Unity with AR mode + wikitude - no such problem, everything runs without problems from any mode

@azesmway If you don't mind, can you share your implementation of permission request flow in the screen you use the AR mode? For me it works perfectly for iOS, but the camera remains black in Android, no matter what I tried.

My app uses Unity with AR mode + wikitude - no such problem, everything runs without problems from any mode

@azesmway If you don't mind, can you share your implementation of permission request flow in the screen you use the AR mode? For me it works perfectly for iOS, but the camera remains black in Android, no matter what I tried.

<uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission
      android:name="android.permission.WRITE_EXTERNAL_STORAGE"
      tools:ignore="ScopedStorage" />
    <uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.USE_FINGERPRINT" />
    <uses-permission android:name="android.permission.USE_BIOMETRIC" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
    <uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="com.google.android.gms.permission.AD_ID" tools:node="remove" />
    <uses-permission android:name="android.permission.READ_LOGS" tools:node="remove" />
    <uses-permission android:name="android.permission.READ_CALENDAR" />
    <uses-permission android:name="android.permission.WRITE_CALENDAR" />

    <uses-feature
      android:name="android.hardware.camera.ar"
      android:required="true" />
    <uses-feature
      android:glEsVersion="0x00020000"
      android:required="true" />
    <uses-feature
      android:name="android.hardware.location.gps"
      android:required="true" />
    <uses-feature
      android:name="android.hardware.camera"
      android:required="true" />
    <uses-feature
      android:name="android.hardware.camera.front"
      android:required="true" />
    <uses-feature
      android:name="android.hardware.location"
      android:required="true" />
    <uses-feature
      android:name="android.hardware.sensor.accelerometer"
      android:required="true" />
    <uses-feature
      android:name="android.hardware.sensor.compass"
      android:required="true" />