Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 498510277e2c87eee205596bd973049eece62837
      
https://github.com/WebKit/WebKit/commit/498510277e2c87eee205596bd973049eece62837
  Author: Tyler Wilcock <[email protected]>
  Date:   2024-12-18 (Wed, 18 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/141629794

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.

The first attempt at making this change was reverted in 
https://commits.webkit.org/287865@main because it caused
crashes in debug macOS layout tests with added assert:

ASSERT(!m_window);

This commit changes the assert to allow the window to be set to the same value, 
i.e.:

ASSERT(!m_window || m_window.get() == window);

* 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/288040@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to