30

遍历 AccessibilityNodeInfo 报 StackOverflowError

 5 years ago
source link: http://likfe.com/2019/02/17/StackOverflowErrorInAccessibilityNodeInfo/?amp%3Butm_medium=referral
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

在使用 AccessibilityService 遍历包含 WebView 的 AccessibilityNodeInfo 时会在某些情况下必现 StackOverflowError 的错误,导致应用崩溃。

0x00 异常

最近使用 Android 的 AccessibilityService 做一些自动化操作时发现,在部分机器上遍历包含 WebView 页面的 AccessibilityNodeInfo 时,某些页面必定会引起 StackOverflowError 错误,经过一番查证,定位到主要与系统所使用的 Android System WebView 版本有关,属于 WebView 的 Bug。

相关说明可以参考 Android: Infinite loop of FrameLayouts in accessibility tree 的讨论。

查看 Android System WebView 版本(以下2种方法任一均可):

  1. 应用程序
    1. 菜单:显示系统应用程序
    2. 点击列表中的:Android System WebView
    3. 详情页内包含版本
  2. 开发者选项
    1. 开启「开发者选项」
    2. 开发者选项 -> WebView 实现

0x01 解决

方法有2种:

StackOverflowError

当然,方法2更具有可控性和兼容性,某些情况下我们并不能左右用户手机上 Android System WebView 的版本。

0x02 总结

此类情况发生在特定的 Android System WebView 和 Android 版本上,建议使用了相关功能的应用加上 Bug 上报的功能。

如果有什么建议或者问题可以随时联系我,共同探讨学习:


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK