网站建设企业推荐,东莞网站建设 硅胶,商丘房产网,重庆飘逸科技有限公司背景
我们经常会遇到一种Application does not hava focused window的ANR异常#xff0c;这种异常一般是没有焦点窗口FocusedWindow导致,且这类异常只会发生在key事件的派发#xff0c;因为key事件是需要找到一个焦点窗口然后再派发#xff0c;而触摸事件只需要找到当前显示…背景
我们经常会遇到一种Application does not hava focused window的ANR异常这种异常一般是没有焦点窗口FocusedWindow导致,且这类异常只会发生在key事件的派发因为key事件是需要找到一个焦点窗口然后再派发而触摸事件只需要找到当前显示的窗口即可
关键日志
window
在dumpsys window中查看mCurrentFocus和mFocusedApp mCurrentFocusWindow{f96644 u0 NotificationShade}mFocusedAppActivityRecord{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:displayId0, nameActivityRecord{e9566ee u0 com.android.launcher3/.uioverrides.QuickstepLauncher} t12}, dispatchingTimeout5000msFocusedWindows:displayId0, namef96644 NotificationShade如果发生ANR焦点窗口以dumpsys input为主
event log
05-18 19:22:55.806 580 607 I input_focus: [Focus request f96644 NotificationShade,reasonUpdateInputWindows]
05-18 19:22:55.837 580 675 I input_focus: [Focus leaving e225d94 com.android.launcher3/com.android.launcher3.uioverrides.QuickstepLauncher (server),reasonWaiting for window because NO_WINDOW]
05-18 19:22:55.855 580 675 I input_focus: [Focus entering f96644 NotificationShade (server),reasonWindow became focusable. Previous reason: NOT_VISIBLE]request 和 entering正常情况下是一一对应打印了entering则表示真正的焦点已经进入到对应的窗口 发生Application does not hava focused window时一般request 有打印我们可以通过是否有entering的打印来分析 1.entering部分有打印代表焦点已经在input里面但是仍然有ANR就需要从input角度分析 2.entering部分未打印代表input没有被触发焦点窗口设置到input需排查SurfaceFlinger或WMS