当前位置: 首页 > news >正文

android 窗口焦点介绍

背景

我们经常会遇到一种Application does not hava focused windowANR异常,这种异常一般是没有焦点窗口FocusedWindow导致,且这类异常只会发生在key事件的派发,因为key事件是需要找到一个焦点窗口然后再派发,而触摸事件只需要找到当前显示的窗口即可

关键日志

window

在dumpsys window中查看mCurrentFocus和mFocusedApp

  mCurrentFocus=Window{f96644 u0 NotificationShade}mFocusedApp=ActivityRecord{e9566ee u0 com.android.launcher3/.uioverrides.QuickstepLauncher} t12}

mCurrentFocus指的是当前的焦点窗口
mFocusedApp指的是当前的焦点Activity

查看有没有LAST ANR

WINDOW MANAGER LAST ANR (dumpsys window lastanr)<no ANR has occurred since boot>

这里没有LAST ANR,如果有,mCurrentFocus会显示null

input

在dumpsys input中查看FocusedApplications和FocusedWindows

  FocusedApplications:displayId=0, name='ActivityRecord{e9566ee u0 com.android.launcher3/.uioverrides.QuickstepLauncher} t12}', dispatchingTimeout=5000msFocusedWindows:displayId=0, name='f96644 NotificationShade'

如果发生ANR,焦点窗口以dumpsys input为主

event log

05-18 19:22:55.806   580   607 I input_focus: [Focus request f96644 NotificationShade,reason=UpdateInputWindows]
05-18 19:22:55.837   580   675 I input_focus: [Focus leaving e225d94 com.android.launcher3/com.android.launcher3.uioverrides.QuickstepLauncher (server),reason=Waiting for window because NO_WINDOW]
05-18 19:22:55.855   580   675 I input_focus: [Focus entering f96644 NotificationShade (server),reason=Window became focusable. Previous reason: NOT_VISIBLE]

requestentering正常情况下是一一对应,打印了entering则表示真正的焦点已经进入到对应的窗口
发生Application does not hava focused window时,一般request 有打印,我们可以通过是否有entering的打印来分析
1.entering部分有打印,代表焦点已经在input里面,但是仍然有ANR,就需要从input角度分析
2.entering部分未打印,代表input没有被触发焦点窗口设置到input,需排查SurfaceFlinger或WMS

http://www.lryc.cn/news/69548.html

相关文章:

  • 研发工程师玩转Kubernetes——构建、推送自定义镜像
  • [网络安全]DVWA之XSS(Stored)攻击姿势及解题详析合集
  • VP记录:Codeforces Round 873 (Div. 2) A~D1
  • 【C++】函数提高
  • 【可持续能源:让我们迈向绿色、可持续未来的道路】
  • ES6中数组新增了哪些扩展?
  • 【算法】动态规划
  • HNOI2014 世界树
  • 在MyBatis XML文件中处理特殊符号的方法,如“>”、“<”、“>=”、“<=”这些符号XML会报错如何处理
  • 第三章--第一篇:什么是对话系统?
  • 项目基础搭建
  • PFCdocumentation_FISH Rules and Usage
  • 如何完美卸载VS2015(2023年5月份实测有效)
  • JavaScript如何声明和定义函数
  • 微信小程序 WebSocket 通信 —— 在线聊天
  • VMware快照:简化虚拟化环境管理与数据保护
  • 图的最短路径
  • RHCE----Shell变量和引用
  • 【Redis】聊一下缓存雪崩、击穿、穿透、预热
  • 全景描绘云原生技术图谱,首个《云原生应用引擎技术发展白皮书》发布
  • 【Python共享文件】——Python快速搭建HTTP web服务实现文件共享并公网远程访问
  • Mysql数据库分库分表
  • SpringBoot热部署插件原理分析及实战演练
  • 【C++ 入坑指南】(10)函数
  • P2233 [HNOI2002]公交车路线
  • java入门-W11(K168-K182)网络编程
  • 距离6月18日DAMA-CDGA/CDGP认证考试还有31天,报名从速
  • PO、VO、DAO、BO、DTO、POJO区分
  • MobPush Flutter平台插件
  • 机器学习面试题库:K-means