[webkit-changes] [WebKit/WebKit] cd2edb: AX: -[WKAccessibilityWebPageObjectMac accessibilit...

Tyler Wilcock noreply at github.com
Sun Dec 15 12:35:31 PST 2024


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

  Changed paths:
    M Source/WebKit/WebProcess/WebPage/mac/WKAccessibilityWebPageObjectBase.h
    M Source/WebKit/WebProcess/WebPage/mac/WKAccessibilityWebPageObjectBase.mm
    M Source/WebKit/WebProcess/WebPage/mac/WKAccessibilityWebPageObjectMac.mm
    M Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm

  Log Message:
  -----------
  AX: -[WKAccessibilityWebPageObjectMac accessibilityAttributeValue] hits the main-thread unnecessarily
https://bugs.webkit.org/show_bug.cgi?id=284681
rdar://problem/141469939

Reviewed by Chris Fleizach.

Prior to this commit, -[WKAccessibilityWebPageObjectMac accessibilityAttributeValue] unconditionally hit the main-thread
once to initialize accessibility (even if it had already been done so), and potentially again depending on the attribute
requested.

Solve the first main-thread hit by adding a std::atomic<bool> that can be set after we've initialized accessibility.
Checking an atomic bool is significantly cheaper than waiting on the main-thread, which could be busy.

Solve the second main-thread hit by making changes necessary to serve some attributes off the main-thread:

  - Cache NSAccessibilityPrimaryScreenHeightAttribute once at the same time we hit the main-thread to initialize
    accessibility for the first time, then store it in a std::atomic<unsigned> for subsequent use.

  - Put usage of WKAccessibilityWebPageObjectBase::m_parent behind a new lock, WKAccessibilityWebPageObjectBase::m_parentLock.
    RetainPtr reference counting is inherently threadsafe, but the lock is still necessary to ensure the main-thread
    cannot overwrite m_parent with a new value while the AX thread is reading it to serve a request.

* Source/WebKit/WebProcess/WebPage/mac/WKAccessibilityWebPageObjectBase.h:
* Source/WebKit/WebProcess/WebPage/mac/WKAccessibilityWebPageObjectBase.mm:
(-[WKAccessibilityWebPageObjectBase setRemoteParent:]):
* Source/WebKit/WebProcess/WebPage/mac/WKAccessibilityWebPageObjectMac.mm:
(-[WKAccessibilityWebPageObject accessibilityAttributeValue:]):
(-[WKAccessibilityWebPageObject accessibilityAttributeSizeValue]):
(-[WKAccessibilityWebPageObject accessibilityAttributePositionValue]):
(-[WKAccessibilityWebPageObject accessibilityAttributeParentValue]):
(-[WKAccessibilityWebPageObject accessibilityAttributeWindowValue]):
(-[WKAccessibilityWebPageObject accessibilityAttributeTopLevelUIElementValue]):

Canonical link: https://commits.webkit.org/287855@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