Bug 253247

Summary: AX: Cache the AttributedString for objects of role Tab and WebCoreLink in AXIsolatedObjects.
Product: WebKit Reporter: Andres Gonzalez <andresg_22>
Component: AccessibilityAssignee: Andres Gonzalez <andresg_22>
Status: RESOLVED FIXED    
Severity: Normal CC: aboxhall, andresg_22, apinheiro, cfleizach, dmazzoni, ews-watchlist, jcraig, jdiggs, samuel_white, tyler_w, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch
none
Patch none

Andres Gonzalez
Reported 2023-03-02 09:06:22 PST
This will reduce main thread hits in some web pages considerably.
Attachments
Patch (11.38 KB, patch)
2023-03-02 09:15 PST, Andres Gonzalez
no flags
Patch (9.93 KB, patch)
2023-03-02 11:28 PST, Andres Gonzalez
no flags
Radar WebKit Bug Importer
Comment 1 2023-03-02 09:06:47 PST
Andres Gonzalez
Comment 2 2023-03-02 09:15:10 PST
chris fleizach
Comment 3 2023-03-02 10:10:53 PST
Comment on attachment 465263 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=465263&action=review > Source/WebCore/accessibility/AccessibilityNodeObject.cpp:2147 > if (!node) I don’t know if weak ptr helps here. If it goes away, we might still hit a null ptr. Do we instead want to ref this so we hold onto to it until end of scope?
Tyler Wilcock
Comment 4 2023-03-02 10:26:17 PST
Comment on attachment 465263 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=465263&action=review > Source/WebCore/accessibility/AccessibilityNodeObject.cpp:-2173 > + // For <select> elements, title should be empty if they are not rendered or have role PopUpButton. > + if (node && node->hasTagName(selectTag) > + && (!isAccessibilityRenderObject() || roleValue() == AccessibilityRole::PopUpButton)) > + return { }; > > switch (roleValue()) { > - case AccessibilityRole::PopUpButton: > - // Native popup buttons should not use their button children's text as a title. That value is retrieved through stringValue(). > - if (node->hasTagName(selectTag)) > - return String(); > - FALLTHROUGH; Prior to your change, AccessibilityRole::PopUpButton without node->hasTagName(selectTag) would FALLTHROUGH to useTextUnderElement = true. And now we won't do that (because AccessibilityRole::PopUpButton is no longer handled in the switch). Am I reading that right, and if so is this behavior change intentional? > Source/WebCore/accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm:114 > + AXLOG(makeString("AXIsolatedObject::attributedStringForTextMarkerRange", " role = ", accessibilityRoleToString(roleValue()))); Definitely understand why these logs would be useful for your work on this bug, but are they generally useful? I think this gets requested a lot, so they might make our logs more noisy then they already are. (Same comment for the AXTRACE in this method)
Andres Gonzalez
Comment 5 2023-03-02 10:32:10 PST
(In reply to chris fleizach from comment #3) > Comment on attachment 465263 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=465263&action=review > > > Source/WebCore/accessibility/AccessibilityNodeObject.cpp:2147 > > if (!node) > > I don’t know if weak ptr helps here. If it goes away, we might still hit a > null ptr. Do we instead want to ref this so we hold onto to it until end of > scope? All depends on what we are doing with the pointer in the given scope. In this case I think WeakPtr is fine because we only use it for dynamicDowncast or we check for nil before using. That's what makes this a bit tricky, one has to understand the context. In general we don't always want to do RefPtr, especially for Nodes or other objects that we don't create.
Andres Gonzalez
Comment 6 2023-03-02 11:28:50 PST
Andres Gonzalez
Comment 7 2023-03-02 11:34:31 PST
(In reply to Tyler Wilcock from comment #4) > Comment on attachment 465263 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=465263&action=review > > > Source/WebCore/accessibility/AccessibilityNodeObject.cpp:-2173 > > + // For <select> elements, title should be empty if they are not rendered or have role PopUpButton. > > + if (node && node->hasTagName(selectTag) > > + && (!isAccessibilityRenderObject() || roleValue() == AccessibilityRole::PopUpButton)) > > + return { }; > > > > switch (roleValue()) { > > - case AccessibilityRole::PopUpButton: > > - // Native popup buttons should not use their button children's text as a title. That value is retrieved through stringValue(). > > - if (node->hasTagName(selectTag)) > > - return String(); > > - FALLTHROUGH; > > Prior to your change, AccessibilityRole::PopUpButton without > node->hasTagName(selectTag) would FALLTHROUGH to useTextUnderElement = true. > And now we won't do that (because AccessibilityRole::PopUpButton is no > longer handled in the switch). Am I reading that right, and if so is this > behavior change intentional? Good catch! meant to put it down below and forgot! > > > Source/WebCore/accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm:114 > > + AXLOG(makeString("AXIsolatedObject::attributedStringForTextMarkerRange", " role = ", accessibilityRoleToString(roleValue()))); > > Definitely understand why these logs would be useful for your work on this > bug, but are they generally useful? I think this gets requested a lot, so > they might make our logs more noisy then they already are. (Same comment for > the AXTRACE in this method) Removed all the new AX logging. We definitely have to improve our logging so that we can leave debugging stuff like this, so that you don't have to re-create it, and still doesn't show in the logs unless you want to.
EWS
Comment 8 2023-03-03 07:29:42 PST
Committed 261140@main (1b2f162302f9): <https://commits.webkit.org/261140@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 465266 [details].
Note You need to log in before you can comment on or make changes to this bug.