2018-07-31

您好看了您的文章收益颇丰,麻烦咨询一个ANR的问题。

我们的一个游戏项目出现了一个很难复现的ANR,具体traces.txt如下所示

```

"main" prio=5 tid=1 Native

  | group="main" sCount=1 dsCount=0 obj=0x74f2fd10 self=0xab277a98

  | sysTid=26895 nice=-1 cgrp=top_visible sched=0/0 handle=0xf7144b38

  | state=S schedstat=( 134969883152 21492190720 332833 ) utm=10078 stm=3418 core=1 HZ=100

  | stack=0xff24e000-0xff250000 stackSize=8MB

  | held mutexes=

  kernel: (couldn't read /proc/self/task/26895/stack)

  native: #00 pc 00044450  /system/lib/libc.so (__epoll_pwait+20)

  native: #01 pc 0001975f  /system/lib/libc.so (epoll_pwait+26)

  native: #02 pc 0001976d  /system/lib/libc.so (epoll_wait+6)

  native: #03 pc 0001377f  /system/lib/libutils.so (_ZN7android6Looper9pollInnerEi+102)

  native: #04 pc 000139fb  /system/lib/libutils.so (_ZN7android6Looper8pollOnceEiPiS1_PPv+130)

  native: #05 pc 000883e5  /system/lib/libandroid_runtime.so (_ZN7android18NativeMessageQueue8pollOnceEP7_JNIEnvP8_jobjecti+22)

  native: #06 pc 0000055d  /data/dalvik-cache/arm/system@[email protected] (Java_android_os_MessageQueue_nativePollOnce__JI+96)

  at android.os.MessageQueue.nativePollOnce(Native method)

  at android.os.MessageQueue.next(MessageQueue.java:330)

  at android.os.Looper.loop(Looper.java:137)

  at android.app.ActivityThread.main(ActivityThread.java:5546)

  at java.lang.reflect.Method.invoke!(Native method)

  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)

  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:682)

  "Binder_1" prio=5 tid=7 Native

  | group="main" sCount=1 dsCount=0 obj=0x12ca40a0 self=0xac1d4b80

  | sysTid=26905 nice=0 cgrp=top_visible sched=0/0 handle=0xef2fe930

  | state=S schedstat=( 5905897504 876400096 31265 ) utm=256 stm=334 core=2 HZ=100

  | stack=0xef202000-0xef204000 stackSize=1014KB

  | held mutexes=

  kernel: (couldn't read /proc/self/task/26905/stack)

  native: #00 pc 000429f4  /system/lib/libc.so (__ioctl+8)

  native: #01 pc 00049715  /system/lib/libc.so (ioctl+14)

  native: #02 pc 0001e87b  /system/lib/libbinder.so (_ZN7android14IPCThreadState14talkWithDriverEb+174)

  native: #03 pc 0001edbb  /system/lib/libbinder.so (_ZN7android14IPCThreadState20getAndExecuteCommandEv+6)

  native: #04 pc 0001ee59  /system/lib/libbinder.so (_ZN7android14IPCThreadState14joinThreadPoolEb+48)

  native: #05 pc 000238a1  /system/lib/libbinder.so (???)

  native: #06 pc 00010abd  /system/lib/libutils.so (_ZN7android6Thread11_threadLoopEPv+112)

  native: #07 pc 00064b1f  /system/lib/libandroid_runtime.so (_ZN7android14AndroidRuntime15javaThreadShellEPv+70)

  native: #08 pc 0004172f  /system/lib/libc.so (_ZL15__pthread_startPv+30)

  native: #09 pc 00019433  /system/lib/libc.so (__start_thread+6)

  (no managed stack frames)

"Binder_2" prio=5 tid=8 Native

  | group="main" sCount=1 dsCount=0 obj=0x12ca70a0 self=0xac14e7f0

  | sysTid=26906 nice=0 cgrp=top_visible sched=0/0 handle=0xdf932930

  | state=S schedstat=( 5987319312 838710704 31220 ) utm=270 stm=328 core=2 HZ=100

  | stack=0xdf836000-0xdf838000 stackSize=1014KB

  | held mutexes=

  kernel: (couldn't read /proc/self/task/26906/stack)

  native: #00 pc 000429f4  /system/lib/libc.so (__ioctl+8)

  native: #01 pc 00049715  /system/lib/libc.so (ioctl+14)

  native: #02 pc 0001e87b  /system/lib/libbinder.so (_ZN7android14IPCThreadState14talkWithDriverEb+174)

  native: #03 pc 0001edbb  /system/lib/libbinder.so (_ZN7android14IPCThreadState20getAndExecuteCommandEv+6)

  native: #04 pc 0001ee59  /system/lib/libbinder.so (_ZN7android14IPCThreadState14joinThreadPoolEb+48)

  native: #05 pc 000238a1  /system/lib/libbinder.so (???)

  native: #06 pc 00010abd  /system/lib/libutils.so (_ZN7android6Thread11_threadLoopEPv+112)

  native: #07 pc 00064b1f  /system/lib/libandroid_runtime.so (_ZN7android14AndroidRuntime15javaThreadShellEPv+70)

  native: #08 pc 0004172f  /system/lib/libc.so (_ZL15__pthread_startPv+30)

  native: #09 pc 00019433  /system/lib/libc.so (__start_thread+6)

  (no managed stack frames)

```

从traces.txt文件中可以看到main thread阻塞在`nativePoolOnce`上面这和您在文章中描述的`binder`繁忙造成的ANR很类似,但是我们抓到的`Binder_*`线程都是出于`native`状态,并且看到不其堆栈信息。

所以能不能麻烦问一下

1. 为什么

你可能感兴趣的:(2018-07-31)