Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 71471a58fedd5b39f591f59fd35b13e35827e915
      
https://github.com/WebKit/WebKit/commit/71471a58fedd5b39f591f59fd35b13e35827e915
  Author: Tyler Wilcock <[email protected]>
  Date:   2026-04-13 (Mon, 13 Apr 2026)

  Changed paths:
    M Source/WebCore/accessibility/AccessibilityRenderObject.cpp
    M Source/WebCore/accessibility/AccessibilitySVGObject.cpp
    M Source/WebCore/accessibility/AccessibilitySVGObject.h

  Log Message:
  -----------
  AX: SVG accname computation expensive in Speedometer runs with accessibility 
enabled
https://bugs.webkit.org/show_bug.cgi?id=312163
rdar://174665355

Reviewed by Joshua Hoffman.

Profiling a Speedometer benchmark run shows 
AccessibilitySVGObject::accessibilityText() as a significant hotspot during
isolated tree creation (~2,500 samples / ~7.5% of all AX work on the main 
thread). The cost comes from
childElementWithMatchingLanguage(), which calls 
indexOfBestMatchingLanguageInList(), an expensive Cocoa NSLocale/ICU
locale matching operation.

This PR greatly optimizes accessibilityText() by reducing repeated and 
unnecessary work:

   4 → 0-2 indexOfBestMatchingLanguageInList calls per element in 
accessibilityText() (the hot path during tree building)
   4 → 1 languageIncludingAncestors() call
   4 → 1 defaultLanguage() call
   0 calls to any of the above when no child has a lang attribute. This is the 
common case for Chart.js SVGs.
   0 calls to any of the above when there are no <title>/<desc> children at all.

This yields a 1.25% improvement in our Speedometer runtime with accessibility 
enabled.

* Source/WebCore/accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::updateRoleAfterChildrenCreation):
* Source/WebCore/accessibility/AccessibilitySVGObject.cpp:
(WebCore::AccessibilitySVGObject::childElementWithMatchingLanguage const):
(WebCore::AccessibilitySVGObject::accessibilityText const):
(WebCore::AccessibilitySVGObject::matchingTitleAndDescChildren const):
(WebCore::AccessibilitySVGObject::descriptionFromTitleChild const):
(WebCore::AccessibilitySVGObject::helpTextFromChildren const):
* Source/WebCore/accessibility/AccessibilitySVGObject.h:

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



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

Reply via email to