Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f36f30e2e54847922e9b65cce60ab4fd75200404
      
https://github.com/WebKit/WebKit/commit/f36f30e2e54847922e9b65cce60ab4fd75200404
  Author: Tyler Wilcock <tyle...@apple.com>
  Date:   2023-10-10 (Tue, 10 Oct 2023)

  Changed paths:
    M Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm

  Log Message:
  -----------
  AX: -[WebAccessibilityObjectWrapper accessibilityIndexOfChild:] unnecessarily 
allocates an NSArray
https://bugs.webkit.org/show_bug.cgi?id=262941
rdar://problem/116717845

Reviewed by Chris Fleizach.

Prior to this patch, accessibilityIndexOfChild calls childrenVectorArray, which 
turns AXCoreObject::children()
into an NSArray of the corresponding wrappers. This is bad to use in 
accessibilityIndexOfChild for two reasons:

  1. This NSArray allocation shows up in the thousands of samples on some sites
  2. childrenVectorArray eagerly resolves attachments, which (for now) requires 
a main-thread hit,
     even if accessibilityIndexOfChild doesn't use the attachment

With this patch, we iterate over the children directly without allocating the 
NSArray. This saves 7k samples
on an internal webpage. Snippet from the sample:

6952 -[WebAccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]
! 6861 -[NSObject(NSObjectAccessibilityAttributeAccessAdditions) 
accessibilityIndexForChildUIElementAttributeForParameter:]
! : 6698 -[WebAccessibilityObjectWrapper accessibilityIndexOfChild:]
! : | 5016 makeNSArray(WTF::Vector<...> const&)
! : | + 4020 objc_msgSend  (in libobjc.A.dylib)
! : | + 684 -[__NSArrayM addObject:]
! : | + 133 -[__NSArrayM insertObject:atIndex:]
! : | + 66 objc_msgSend$addObject:
! : | + 61 objc_retain
! : | + 28 objc_msgSend$insertObject:atIndex:
! : | + 24 DYLD-STUB$$objc_retain
! : | 1163 makeNSArray(WTF::Vector<...> const&)

* Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper accessibilityIndexOfChild:]):

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


_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to