Android MONKEY ANR at android.os.MessageQueue.nativePollOnce


We find a tricky ANR problem when using MONKEY to test our app.

CPU and memory using is in the normal level.

it seems that the ANR is cause by a Timeout KeyEvent faked by MONKEY sending to our app’s Activity. Below is the part of log:

    Time: 2016-12-29 15:36:08
    Window: AppWindowToken{56a48d3 token=Token{abb12c2 ActivityRecord{cb0230d u0 <our app’s activity> t34}}} - Window{40c381a u0 <our app’s activity>}
    DispatchLatency: 5005.0ms
    WaitDuration: 5003.6ms
    Reason: Waiting to send key event because the focused window has not finished processing all of the input events that were previously delivered to it.  Outbound queue length: 0.  Wait queue length: 1.

11: channelName='40c381a <our app’s activity> (server)', windowName='Window{40c381a u0 <our app’s activity>', status=NORMAL, monitor=false, inputPublisherBlocked=false
      OutboundQueue: <empty>
      WaitQueue: length=1
        KeyEvent(deviceId=-1, source=0x00000101, action=0, flags=0x00000008, keyCode=82, scanCode=0, metaState=0x00000000, repeatCount=0), policyFlags=0x6b000000, eventT=12621294000000, targetFlags=0x00000101, resolvedAction=0, age=5014.4ms, wait=5011.8ms

But the trace log is
"main" prio=5 tid=1 Native
  | group="main" sCount=1 dsCount=0 obj=0x75fc23f0 self=0x7fa2f04a00
  | sysTid=1478 nice=0 cgrp=default sched=0/0 handle=0x7fa321ba98
  | state=S schedstat=( 0 0 0 ) utm=3806 stm=1660 core=0 HZ=100
  | stack=0x7fca45d000-0x7fca45f000 stackSize=8MB
  | held mutexes=
  kernel: __switch_to+0x7c/0x88
  kernel: SyS_epoll_wait+0x298/0x328
  kernel: SyS_epoll_pwait+0xa4/0x118
  kernel: el0_svc_naked+0x24/0x28
  native: #00 pc 000000000006b418  /system/lib64/ (__epoll_pwait+8)
  native: #01 pc 000000000001e7cc  /system/lib64/ (epoll_pwait+64)
  native: #02 pc 000000000001a26c  /system/lib64/ (_ZN7android6Looper9pollInnerEi+156)
  native: #03 pc 000000000001a120  /system/lib64/ (_ZN7android6Looper8pollOnceEiPiS1_PPv+60)
  native: #04 pc 00000000000ef3bc  /system/lib64/ (_ZN7android18NativeMessageQueue8pollOnceEP7_JNIEnvP8_jobjecti+48)
  native: #05 pc 00000000008e8000  /system/framework/arm64/boot-framework.oat (Java_android_os_MessageQueue_nativePollOnce__JI+140)
  at android.os.MessageQueue.nativePollOnce(Native method)
  at android.os.Looper.loop(
  at java.lang.reflect.Method.invoke!(Native method)

Our main thread is waiting for get the message from MessageQueue. The inputmanager send a KeyEvent to our Activity but our main thread seems not receive the event and still waiting for the message to handle.

What reason causes this problem?

asked on Stack Overflow Jan 6, 2017 by YUANSHUO ZHU

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0