[webkit-changes] [WebKit/WebKit] a653ee: AX: Optimize AccessibilityObject::supportsPressAct...
Tyler Wilcock
noreply at github.com
Thu Mar 9 00:30:49 PST 2023
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: a653ee93a3145c22c56cf4d7c6d4b3465177009a
https://github.com/WebKit/WebKit/commit/a653ee93a3145c22c56cf4d7c6d4b3465177009a
Author: Tyler Wilcock <tyler_w at apple.com>
Date: 2023-03-09 (Thu, 09 Mar 2023)
Changed paths:
M Source/WebCore/accessibility/AccessibilityObject.cpp
M Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp
M Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h
Log Message:
-----------
AX: Optimize AccessibilityObject::supportsPressAction() and eagerly cache AXPropertyName::SupportsPressAction
https://bugs.webkit.org/show_bug.cgi?id=253337
rdar://problem/106206220
Reviewed by Chris Fleizach.
In https://bugs.webkit.org/show_bug.cgi?id=240473, we moved AXPropertyName::SupportsPressAction to a lazy-caching
mechanism because it was too expensive to compute up-front. This is not ideal as many AX clients ask for accessibilityActionNames
(through which `AXCoreObject::supportsPressAction` is called) once per navigation request, meaning we have to hit the
main-thread for each navigation request.
The reason this method was slow is because it did a full subtree traversal to determine if there is more than one
accessible child matching certain criteria (if so, the object would not support the press action). A huge portion of
the sample was made up of copying `AXCoreObject::children` into the temporary search stack Vector, which was surprising
until I added logging and found that some objects have more than ten thousand children (and of course, if none of those children
met the criteria, we would add their children, and so on).
This patch introduces several optimizations:
1. We now stop the search after checking 512 candidate objects. If we've checked this many and still can't determine
if it's safe to expose the press action, we should exit. This should only be relevant for high-level elements
(e.g. a body element) with event handlers, and of those cases we should still catch most with this limit.
2. Limit the amount of things that can be copied into the temporary search stack Vector.
On the internal webpage that prompted making this property lazy, eagerly caching AXPropertyName::SupportsPressAction
took ~10000 samples of 47728 total samples before this patch, and ~50 samples of ~47000 samples after this patch.
AccessibilityObject::supportsPressAction was introduced with a test:
mac/press-action-not-exposed-for-event-delegation.html
Which still passes after this change.
* Source/WebCore/accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::supportsPressAction const):
* Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp:
(WebCore::AXIsolatedObject::initializeProperties):
(WebCore::AXIsolatedObject::getOrRetrievePropertyValue):
(WebCore::AXIsolatedObject::supportsPressAction const): Deleted.
* Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h:
Canonical link: https://commits.webkit.org/261413@main
More information about the webkit-changes
mailing list