Android ANR-Keydispatch timeout
16lz
2021-01-23
Code flow of ANR
- Code flow of InputSystem
- Code flow of dispatch input event
flow of Scenario
normal flow
// notifyKey() / notifyMotion()01-15 11:55:56.713 937 1127 D InputDispatcher: notifyM-evT=1156348,dev=1,src=0x1002, ac=0x0, downT=115634801-15 11:55:56.713 937 1127 D InputDispatcher: id[0]=0,tool=1,x=670,y=1246// dispatchKeyLocked() / dispatchMotionLocked() -> dispatchEventLocked()// dispatchEventLocked to every inputTarget01-15 11:55:56.713 937 1126 D InputDispatcher: DispatchM[0]42644ed8 NavigationBar (s),evT=1156348,curT=115635101-15 11:55:56.713 937 1126 D InputDispatcher: DispatchM[0]425a5d78 StatusBar (s),evT=1156348,curT=115635101-15 11:55:56.713 937 1126 D InputDispatcher: DispatchM[0]4354eee0 com.android.settings.Settings (s),evT=1156348,curT=115635101-15 11:55:56.713 937 1126 D InputDispatcher: DispatchM[0]WindowManager (s),evT=1156348,curT=1156351// finishDispatchCycleLocked() -> ... -> doDispatchCycleFinishedLockedInterruptible()01-15 11:55:56.713 937 1126 D InputDispatcher: FinishedM-evT=115634801-15 11:55:56.713 937 1126 D InputDispatcher: FinishedM-evT=115634801-15 11:55:56.713 937 1126 D InputDispatcher: FinishedM-evT=115634801-15 11:55:56.713 937 1126 D InputDispatcher: FinishedM-evT=1156348
No focused window
@ bugreportInput Dispatcher State at time of last ANR: ANR: Time: 2014-02-20 12:13:15 Window: AppWindowToken{4282ed50 token=Token{42755b28 ActivityRecord{42485160 u0 com.htc.camera/.CameraEntry t23}}} DispatchLatency: 5022.9ms WaitDuration: 5005.4ms Reason: Waiting because no window has focus but there is a focused application that may eventually add a window when it finishes starting up. DispatchEnabled: 1 DispatchFrozen: 0 FocusedApplication: name='AppWindowToken{4282ed50 token=Token{42755b28 ActivityRecord{42485160 u0 com.htc.camera/.CameraEntry t23}}}', dispatchingTimeout=5000.000ms FocusedWindow: name='' ...Windows:...PendingEvent: KeyEvent(deviceId=-1, source=0x00000101, action=0, flags=0x00000048, keyCode=4, scanCode=0, metaState=0x00000000, repeatCount=0), policyFlags=0x4b000100, age=5025.8msInboundQueue: length=5 MotionEvent(deviceId=2, source=0x00001002, action=2, flags=0x00000000, metaState=0x00000000, buttonState=0x00000000, edgeFlags=0x00000000, xPrecision=1.5, yPrecision=1.5, displayId=0, pointers=[0: (1266.0, 569.5)]), policyFlags=0x42000000, age=5015.0ms... KeyEvent(deviceId=-1, source=0x00000101, action=0, flags=0x000000c8, keyCode=4, scanCode=0, metaState=0x00000000, repeatCount=1), policyFlags=0x4b000100, age=4520.8ms
event not finished
// 1st touch: dispatch not finished (waitQueue can’t consume: 2*DispatchM but 1*FinishedM)02-14 17:29:59.664 969 1058 D InputDispatcher: notifyM-evT=67123340,dev=3,src=0x1002, ac=0x1, downT=6712310202-14 17:29:59.664 969 1058 D InputDispatcher: id[0]=0,tool=1,x=459,y=102302-14 17:29:59.664 969 1057 D InputDispatcher: DispatchM[1]4263bbf0 com.android.development.BadBehaviorActivity (s),evT=67123340,curT=6712334102-14 17:29:59.664 969 1057 D InputDispatcher: DispatchM[1]WindowManager (s),evT=67123340,curT=6712334102-14 17:29:59.664 969 1057 D InputDispatcher: FinishedM-evT=67123341// - mPendingEvent = NULL// 2nd touch: 02-14 17:30:01.576 969 1058 D InputDispatcher: notifyM-evT=67125255,dev=3,src=0x1002, ac=0x0, downT=6712525502-14 17:30:01.576 969 1058 D InputDispatcher: id[0]=0,tool=1,x=433,y=104202-14 17:30:01.576 969 1057 D InputDispatcher: Waiting for application to become ready for input: Window{4263bbf0 u0 com.android.development/com.android.development.BadBehaviorActivity}. Reason: Waiting because the touched window has not finished processing the input events that were previously delivered to it.// findFocusedWindowTargetsLocked() -> handleTargetsNotReadyLocked()// - waitCause = INPUT_TARGET_WAIT_CAUSE_APPLICATION_NOT_READY;// - waitTimeoutTime = 17:30:01.576 + {5sec}// - Looper’s nextWakeupTime = 17:30:01.576 + {5sec}// - mPendingEvent = 2nd touch// after 5sec, Looper wakeup// dispatchOnceInnerLocked() -> handleTargetsNotReadyLocked() -> onANRLocked()02-14 17:30:06.581 969 1057 I InputDispatcher: Application is not responding: Window{4263bbf0 u0 com.android.development/com.android.development.BadBehaviorActivity}. It has been 5005.5ms since event, 5005.1ms since wait started. Reason: Waiting because the touched window has not finished processing the input events that were previously delivered to it.
更多相关文章
- [记录点滴]在Ionic和Android中上传Blob图片
- android 实现保存图片到相册
- android图片裁剪
- Android 中保存图片的代码
- android之将图片转化为圆形图片
- Android 使用decodeFile方法加载手机磁盘中的图片文件
- Android:使用SpannableString实现图片替换相应的文字
- Android 加载图片并存放在缓存中
- android 实现图片的裁剪