[Android] Hard crash in touch code
Forum thread here: https://forum.unity.com/threads/the-android-is-crash-when-i-using-the-new-input-system.538840/
# UnityMain(60)
SIGSEGV(UNKNOWN_SIGSEGV)
1 #00 pc 00311e00 /data/app-lib/com.d63.wind-1/libunity.so (AddTouchEvent(int, float, float, float, float, int, long long, int)+136) [x86]
2 #01 pc 0031287b /data/app-lib/com.d63.wind-1/libunity.so (ProcessTouchEvent(android::view::InputEvent&, int)+626) [x86]
3 #02 pc 002f86c7 /data/app-lib/com.d63.wind-1/libunity.so (JavaInput::Process()+105) [x86]
4 #03 pc 002f728a /data/app-lib/com.d63.wind-1/libunity.so (InputProcess()+84) [x86]
5 #04 pc 002f700a /data/app-lib/com.d63.wind-1/libunity.so (UnityPlayerLoop()+652) [x86]
6 #05 pc 002f9d62 /data/app-lib/com.d63.wind-1/libunity.so (nativeRender(_JNIEnv*, _jobject*)+94) [x86]
7 #06 pc 0002a9fb /system/lib/libdvm.so (dvmPlatformInvoke+79) [x86]
8 #07 pc 00087db2 /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+434) [x86]
9 #08 pc 9305c11e <unknown>
10 #09 pc 0003beb2 /system/lib/libdvm.so (dvmMterpStd(Thread*)+66) [x86]
11 #10 pc 00037579 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+217) [x86]
12 #11 pc 000be427 /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, char*)+759) [x86]
13 #12 pc 000be837 /system/lib/libdvm.so (dvmCallMethod(Thread*, Method const*, Object*, JValue*, ...)+55) [x86]
14 #13 pc 0009a7c3 /system/lib/libdvm.so (interpThreadStart(void*)+995) [x86]
15 #14 pc 0000bc3c /system/lib/libc.so (__thread_entry+236) [x86]
16 #15 pc 0003e1b5 /system/lib/libc.so (__pthread_clone+69) [x86]
17 java:
18 com.unity3d.player.UnityPlayer.nativeRender(Native Method)
19 com.unity3d.player.UnityPlayer.nativeRender(Native Method)
20 com.unity3d.player.UnityPlayer.c(Unknown Source)
21 com.unity3d.player.UnityPlayer$e$2.queueIdle(Unknown Source)
22 android.os.MessageQueue.next(MessageQueue.java:207)
23 android.os.Looper.loop(Looper.java:123)
24 com.unity3d.player.UnityPlayer$e.run(Unknown Source)
Some additional info from the user:
- This crash is not consistently. It happen sometime when I control the UGUI joystick.
- I am using the Unity2018b9 when the crash happen.
- I am using the InputSystem download from the github, I think it the newest version.
- In fact I think the device is the problem, because it not happen on real android device, but on the simulator on windows. I am using this one: http://syzs.qq.com/?ADTAG=baidu.pz.bt04_1 I think because it using the x86 code, maybe it is where the problem come from.
I am getting thousands of ANRs in production which MAY be related to this crash. I was gonna open a new issue but found this one and they may be related. Let me paste the stack trace, if you think it's unrelated let me know and I will open a new issue.
#00 pc 0000000000039824 /system/lib/libc.so (nanosleep+12) #01 pc 0000000000a736dc /data/app/mygamepackage-1/lib/arm/libunity.so (???) #02 pc 00000000002e6034 /data/app/mygamepackage-1/lib/arm/libunity.so (???) #03 pc 0000000000462294 /data/app/mygamepackage-1/lib/arm/libunity.so (???) #04 pc 0000000000461d90 /data/app/mygamepackage-1/lib/arm/libunity.so (???) #05 pc 0000000000441874 /data/app/mygamepackage-1/lib/arm/libunity.so (???) #06 pc 0000000000442e20 /data/app/mygamepackage-1/lib/arm/libunity.so (???) #07 pc 00000000004fec37 /data/dalvik-cache/arm/data@app@[email protected]@classes.dex (Java_com_unity3d_player_UnityPlayer_nativeInjectEvent__Landroid_view_InputEvent_2+102) at com.unity3d.player.UnityPlayer.nativeInjectEvent (Native method) at com.unity3d.player.UnityPlayer.injectEvent (unavailable) at com.unity3d.player.UnityPlayer.onTouchEvent (unavailable) at android.view.View.dispatchTouchEvent (View.java:8725)
Input dispatching timed out (Waiting to send non-key event because the touched window has not finished processing certain input events that were delivered to it over 500.0ms ago. Wait queue length: 40. Wait queue head age: 5507.8ms.) in mygamepackage.myactivity
From the last 7 days: ANRs reports: 503 Impacted users: 230 Last reported: 52 minutes ago
@rotter Is this with the new input system enabled? ("Active Input Method" in player preferences set to "Both" or "New Input System (Preview)").
Yes, it's set to Both. And I'm running it on Android, forgot to mention.
I have it running for a couple months, and am getting several complains from players regarding crashes/freezes, but dont know if they are related to NIS or not, but adding the NIS was the main thing I added on the last update, so it's likely to be the culprit.
I do have some old input code (that's why it's set to Both), do you think it could be some kind of conflict due to be using both input systems?
I tried updating the input system to see if the error vanishes, but am having some problems updating ( https://forum.unity.com/threads/problem-compiling-due-to-unsafe-code.546368/ )
I see. Thanks for the details. We have some ideas where this may be coming from (and yeah, it's most likely related to the new input system) and are looking into it.
Thanks! And thanks for letting me know it's likely the culprit. I will disable the NIS now, and will reenable it once it's fixed.
Please let me know when you push a commit that might fix it and I will gladly roll an update to test it if I'm home (I will be out of town on the first 2 weeks of September)
Trying to reproduce this
Just as a feedback, I have rolled an update removing the NIS a couple of days ago and indeed the ANRs have stopped.
We still aren't able to reproduce this on our end. @rotter Can you provide a repro case please?
Sorry @todi1856, I cant reproduce it. My game is in production with hundreds of thousands active players, and I started getting reports for freezes/crashes and saw hundreds of reports for ANR appear on Google Play console after introducing the NIS. After I removed it (around 7 days ago) complains stopped, and ANRs dropped dramatically (to approx 2% the original number of reports, relative to the number of users that have received the update).
I see, that's too bad. We'll try to spend some more time on this, and close this issue.
I can provide some info about the ANRs regarding models and OS version. But there doesn't seem to have any pattern, the ANR seems to happen on all kinds of devices.
Unfortunately Google Play Console doesnt give me more data to work with (such as free RAM, free disk, battery level, if a call was made, if there is Internet available, cell signal, etc). But from the reports/emails from the players I couldnt find any pattern as well, and if players are complaining that the game was freezing a lot, certainly the phone didnt die due to no battery (or they wouldnt even notice the crash).
OS versions: Android 6.0 | 1,353 | 36.7% Android 5.1 | 631 | 17.1% Android 7.0 | 505 | 13.7% Android 7.1 | 441 | 12.0% Android 5.0 | 392 | 10.6% Android 8.0 | 287 | 7.8% Android 8.1 | 79 | 2.1%
Models: Moto G (2nd Gen) (titan_udstv) | 188 | 5.1% Moto G (3rd Gen) (osprey_uds) | 168 | 4.6% Moto G (3rd Gen) (osprey_udstv) | 102 | 2.8% Moto G (2nd Gen) (titan_umtsds) | 94 | 2.5% Moto G (1st Gen) (falcon_umtsds) | 81 | 2.2% Galaxy J7 (j7elte) | 74 | 2.0% Galaxy J7 Prime (on7xelte) | 71 | 1.9% Galaxy Tab A (gt510wifi) | 61 | 1.7% Galaxy Grand Prime (fortuna3gdtv) | 52 | 1.4% Galaxy Grand Prime (fortuna3g) | 43 | 1.2% Moto G (3rd Gen) (osprey_umts) | 42 | 1.1% V831W (P731A10) | 32 | 0.9% Galaxy Note4 (trltechnzh) | 31 | 0.8% A1000/P1003/P1010 (A1000) | 31 | 0.8% TB2-X30F (TB2-X30F) | 31 | 0.8% AX920 (Bmobile_AX920) | 30 | 0.8% Galaxy Tab A (2016) (gtaxlwifi) | 29 | 0.8% Moto G (1st Gen) (falcon_umts) | 27 | 0.7% Moto G (5th Gen) (cedric) | 27 | 0.7% moto g(6) play (aljeter) | 26 | 0.7% Others | 2,451 | 66.4%
@rotter Any chance there's stack traces for threads other than the UI thread along with the trace you posted initially? It looks like the UI thread goes into an infinite sleep loop because the input queue it's meant to feed is blocked. What we haven't been able to establish yet is what's happening with the app thread that's supposed to unblock the UI thread.
@Rene-Damm I am going to the airport in 3h and will be out of country without my computer for 2 weeks, so if possible please send me more requests/questions on the next few hours (if we're lucky you're Europe or Asia based).
I do have the stack traces on Google Play Console for all the other threads, but there are dozens of threads, so I will focus on threads I found with Unity on their name. Unfortunately there's no option to easily export the stack trace on GPC, so I have to copy/paste for each thread.
Motorola Moto E with 4G LTE (2nd Gen) (surnia_udstv), Android 6.0
"main" prio=5 tid=1 Native
| group="main" sCount=1 dsCount=0 obj=0x74996f98 self=0xb7bf4c60
| sysTid=29506 nice=-4 cgrp=default sched=0/0 handle=0xb6f20b34
| state=R schedstat=( 19197982750 6189377895 53625 ) utm=1399 stm=520 core=2 HZ=100
| stack=0xbe0eb000-0xbe0ed000 stackSize=8MB
| held mutexes=
#00 pc 000000000004455c /system/lib/libc.so (nanosleep+12)
#01 pc 0000000000a736dc /data/app/mygamepackage-2/lib/arm/libunity.so (???)
#02 pc 00000000002e6034 /data/app/mygamepackage-2/lib/arm/libunity.so (???)
#03 pc 0000000000462214 /data/app/mygamepackage-2/lib/arm/libunity.so (???)
#04 pc 0000000000461d90 /data/app/mygamepackage-2/lib/arm/libunity.so (???)
#05 pc 0000000000441874 /data/app/mygamepackage-2/lib/arm/libunity.so (???)
#06 pc 0000000000442e20 /data/app/mygamepackage-2/lib/arm/libunity.so (???)
#07 pc 0000000000538e35 /data/app/mygamepackage-2/oat/arm/base.odex (Java_com_unity3d_player_UnityPlayer_nativeInjectEvent__Landroid_view_InputEvent_2+96)
at com.unity3d.player.UnityPlayer.nativeInjectEvent (Native method)
at com.unity3d.player.UnityPlayer.injectEvent (unavailable)
at com.unity3d.player.UnityPlayer.onTouchEvent (unavailable)
at android.view.View.dispatchTouchEvent (View.java:9297)
at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2549)
at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2240)
at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2555)
at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2254)
at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2555)
at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2254)
at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2555)
at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2254)
at com.android.internal.policy.PhoneWindow$DecorView.superDispatchTouchEvent (PhoneWindow.java:2403)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent (PhoneWindow.java:1737)
at android.app.Activity.dispatchTouchEvent (Activity.java:2769)
at com.android.internal.policy.PhoneWindow$DecorView.dispatchTouchEvent (PhoneWindow.java:2364)
at android.view.View.dispatchPointerEvent (View.java:9517)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent (ViewRootImpl.java:4242)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess (ViewRootImpl.java:4108)
at android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:3654)
at android.view.ViewRootImpl$InputStage.onDeliverToNext (ViewRootImpl.java:3707)
at android.view.ViewRootImpl$InputStage.forward (ViewRootImpl.java:3673)
at android.view.ViewRootImpl$AsyncInputStage.forward (ViewRootImpl.java:3799)
at android.view.ViewRootImpl$InputStage.apply (ViewRootImpl.java:3681)
at android.view.ViewRootImpl$AsyncInputStage.apply (ViewRootImpl.java:3856)
at android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:3654)
at android.view.ViewRootImpl$InputStage.onDeliverToNext (ViewRootImpl.java:3707)
at android.view.ViewRootImpl$InputStage.forward (ViewRootImpl.java:3673)
at android.view.ViewRootImpl$InputStage.apply (ViewRootImpl.java:3681)
at android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:3654)
at android.view.ViewRootImpl.deliverInputEvent (ViewRootImpl.java:5969)
at android.view.ViewRootImpl.doProcessInputEvents (ViewRootImpl.java:5908)
at android.view.ViewRootImpl.enqueueInputEvent (ViewRootImpl.java:5869)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent (ViewRootImpl.java:6072)
at android.view.InputEventReceiver.dispatchInputEvent (InputEventReceiver.java:192)
at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents (Native method)
at android.view.InputEventReceiver.consumeBatchedInputEvents (InputEventReceiver.java:183)
at android.view.ViewRootImpl.doConsumeBatchedInput (ViewRootImpl.java:6043)
at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run (ViewRootImpl.java:6095)
at android.view.Choreographer$CallbackRecord.run (Choreographer.java:858)
at android.view.Choreographer.doCallbacks (Choreographer.java:670)
at android.view.Choreographer.doFrame (Choreographer.java:600)
at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:844)
at android.os.Handler.handleCallback (Handler.java:746)
at android.os.Handler.dispatchMessage (Handler.java:95)
at android.os.Looper.loop (Looper.java:148)
at android.app.ActivityThread.main (ActivityThread.java:5443)
at java.lang.reflect.Method.invoke! (Native method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:618)
"UnityMain" prio=5 tid=15 Native | group="main" sCount=1 dsCount=0 obj=0x12cc66d0 self=0xb8bb5640 | sysTid=29539 nice=0 cgrp=default sched=0/0 handle=0xa30de930 | state=S schedstat=( 93862311063 26707217375 166733 ) utm=8426 stm=960 core=2 HZ=100 | stack=0xa2fdc000-0xa2fde000 stackSize=1038KB | held mutexes= #00 pc 0000000000016a6c /system/lib/libc.so (syscall+28) #01 pc 00000000000f60bb /system/lib/libart.so (_ZN3art17ConditionVariable4WaitEPNS_6ThreadE+82) #02 pc 000000000027e42b /system/lib/libart.so (_ZN3art3JNI14PushLocalFrameEP7_JNIEnvi+634) #03 pc 0000000000b71bf8 /data/app/mygamepackage-2/lib/arm/libunity.so (???) at com.unity3d.player.UnityPlayer.nativeRender (Native method) at com.unity3d.player.UnityPlayer.c (unavailable) at com.unity3d.player.UnityPlayer$e$2.queueIdle (unavailable) at android.os.MessageQueue.next (MessageQueue.java:392) at android.os.Looper.loop (Looper.java:135) at com.unity3d.player.UnityPlayer$e.run (unavailable)
"UnityChoreographer" prio=5 tid=17 Native | group="main" sCount=1 dsCount=0 obj=0x12d69e20 self=0xb9d15a40 | sysTid=29831 nice=-2 cgrp=default sched=0/0 handle=0x9eea1930 | state=S schedstat=( 23166704951 6635606457 51721 ) utm=1690 stm=626 core=2 HZ=100 | stack=0x9ed9f000-0x9eda1000 stackSize=1038KB | held mutexes= #00 pc 0000000000016a6c /system/lib/libc.so (syscall+28) #01 pc 00000000000f60bb /system/lib/libart.so (_ZN3art17ConditionVariable4WaitEPNS_6ThreadE+82) #02 pc 0000000000284619 /system/lib/libart.so (_ZN3art3JNI16CallObjectMethodEP7_JNIEnvP8_jobjectP10_jmethodIDz+624) #03 pc 0000000000002bc3 /system/lib/libnativehelper.so (jniGetReferent+94) #04 pc 000000000007735b /system/lib/libandroid_runtime.so (_ZN7android26NativeDisplayEventReceiver13dispatchVsyncExij+26) #05 pc 000000000007757d /system/lib/libandroid_runtime.so (_ZN7android26NativeDisplayEventReceiver11handleEventEiiPv+80) #06 pc 0000000000012f4f /system/lib/libutils.so (_ZN7android6Looper9pollInnerEi+530) #07 pc 000000000001301f /system/lib/libutils.so (_ZN7android6Looper8pollOnceEiPiS1_PPv+130) #08 pc 0000000000083415 /system/lib/libandroid_runtime.so (_ZN7android18NativeMessageQueue8pollOnceEP7_JNIEnvP8_jobjecti+22) #09 pc 0000000000000585 /system/framework/arm/boot.oat (Java_android_os_MessageQueue_nativePollOnce__JI+96) at android.os.MessageQueue.nativePollOnce (Native method) at android.os.MessageQueue.next (MessageQueue.java:323) at android.os.Looper.loop (Looper.java:135) at android.os.HandlerThread.run (HandlerThread.java:61)
No reproducible case. Close. If this still happens, please file through Unity Bug Reporter, so a minimum repro project can be attached.