ANR 类型

摘抄自ANR原理分析

#5.1 ANR分类

由小节[3.5] InputMonitor.notifyANR完成, 当发生ANR时system log中会出现以下信息, 并且TAG=WindowManager:

Input event dispatching timed out xxx. Reason: + reason, 其中xxx取值:

窗口类型: sending to windowState.mAttrs.getTitle() 应用类型: sending to application appWindowToken.stringName 其他类型: 则为空. 至于Reason主要有以下类型:

## 5.1.1 reason类型

由小节[2.3.1]checkWindowReadyForMoreInputLocked完成, ANR reason主要有以下几类:

无窗口, 有应用:Waiting because no window has focus but there is a focused application that may eventually add a window when it finishes starting up.

窗口暂停: Waiting because the [targetType] window is paused.

窗口未连接: Waiting because the [targetType] window’s input channel is not registered with the input dispatcher. The window may be in the process of being removed.

窗口连接已死亡:Waiting because the [targetType] window’s input connection is [Connection.Status]. The window may be in the process of being removed.

窗口连接已满:Waiting because the [targetType] window’s input channel is full. Outbound queue length: [outboundQueue长度]. Wait queue length: [waitQueue长度].

按键事件,输出队列或事件等待队列不为空:Waiting to send key event because the [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长度].

非按键事件,事件等待队列不为空且头事件分发超时500ms:Waiting to send non-key event because the [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: [等待时长].

其中 targetType: 取值为”focused”或者”touched” Connection.Status: 取值为”NORMAL”,”BROKEN”,”ZOMBIE” 另外, findFocusedWindowTargetsLocked, findTouchedWindowTargetsLocked这两个方法中可以通过实现 updateDispatchStatisticsLocked()来分析anr问题.

#5.2 drop事件分类

由小节[2.1.2] dropInboundEventLocked完成,输出事件丢弃的原因:

DROP_REASON_POLICY: “inbound event was dropped because the policy consumed it”;

DROP_REASON_DISABLED: “inbound event was dropped because input dispatch is disabled”;

DROP_REASON_APP_SWITCH: “inbound event was dropped because of pending overdue app switch”;

DROP_REASON_BLOCKED: “inbound event was dropped because the current application is not responding and the user has started interacting with a different application””;

DROP_REASON_STALE: “inbound event was dropped because it is stale”;

其他:

doDispatchCycleFinishedLockedInterruptible的过程, 会记录分发时间超过2s的事件, findFocusedWindowTargetsLocked的过程, 可以统计等待时长信息.

转载于:https://juejin.im/post/5a6829386fb9a01c975a698e

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值