Android a11y: Avoid firing too many WINDOW_CONTENT_CHANGED events.
This is a quick fix for a performance issue that we've seen in several cases but is particularly bad for one Android app on Android TV. Whenever a node in the accessibility tree changes, we fire a TYPE_WINDOW_CONTENT_CHANGED accessibility event, which is needed for Android to clear its accessibility cache. However, when a major change to a web page happens and a lot of events are fired on different nodes, the overhead of firing an event on every single node is much too high and just ends up slowing the device to a crawl or causing an ANR. The alternative is to just fire TYPE_WINDOW_CONTENT_CHANGED on the root, invalidating the whole WebView. This is inefficient compared to invalidating just one node, but much more efficient than individually updating hundreds of nodes. What this patch does is add some really simple and quick logic to count how many WINDOW_CONTENT_CHANGED events we're firing within a single accessibility tree atomic update, and when we reach some maximum it fires an event on the root and then suppresses further events of this type until the next update. It might be cleaner to move this logic to AccessibilityEventDispatcher instead in the future, but for now this is the most straightforward fix and it results in a big performance improvement in practice. is changing Bug: b/159131746 Change-Id: Ic04f5e87a205e80f460715de14f99de70a0cf90e AX-Relnotes: improves performance on some Android pages when lots of content Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2552897 Auto-Submit: Dominic Mazzoni <dmazzoni@chromium.org> Reviewed-by:Mark Schillaci <mschillaci@google.com> Commit-Queue: Mark Schillaci <mschillaci@google.com> Cr-Commit-Position: refs/heads/master@{#829900}
Showing
Please register or sign in to comment