Title: [259253] trunk/Source/WebKit
Revision
259253
Author
andresg...@apple.com
Date
2020-03-30 17:41:02 -0700 (Mon, 30 Mar 2020)

Log Message

Cache [WKAccessibilityWebPageObject accessibilityParameterizedAttributeNames] to avoid hitting often the main thread in isolated tree mode.
https://bugs.webkit.org/show_bug.cgi?id=209767

Reviewed by Chris Fleizach.

[WKAccessibilityWebPageObject accessibilityParameterizedAttributeNames]
is called often in isolated tree mode causing a dispatch to the main thread.
This change caches this value so it doesn't keep hitting the main thread.

* WebProcess/WebPage/mac/WKAccessibilityWebPageObjectMac.mm:
(-[WKAccessibilityWebPageObject ALLOW_DEPRECATED_IMPLEMENTATIONS_END]):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (259252 => 259253)


--- trunk/Source/WebKit/ChangeLog	2020-03-31 00:25:24 UTC (rev 259252)
+++ trunk/Source/WebKit/ChangeLog	2020-03-31 00:41:02 UTC (rev 259253)
@@ -1,3 +1,17 @@
+2020-03-30  Andres Gonzalez  <andresg...@apple.com>
+
+        Cache [WKAccessibilityWebPageObject accessibilityParameterizedAttributeNames] to avoid hitting often the main thread in isolated tree mode.
+        https://bugs.webkit.org/show_bug.cgi?id=209767
+
+        Reviewed by Chris Fleizach.
+
+        [WKAccessibilityWebPageObject accessibilityParameterizedAttributeNames]
+        is called often in isolated tree mode causing a dispatch to the main thread.
+        This change caches this value so it doesn't keep hitting the main thread.
+
+        * WebProcess/WebPage/mac/WKAccessibilityWebPageObjectMac.mm:
+        (-[WKAccessibilityWebPageObject ALLOW_DEPRECATED_IMPLEMENTATIONS_END]):
+
 2020-03-30  Chris Dumez  <cdu...@apple.com>
 
         WebKit should take a foreground assertion for offscreen loads when the app is foreground

Modified: trunk/Source/WebKit/WebProcess/WebPage/mac/WKAccessibilityWebPageObjectMac.mm (259252 => 259253)


--- trunk/Source/WebKit/WebProcess/WebPage/mac/WKAccessibilityWebPageObjectMac.mm	2020-03-31 00:25:24 UTC (rev 259252)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/WKAccessibilityWebPageObjectMac.mm	2020-03-31 00:41:02 UTC (rev 259253)
@@ -51,6 +51,12 @@
 
 namespace ax = WebCore::Accessibility;
 
+@interface WKAccessibilityWebPageObject()
+#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
+@property (nonatomic, strong) NSArray *cachedParameterizedAttributeNames;
+#endif
+@end
+
 @implementation WKAccessibilityWebPageObject
 
 #define PROTECTED_SELF protectedSelf = RetainPtr<WKAccessibilityWebPageObject>(self)
@@ -86,17 +92,28 @@
 - (NSArray *)accessibilityParameterizedAttributeNames
 ALLOW_DEPRECATED_IMPLEMENTATIONS_END
 {
-    return ax::retrieveValueFromMainThread<RetainPtr<id>>([PROTECTED_SELF] () -> RetainPtr<id> {
+#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
+    if (id cachedNames = self.cachedParameterizedAttributeNames)
+        return cachedNames;
+#endif
+
+    id names = ax::retrieveValueFromMainThread<RetainPtr<id>>([PROTECTED_SELF] () -> RetainPtr<id> {
         NSMutableArray *names = [NSMutableArray array];
         if (!protectedSelf->m_page)
             return names;
-        
-        if (auto corePage = protectedSelf->m_page->corePage()) {
+
+        if (auto* corePage = protectedSelf->m_page->corePage()) {
             for (auto& name : corePage->pageOverlayController().copyAccessibilityAttributesNames(true))
                 [names addObject:(NSString *)name];
         }
         return names;
     }).autorelease();
+
+#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
+    self.cachedParameterizedAttributeNames = names;
+#endif
+
+    return names;
 }
 
 ALLOW_DEPRECATED_IMPLEMENTATIONS_BEGIN
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to