Search Unity

Resolved ARCore causes black screen and crash

Discussion in 'AR' started by MattJackB, May 3, 2022.

  1. MattJackB

    MattJackB

    Joined:
    Oct 14, 2018
    Posts:
    37
    Hi There,

    Our app is immediately crashing when opening the AR feature. The app displays a black screen before crashing.

    The device we are testing on is a Samsung Tab A8 running Android 11; which sounds incredibly similar to this thread https://forum.unity.com/threads/arfoundation-black-screen-issue-on-android-11.1162313/

    I have seen other posts with similar issues which all seem to say the cause is down to the architecture (stating that you can't have 32 bit only app for 64 bit devices); however for the latest release I enabled 64 bit only and it still hasn't fixed it. Before I had both ARMv7 and ARM64 selected, now I only have ARM64.

    It'd be great to know if this is a known unfixable bug so I can stop faffing with the issue and wait for a patch! If someone knows how to fix the issue then that would be ideal.

    Other useful info:
    Target API is 32, and the minimum is set to 24
    Scripting backend is set to IL2CPP.
    Unity 2020.3.19f1
    ARCore/ARFoundation 4.1.9
     
  2. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,058
    2 things to try:
    - make sure graphics API is OpenGL, vulkan is not supported (for some reason) in ARCore
    - Maybe put target API back to 30 or 29. Might not change anything but worth a shot as this helps with Lightship AR (unless changing android manifest)
     
  3. ankur-unity

    ankur-unity

    Unity Technologies

    Joined:
    Aug 12, 2021
    Posts:
    34
  4. MattJackB

    MattJackB

    Joined:
    Oct 14, 2018
    Posts:
    37
    Thanks for the advice! Unfortunately non of it worked; I already only had OpenGL in the project, and I've just tried targeting 30 instead of 32 but had no luck. I only just noticed you suggested to try 29, so might give that ago next.
     
  5. MattJackB

    MattJackB

    Joined:
    Oct 14, 2018
    Posts:
    37
    I've heard someone mention that before (that there is a sperate list for devices sold in China), but that isn't the issue. The device shows up in the Google Play Console as a compatible device, and also appears on the ARCore listed devices.
     
  6. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    1,062
    Hi @MattJackB

    Indeed if the Samsung Tab A8 device was sold in China, there would be an incompatibility issue.

    Could you provide us with the logcat information from the device leading up to the crash?

    Another place to seek help for this issue would be Google's ARCore issues:
    https://github.com/google-ar/arcore-android-sdk
     
  7. MattJackB

    MattJackB

    Joined:
    Oct 14, 2018
    Posts:
    37
    Hi @andyb_unity

    Managed to grab some info from logcat. Never used it before so not entirely sure on what is useful to see. Pretty sure this is important though, it came from viewing the errors:

    Code (CSharp):
    1. 2022-05-16 17:50:29.103 25127-27675/? E/CRASH:
    2. 2022-05-16 17:50:29.103 25127-27675/? E/CRASH: Version '2020.3.34f1 (9a4c9c70452b)', Build type 'Release', Scripting Backend 'il2cpp', CPU 'arm64-v8a'
    3. 2022-05-16 17:50:29.103 25127-27675/? E/CRASH: Build fingerprint: 'samsung/gta8wifieea/gta8wifi:11/RP1A.200720.012/X200XXU1AVC1:user/release-keys'
    4. 2022-05-16 17:50:29.103 25127-27675/? E/CRASH: Revision: '0'
    5. 2022-05-16 17:50:29.103 25127-27675/? E/CRASH: ABI: 'arm64'
    6. 2022-05-16 17:50:29.103 25127-27675/? E/CRASH: Timestamp: 2022-05-16 17:50:29+0100
    7. 2022-05-16 17:50:29.103 25127-27675/? E/CRASH: pid: 25127, tid: 27675, name: GC Finalizer  >>> com.Amonev.AmageniusAR <<<
    8. 2022-05-16 17:50:29.103 25127-27675/? E/CRASH: uid: 10233
    9. 2022-05-16 17:50:29.103 25127-27675/? E/CRASH: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
    10. 2022-05-16 17:50:29.103 25127-27675/? E/CRASH: Cause: null pointer dereference
    11. 2022-05-16 17:50:29.105 25127-27675/? E/CRASH:     x0  0000000000000000  x1  0000000000000000  x2  00000076344ce918  x3  0000000000000030
    12. 2022-05-16 17:50:29.105 25127-27675/? E/CRASH:     x4  0000000000000010  x5  0000000000000000  x6  0000000080000000  x7  686d53ff64726064
    13. 2022-05-16 17:50:29.105 25127-27675/? E/CRASH:     x8  0000007535ed72d0  x9  0000000000000040  x10 0000000000001f44  x11 22e3000000030103
    14. 2022-05-16 17:50:29.105 25127-27675/? E/CRASH:     x12 000000006ff16628  x13 22e3000000030103  x14 0000000000000000  x15 0000000000000030
    15. 2022-05-16 17:50:29.105 25127-27675/? E/CRASH:     x16 00000075500a9078  x17 0000007535ed40bc  x18 00000076382a5000  x19 b400007734a353e0
    16. 2022-05-16 17:50:29.105 25127-27675/? E/CRASH:     x20 0000000000000000  x21 000000000000004d  x22 b400007734a353e0  x23 0000007638260ed0
    17. 2022-05-16 17:50:29.105 25127-27675/? E/CRASH:     x24 00000076382a5000  x25 0000000000000001  x26 000000755003f380  x27 00000000000fe000
    18. 2022-05-16 17:50:29.105 25127-27675/? E/CRASH:     x28 00000000000fc000  x29 00000076344cea60
    19. 2022-05-16 17:50:29.105 25127-27675/? E/CRASH:     sp  00000076344ce9e0  lr  000000755006d534  pc  0000000000000000
    And then there was this when viewing verbose:
    Code (CSharp):
    1. 2022-05-16 17:50:31.027 25127-27668/? E/AndroidRuntime: FATAL EXCEPTION: UnityMain
    2.     Process: com.Amonev.AmageniusAR, PID: 25127
    3.     java.lang.Error:
    4.     Version '2020.3.34f1 (9a4c9c70452b)', Build type 'Release', Scripting Backend 'il2cpp', CPU 'arm64-v8a'
    5.     Build fingerprint: 'samsung/gta8wifieea/gta8wifi:11/RP1A.200720.012/X200XXU1AVC1:user/release-keys'
    6.     Revision: '0'
    7.     ABI: 'arm64'
    8.     Timestamp: 2022-05-16 17:50:29+0100
    9.     pid: 25127, tid: 27675, name: GC Finalizer  >>> com.Amonev.AmageniusAR <<<
    10.     uid: 10233
    11.     signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
    12.     Cause: null pointer dereference
    13.         x0  0000000000000000  x1  0000000000000000  x2  00000076344ce918  x3  0000000000000030
    14.         x4  0000000000000010  x5  0000000000000000  x6  0000000080000000  x7  686d53ff64726064
    15.         x8  0000007535ed72d0  x9  0000000000000040  x10 0000000000001f44  x11 22e3000000030103
    16.         x12 000000006ff16628  x13 22e3000000030103  x14 0000000000000000  x15 0000000000000030
    17.         x16 00000075500a9078  x17 0000007535ed40bc  x18 00000076382a5000  x19 b400007734a353e0
    18.         x20 0000000000000000  x21 000000000000004d  x22 b400007734a353e0  x23 0000007638260ed0
    19.         x24 00000076382a5000  x25 0000000000000001  x26 000000755003f380  x27 00000000000fe000
    20.         x28 00000000000fc000  x29 00000076344cea60
    21.         sp  00000076344ce9e0  lr  000000755006d534  pc  0000000000000000
     
  8. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    1,062
  9. MattJackB

    MattJackB

    Joined:
    Oct 14, 2018
    Posts:
    37
    Sorted it!

    Not entirely sure what did it though... I changed a few things at once so it could have been any of these:
    • Reduced CPU usage/ made the AR scene easier to load by only instantiating elements when they are being used.
    • Upgraded to AR 4.2.3 because there was a known issue (which was fixed in 4.2.0-pre.9) that caused a crash when pausing/ resuming AR session: https://stackoverflow.com/a/69804772
    • Removed OpenGLES2 because the OpenGLES2 graphics API is not supported by ARCore. Before I had both OpenGLES2 and OpenGLES3.
    Hope this helps anyone else who encounters this issue!
     
  10. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,058
    I'm guessing it's the openGL thing
     
    andyb-unity likes this.
  11. MattJackB

    MattJackB

    Joined:
    Oct 14, 2018
    Posts:
    37
    Guess who's back, back again....

    Oh and by the way, I have not added back OpenGLES2, so that can't be what causes this. But now I literally don't have a clue.........

    Code (CSharp):
    1. 2022-06-22 15:35:32.865 26023-26049/? E/CRASH: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    2. 2022-06-22 15:35:32.865 26023-26049/? E/CRASH: Version '2020.3.34f1 (9a4c9c70452b)', Build type 'Release', Scripting Backend 'il2cpp', CPU 'arm64-v8a'
    3. 2022-06-22 15:35:32.865 26023-26049/? E/CRASH: Build fingerprint: 'google/sargo/sargo:11/RQ3A.210905.001/7511028:user/release-keys'
    4. 2022-06-22 15:35:32.865 26023-26049/? E/CRASH: Revision: 'MP1.0'
    5. 2022-06-22 15:35:32.865 26023-26049/? E/CRASH: ABI: 'arm64'
    6. 2022-06-22 15:35:32.865 26023-26049/? E/CRASH: Timestamp: 2022-06-22 15:35:32+0100
    7. 2022-06-22 15:35:32.865 26023-26049/? E/CRASH: pid: 26023, tid: 26049, name: GC Finalizer  >>> com.Amonev.AmageniusAR <<<
    8. 2022-06-22 15:35:32.865 26023-26049/? E/CRASH: uid: 10247
    9. 2022-06-22 15:35:32.865 26023-26049/? E/CRASH: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
    10. 2022-06-22 15:35:32.865 26023-26049/? E/CRASH: Cause: null pointer dereference
    11. 2022-06-22 15:35:32.865 26023-26049/? E/CRASH:     x0  0000000000000000  x1  0000000000000000  x2  0000006d2bd46918  x3  0000000000000030
    12. 2022-06-22 15:35:32.865 26023-26049/? E/CRASH:     x4  0000000000000010  x5  0000000000000000  x6  0000008000000000  x7  73686d53ff647260
    13. 2022-06-22 15:35:32.865 26023-26049/? E/CRASH:     x8  0000006c5116f290  x9  0000000000000000  x10 000000000000000e  x11 0000000000000040
    14. 2022-06-22 15:35:32.865 26023-26049/? E/CRASH:     x12 0000000000000000  x13 d68f5d1b23d5f1a5  x14 0000000000000000  x15 0000000000000030
    15. 2022-06-22 15:35:32.865 26023-26049/? E/CRASH:     x16 0000006c511ec638  x17 0000006c5116d010  x18 0000006d2fdbf000  x19 0000006e487ca720
    16. 2022-06-22 15:35:32.865 26023-26049/? E/CRASH:     x20 0000000000000000  x21 000000000000004c  x22 0000006e487ca720  x23 0000006d2fd795a8
    17. 2022-06-22 15:35:32.865 26023-26049/? E/CRASH:     x24 0000006d2fdbf000  x25 0000000000000001  x26 0000006c512fb4c0  x27 00000000000fc000
    18. 2022-06-22 15:35:32.865 26023-26049/? E/CRASH:     x28 0000006d2bc4e000  x29 0000006d2bd46a60
    19. 2022-06-22 15:35:32.865 26023-26049/? E/CRASH:     sp  0000006d2bd469e0  lr  0000006c511aaa6c  pc  0000000000000000
     
  12. MattJackB

    MattJackB

    Joined:
    Oct 14, 2018
    Posts:
    37
    The issue was point number two in my solution post. The app crashes on Android if you, on awake, set the ARTrackedImageManager to false, then manually set the reference library, and finally enable the ARTrackedImageManager. I thought I had fixed it by upgrading to 4.2.3, but it turns out it was fixed because I had commented out this code; I later removed the comment, added the code back, and that broke it again.

    Here is what the problem code looked like:
    Code (CSharp):
    1. private void Awake(){
    2.   ARTrackedImageManager.enabled = false;
    3.   ARTrackedImageManager.referenceLibrary = mylLibrary;
    4.   ARTrackedImageManager.enabled = true;
    5. }