After updating Unity from 2018.4.10 to 2020.3.26 our game started having a new nasty crash on Android (IL2CPP).
We cannot reproduce it locally on available devices, it is only reported in Google Play Console.
The stack trace is:
java.lang.Error: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Version '2020.3.26f1 (7298b473bc1a)', Build type 'Release', Scripting Backend 'il2cpp', CPU 'arm64-v8a'
Build fingerprint: 'samsung/a31nndx/a31:11/RP1A.200720.012/A315GDXU1CUG5:user/release-keys'
Revision: '3'
ABI: 'arm64'
Timestamp: 2022-03-01 09:27:12-0300
pid: 21818, tid: 25180, name: UnityMain >>> com.***.*** <<<
uid: 10545
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
Cause: null pointer dereference
x0 0000000000000000 x1 0000007389a2c05d x2 000000749638b627 x3 0000000000000005
x4 0000000000000000 x5 0000aa0000101000 x6 0000000000000000 x7 7fff7fff7fffffff
x8 0000000000000041 x9 0aa7489c39ba85cf x10 0000000000000000 x11 00000073f68f7151
x12 0000000000000000 x13 0000000000000047 x14 0000000000000001 x15 000023f1ec4ece20
x16 00000074963be9b0 x17 0000007496396670 x18 000000007c5ec72c x19 00000073f68f7260
x20 00000072e1d75098 x21 00000072e01c0a50 x22 0000000000000002 x23 0000000000000001
x24 00000073f68f7ef0 x25 00000073f68fa000 x26 00000073f68fa000 x27 00000073f68f79a0
x28 0000000000000000 x29 00000073f68f8900
sp 00000073f68f71e0 lr 0000007388fa31a4 pc 0000007388e89a40
backtrace:
at
at
at ... a lot of empty entries
at
at
at libunity.0x2bfa40 (Native Method)
at libunity.0x3d91a0 (Native Method)
at libunity.0x3d8e50 (Native Method)
at libunity.0x3c7f9c (Native Method)
at libunity.0x3c761c (Native Method)
at libunity.0x8c4328 (Native Method)
at libunity.0x54d36c (Native Method)
at libunity.0x54d5d4 (Native Method)
at libunity.0x38f5e4 (Native Method)
at libunity.0x37af7c (Native Method)
at libunity.0x37bb00 (Native Method)
at libunity.0x3912d4 (Native Method)
at base.0x10837c (Native Method)
Iāve tried to symbolicate addresses with addr2line, but got nothing meaningful:
...
Upd. 2022-10-23: I deleted the stack trace so as not to be misleading. Initially, I got it with the wrong version of addr2line. See the fixed stack trace further in the thread.
The majority of occurrences are on Android 11 (SDK 30), a little on Android 9, 10, 8; no Android 12.
There are no dominant devices; the top ones are Samsung Galaxy A51 and Huawei P20 Lite.
It looks like some regression in Unity, since we donāt encounter such an issue in 2018.4, but a lot of users hit the crash on the version built with 2020.3. And the error message āCause: null pointer dereferenceā indicates that an issue is rather somewhere in engine code, not in scripts.
No, Iām not sureā¦
Ok, there is similar stacktrace, but for another ABI platform:
Version '2020.3.26f1 (7298b473bc1a)', Build type 'Release', Scripting Backend 'il2cpp', CPU 'armeabi-v7a'
...
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
Cause: null pointer dereference
...
backtrace:
at
...
at
at libunity.0x1cb7dc (Native Method)
at libunity.0x299c8c (Native Method)
at libunity.0x2998d8 (Native Method)
at libunity.0x287414 (Native Method)
at libunity.0x286820 (Native Method)
at libunity.0x73ea1b (Native Method)
at libunity.0x42df38 (Native Method)
at libunity.0x42e1d0 (Native Method)
at libunity.0x25efbf (Native Method)
at libunity.0x2500b3 (Native Method)
at libunity.0x250c01 (Native Method)
at libunity.0x260459 (Native Method)
Iām using addr2line.exe on Windows from this path:
ā¦/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/arm-linux-androideabi-addr2line.exe
Is it right?
I pass libunity.sym.so from this path:
C:\Program Files\Unity\Hub\Editor\2020.3.26f1\Editor\Data\PlaybackEngines\AndroidPlayer\Variations\il2cpp\Release\Symbols*armeabi-v7a*\libunity.sym.so
Now I have this stacktrace:
...
Upd. 2022-10-23: I deleted the stack trace to avoid misleading readers who encountered the same crash. I resolved it with the wrong version of addr2line. See the fixed stack trace further in the thread.
If you have StripEngineCode On, then thatās the wrong path, I donāt think stacktrace is correct. Please read Stacktrace Utility | Android Logcat | 1.2.3 - it should help you get correct symbols
Ok, I have rebuilt the APK from the same commit (hoping that build is deterministic) and passed generated libunity.sym.so instead of the one provided with Unity installation.
Now I have a somewhat more realistic stacktrace:
0x001cb7dc: BeginsWith(char const*, char const*) at ??:?
0x00299c8c: ApiGLES::FillExtensions(dynamic_array<core::basic_string_ref<char>, 0u>&) at ??:?
0x002998d8: ApiGLES::Init(GfxContextGLES const&, GfxDeviceLevelGL&) at ??:?
0x00287414: GfxDeviceGLES::Init(GfxDeviceLevelGL) at ??:?
0x00286820: CreateGLESGfxDevice(GfxDeviceRenderer) at ??:?
0x0073ea1b: CreateClientGfxDevice(GfxDeviceRenderer, GfxCreateDeviceFlags) at ??:?
0x0042df38: CreateGfxDevice(GfxDeviceRenderer, GfxCreateDeviceFlags) at ??:?
0x0042e1d0: InitializeGfxDevice() at ??:?
0x0025efbf: AndroidGraphics::Startup() at ??:?
0x002500b3: UnityInitApplication() at ??:?
0x00250c01: UnityPlayerLoop() at ??:?
0x00260459: nativeRender(_JNIEnv*, _jobject*) at ??:?
Code looks like it would crash with this callstack if glGetString(GL_RENDERER) returns NULL.
But if thatās the case something went wrong earlier during startup.
It returns NULL if we were not able to create a valid OpenGLES/EGL context. It might happen when the system is very resource constrained. It might also be caused by a bug.
Yes this happens before any script code runs and before anything is rendered using Unity (but there may be native Android UI and Java plugin code running before that).
We should not crash when this happens and instead we should show an error dialog. But that wonāt solve the underlying issue.
Iām facing thousands of these errors on user devices (seen both in Google Play and in Crashlytics) since update from Unity 2018 to Unity 2020. Iām using Unity 2020.3.34 now and build is done on macOS. Happens on wide range of devices, but Google Play mostly reports Huawei devices.
Stack trace is as follows:
Caused by java.lang.Error: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Version '2020.3.34f1 (9a4c9c70452b)', Build type 'Release', Scripting Backend 'il2cpp', CPU 'arm64-v8a'
Build fingerprint: 'samsung/a31xx/a31:11/RP1A.200720.012/A315FXXU1CUK4:user/release-keys'
Revision: '3'
ABI: 'arm64'
Timestamp: 2022-06-26 12:39:30+0300
pid: 10269, tid: 12315, name: UnityMain >>> bundle.id <<<
uid: 10255
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
Cause: null pointer dereference
x0 0000000000000000 x1 0000007bd6e5188e x2 0000007cdcf4a627 x3 0000000000000005
x4 0000000000000000 x5 0000aa0000101000 x6 0000000000000000 x7 ff7f7f7fffff7fff
x8 0000000000000041 x9 e12b387ceabd4dae x10 0000000000000000 x11 0000007bde90e071
x12 0000000000000000 x13 0000000000000047 x14 0000000000000001 x15 00003e04809d99b9
x16 0000007cdcf7d9b0 x17 0000007cdcf55670 x18 000000007c5ec72c x19 0000007bde90e180
x20 0000007b30d39c18 x21 0000007b302cefc0 x22 0000000000000000 x23 0000000000000001
x24 0000007bde90ee10 x25 0000007bde910000 x26 0000007bde910000 x27 0000007bde90e8c0
x28 0000000000000001 x29 0000000000000001
sp 0000007bde90e100 lr 0000007bd626037c pc 0000007bd60bed48
backtrace:
#00 pc 00000000005bad48 (BeginsWith(char const*, char const*) at ??:?) /data/app/~~qFH1LQV0MwsoUCykyBnTqw==/bundle.id-Pn6SiNxzh4Yy6Zyhw2vKvg==/lib/arm64/libunity.so (BuildId: 53994a4518c674de19e889c82b6bb22a2875a971)
#01 pc 000000000075c378 (ApiGLES::FillExtensions(dynamic_array<core::basic_string_ref<char>, 0ul>&) at ??:?) /data/app/~~qFH1LQV0MwsoUCykyBnTqw==/bundle.id-Pn6SiNxzh4Yy6Zyhw2vKvg==/lib/arm64/libunity.so (BuildId: 53994a4518c674de19e889c82b6bb22a2875a971)
#02 pc 000000000075c028 (ApiGLES::Init(GfxContextGLES const&, GfxDeviceLevelGL&) at ??:?) /data/app/~~qFH1LQV0MwsoUCykyBnTqw==/bundle.id-Pn6SiNxzh4Yy6Zyhw2vKvg==/lib/arm64/libunity.so (BuildId: 53994a4518c674de19e889c82b6bb22a2875a971)
#03 pc 000000000074b4cc (GfxDeviceGLES::Init(GfxDeviceLevelGL) at ??:?) /data/app/~~qFH1LQV0MwsoUCykyBnTqw==/bundle.id-Pn6SiNxzh4Yy6Zyhw2vKvg==/lib/arm64/libunity.so (BuildId: 53994a4518c674de19e889c82b6bb22a2875a971)
#04 pc 000000000074ab1c /da<truncated: 1613 chars>
at libunity.0x5bad48()
at libunity.0x75c378()
at libunity.0x75c028()
at libunity.0x74b4cc()
at libunity.0x74ab1c()
at libunity.0x3ddc08()
at libunity.0x8f2504()
at libunity.0x8f276c()
at libunity.0x6a8c5c()
at libunity.0x6928f4()
at libunity.0x6934a4()
at libunity.0x6aaa10()
at base.0xc79ac()
And after reading mac build may solve it we have migrated our project to mac and got a build from there with the error below again. This seem to be a very common error on all versions of unity 2020.3 and idk how come we canāt find a solution for it this long.
Iām getting this error as well. Previous builds worked fine, the only thing Iāve changed since the previous build is Iāve added Unity Mediation. Iām using Unity 2022.1.14f1
FATAL EXCEPTION: UnityMain
java.lang.Error: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Version '2022.1.14f1 (ff7e140968b4)', Build type 'Release', Scripting Backend 'il2cpp', CPU 'arm64-v8a'
Build fingerprint: 'google/oriole/oriole:12/SQ1D.220205.004/8151327:user/release-keys'
Revision: 'MP1.0'
ABI: 'arm64'
Timestamp: 2022-08-29 08:56:25-0700
pid: 19661, tid: 19683, name: UnityMain
uid: 10233
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
Cause: null pointer dereference
x0 0000000000000000 x1 0000000000000010 x2 0000000000000010 x3 000000000000000c
x4 0000000000000000 x5 000000740eb5861d x6 0000000000000000 x7 0000000000000001
x8 00000073e000f360 x9 0000000000000a7a x10 0000000000000000 x11 0000000000000000
x12 0000000000000527 x13 0000000000000000 x14 0000000000000526 x15 00000002e3998bb0
x16 000000740eed1cb8 x17 000000771fb31680 x18 0000007407668000 x19 000000738003ca20
x20 000000740dbc47c0 x21 0000000000000000 x22 000000740dbc4719 x23 0000000000000001
x24 b4000074f65f6ec0 x25 0000000000000000 x26 0000000000000018 x27 000000740dbc4d90
x28 000000740ec01e75 x29 0000000000000049
sp 000000740dbc4650 lr 000000740df97680 pc 000000771fb31690
backtrace:
#00 pc 0000000000049690 /apex/com.android.runtime/lib64/bionic/libc.so (__strlen_aarch64+16) (BuildId: 28943f8bb3b7b23557619af9a38223c5)
#01 pc 00000000003cd67c /data/app/~~BaT1HLkuhvyckhznJTajfQ==/-onwunts25lvnXm2ED85_Pw==/split_config.arm64_v8a.apk (BuildId: a5967d7e23ae3fd72044f366f964aedfefea1098)
#02 pc 00000000003c8770 /data/app/~~BaT1HLkuhvyckhznJTajfQ==/-onwunts25lvnXm2ED85_Pw==/split_config.arm64_v8a.apk (BuildId: a5967d7e23ae3fd72044f366f964aedfefea1098)
#03 pc 00000000003b4d10 /data/app/~~BaT1HLkuhvyckhznJTajfQ==/-onwunts25lvnXm2ED85_Pw==/split_config.arm64_v8a.apk (BuildId: a5967d7e23ae3fd72044f366f964aedfefea1098)
#04 pc 00000000003b65ac /data/app/~~BaT1HLkuhvyckhznJTajfQ==/-onwunts25lvnXm2ED85_Pw==/split_config.arm64_v8a.apk (BuildId: a5967d7e23ae3fd72044f366f964aedfefea1098)
#05 pc 00000000003cdf84 /data/app/~~BaT1HLkuhvyckhznJTajfQ==/-onwunts25lvnXm2ED85_Pw==/split_config.arm64_v8a.apk (BuildId: a5967d7e23ae3fd72044f366f964aedfefea1098)
#06 pc 0000000000222244 /apex/com.android.art/lib64/libart.so (art_quick_generic_jni_trampoline+148) (BuildId: e6c658201ef1ec3760112fa1b838ab2c)
#07 pc 0000000000212520 /apex/com.android.art/lib64/libart.so (nterp_helper+4016) (BuildId: e6c658201ef1ec3760112fa1b838ab2c)
#08 pc 00000000002115a4 /apex/com.android.art/lib64/libart.so (nterp_helper+52) (BuildId: e6c658201ef1ec3760112fa1b838ab2c)
#09 pc 00000000004efe70 /system/framework/arm64/boot-framework.oat (BuildId: b475cc2538d0c50ace3ee34f4ccdf79c9b7101d2)
at libc.__strlen_aarch64(__strlen_aarch64:16)
at split_config.0x3cd67c(Native Method)
at split_config.0x3c8770(Native Method)
at split_config.0x3b4d10(Native Method)
at split_config.0x3b65ac(Native Method)
at split_config.0x3cdf84(Native Method)
at libart.art_quick_generic_jni_trampoline(art_quick_generic_jni_trampoline:148)
at libart.nterp_helper(nterp_helper:4016)
at libart.nterp_helper(nterp_helper:52)
at boot-framework.0x4efe70(Native Method)
Found the problem in my case.
It seems like Unity is using internally com.google.android.play:core android library. In February this library was split in 3 smaller libraries and I started using one of them (com.google.android.play:asset-delivery) in my custom code for Play Asset Delivery.
It looks like some collision between these libraries is happening, because I see the following 2 gradle warnings during the build process
[com.google.android.play:asset-delivery:2.0.0] C:\Users\Baceto\.gradle\caches\transforms-3\c4b6775b2416107bb62776bd67542083\transformed\jetified-asset-delivery-2.0.0\AndroidManifest.xml Warning:
Namespace 'com.google.android.play.core.client' used in: com.google.android.play:asset-delivery:2.0.0, com.google.android.play:core-common:2.0.0.
WARNING:R8: Missing class com.google.android.play.core.tasks.OnCompleteListener (referenced from: void com.unity3d.player.a.a(java.lang.String[], com.unity3d.player.IAssetPackManagerDownloadStatusCallback) and 3 other contexts)
Missing class com.google.android.play.core.tasks.OnSuccessListener (referenced from: void com.unity3d.player.a.a(android.app.Activity, com.unity3d.player.IAssetPackManagerMobileDataConfirmationCallback) and 1 other context)
Missing class com.google.android.play.core.tasks.RuntimeExecutionException (referenced from: void com.unity3d.player.a$d.onComplete(com.google.android.play.core.tasks.Task) and 1 other context)
Missing class com.google.android.play.core.tasks.Task (referenced from: void com.unity3d.player.a$d.onComplete(com.google.android.play.core.tasks.Task) and 6 other contexts)
What I did to fix the native unity crash is replace the new play:asset-delivery lib with the old one play:core in my code
Do you have any updates on this crash? It is now top-1 in our Google Play Console after upgrading from Unity 2018 to Unity 2021. It prevents us from rolling out the new build to a wider audience.
0x002e266c: BeginsWith(char const*, char const*) at ??:?
0x00803d20: ApiGLES::FillExtensions(dynamic_array<core::basic_string_ref<char>, 0u>&) at ??:?
0x00803980: ApiGLES::Init(GfxContextGLES const&, GfxDeviceLevelGL&) at ??:?
0x007f168c: GfxDeviceGLES::Init(GfxDeviceLevelGL) at ??:?
0x007f0c9c: CreateGLESGfxDevice(GfxDeviceRenderer) at ??:?
0x003ca9b5: CreateClientGfxDevice(GfxDeviceRenderer, GfxCreateDeviceFlags) at ??:?
0x007dd460: CreateGfxDevice(GfxDeviceRenderer, GfxCreateDeviceFlags) at ??:?
0x007dd720: InitializeGfxDevice() at ??:?
0x003a7d7f: AndroidGraphics::Startup() at ??:?
0x00398c1f: UnityInitApplication() at ??:?
0x00399811: UnityPlayerLoop() at ??:?
0x003a951d: nativeRender(_JNIEnv*, _jobject*) at ??:?