[webkit-changes] [WebKit/WebKit] 36b651: AX: Accessing AXIsolatedTree::rootNode() should no...

Tyler Wilcock noreply at github.com
Fri Dec 13 19:25:40 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 36b6519ff89e17bb7a38224b3f1c8403da54c417
      https://github.com/WebKit/WebKit/commit/36b6519ff89e17bb7a38224b3f1c8403da54c417
  Author: Tyler Wilcock <tyler_w at apple.com>
  Date:   2024-12-13 (Fri, 13 Dec 2024)

  Changed paths:
    M Source/WebCore/accessibility/AXObjectCache.cpp
    M Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp
    M Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp
    M Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.h
    M Source/WebKit/WebProcess/WebPage/mac/WKAccessibilityWebPageObjectMac.mm

  Log Message:
  -----------
  AX: Accessing AXIsolatedTree::rootNode() should not require taking a lock
https://bugs.webkit.org/show_bug.cgi?id=284640
rdar://141445513

Reviewed by Chris Fleizach.

rootNode() is called quite frequently (e.g. from screenRelativePosition(), relativeFrame(), isDetachedFromParent(), and more),
so it's important that it should be consistently fast to access (i.e. not behind m_changeLogLock).

With this commit, we add AXIsolatedTree::m_pendingRootNode, matching the pattern of other state we sync to the AX thread,
e.g. m_pendingFocusedNodeID and m_focusedNodeID. The expectation then becomes that AXIsolatedTree::m_rootNode is only
ever read and written from the AX thread, except when each AXIsolatedTree is first created before it is registered
via AXIsolatedTree::storeTree, as at that point only the main-thread can access the tree.

This commit also fixes a potential thread-safety issue where AXIsolatedTree::updateRootScreenRelativePosition accessed
the root node on the main-thread after the tree was registed via `AXIsolatedTree::storeTree`.

* Source/WebCore/accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::getOrCreateIsolatedTree):
(WebCore::AXObjectCache::buildIsolatedTree):
(WebCore::AXObjectCache::isolatedTreeRootObject):
* Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp:
(WebCore::AXIsolatedObject::isDetachedFromParent):
* Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp:
(WebCore::AXIsolatedTree::createEmptyContent):
(WebCore::AXIsolatedTree::create):
(WebCore::AXIsolatedTree::applyPendingRootNode):
(WebCore::AXIsolatedTree::nodeChangeForObject):
(WebCore::AXIsolatedTree::setPendingRootNodeLocked):
(WebCore::AXIsolatedTree::updateRootScreenRelativePosition):
(WebCore::AXIsolatedTree::applyPendingChanges):
(WebCore::AXIsolatedTree::rootNode): Deleted.
(WebCore::AXIsolatedTree::setRootNode): Deleted.
* Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.h:
(WebCore::AXIsolatedTree::rootNode):
* Source/WebKit/WebProcess/WebPage/mac/WKAccessibilityWebPageObjectMac.mm:
(-[WKAccessibilityWebPageObject accessibilityAttributeValue:]):

Canonical link: https://commits.webkit.org/287828@main



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list