标签:ons different 窗口 队列 started 完成 hub ddr title
ANR时间区别便是指当前这次的事件dispatch过程中执行findFocusedWindowTargetsLocked()方法到下一次执行resetANRTimeoutsLocked()的时间区间. 以下5个时机会reset. 都位于InputDispatcher.cpp文件:
简单来说, 上面方法主要是对应以下4个场景,会有机会执行resetANRTimeoutsLocked重置timeout时间:
当InputDispatcher线程 findFocusedWindowTargetsLocked()过程调用到handleTargetsNotReadyLocked,且满足超时5s的情况则会调用onANRLocked().
通过将InputManagerService加入到Watchdog的monitor队列,定时监测是否发生死锁. 整个监测过涉及EventHub, InputReader, InputDispatcher, InputManagerService的死锁监测. 监测的原理很简单,通过尝试获取锁并释放锁的方式.
可通过adb shell dumpsys input
来查看手机当前的input状态, 输出内容分别为EventHub.dump(), InputReader.dump(),InputDispatcher.dump()这3类,另外如果发生过input ANR,那么也会输出上一个ANR的状态.
其中mPendingEvent代表的当下正在处理的事件.
由小节[3.5] InputMonitor.notifyANR完成, 当发生ANR时system log中会出现以下信息, 并且TAG=WindowManager:
Input event dispatching timed out xxx. Reason: + reason
, 其中xxx取值:
windowState.mAttrs.getTitle()
appWindowToken.stringName
至于Reason主要有以下类型:
由checkWindowReadyForMoreInputLocked完成, ANR reason主要有以下几类:
[targetType]
window is paused.[targetType]
window’s input channel is not registered with the input dispatcher. The window may be in the process of being removed.[targetType]
window’s input connection is [Connection.Status]
. The window may be in the process of being removed.[targetType]
window’s input channel is full. Outbound queue length: [outboundQueue长度]
. Wait queue length: [waitQueue长度]
.[targetType]
window has not finished processing all of the input events that were previously delivered to it. Outbound queue length: [outboundQueue长度]
. Wait queue length: [waitQueue长度]
.[targetType]
window has not finished processing certain input events that were delivered to it over 500ms ago. Wait queue length: [waitQueue长度]
. Wait queue head age: [等待时长]
.其中
另外, findFocusedWindowTargetsLocked, findTouchedWindowTargetsLocked这两个方法中可以通过实现 updateDispatchStatisticsLocked()来分析anr问题.
由dropInboundEventLocked完成,输出事件丢弃的原因:
其他:
标签:ons different 窗口 队列 started 完成 hub ddr title
原文地址:https://www.cnblogs.com/krislight1105/p/10175306.html