android-notes / Cockroach

降低Android非必要crash
MIT License
3.25k stars 449 forks source link

是用monkey测试时,会出现ANR问题,哪位遇到过? #49

Closed youguobin closed 1 year ago

youguobin commented 4 years ago

native: #00 pc 000498e8 /system/lib/libc.so (epoll_pwait+20) native: #01 pc 0001b9e5 /system/lib/libc.so (epoll_pwait+60) native: #02 pc 0001ba15 /system/lib/libc.so (epoll_wait+12) native: #03 pc 00010153 /system/lib/libutils.so (android::Looper::pollInner(int)+118) native: #04 pc 00010045 /system/lib/libutils.so (android::Looper::pollOnce(int, int, int, void*)+32) native: #05 pc 000b2e59 /system/lib/libandroid_runtime.so (android::NativeMessageQueue::pollOnce(_JNIEnv, _jobject*, int)+24) native: #06 pc 001a5d7d /system/framework/arm/boot-framework.oat (Java_android_os_MessageQueue_nativePollOnceJI+92) at android.os.MessageQueue.nativePollOnce(Native method) at android.os.MessageQueue.next(MessageQueue.java:325) at android.os.Looper.loop(Looper.java:142) at com.vb.baseframe.logging.CrashLogger.lambda$start$0(CrashLogger.java:177) at com.vb.baseframe.logging.-$$Lambda$CrashLogger$euMZFyaMBeyoncQBPcn4SPonIhg.run(lambda:-1) at android.os.Handler.handleCallback(Handler.java:790) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6518) at java.lang.reflect.Method.invoke(Native method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

使用方法没问题,本地验证crash会防护住。但monkey时,发生anr堆栈如下。 Reason: 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: 10. Wait queue head age: 5617.8ms.)

Gracker commented 3 years ago

这种跟这个库没啥关系,没有这个库的话,有的 Input dispatching timed out 的主线程堆栈也长这样,只不过是原生的而已. ANR 的问题,除了死锁这种, 其他的一般要从 Log 中去分析,结合各种 Log 输出,推测当时运行的步骤,分析是系统问题还是应用问题