RESOLVED FIXED 244724
AX: Cache accessibilityIsIgnored before in AXIsolatedTree::generateSubtree and AXIsolatedTree::updateChildren
https://bugs.webkit.org/show_bug.cgi?id=244724
Summary AX: Cache accessibilityIsIgnored before in AXIsolatedTree::generateSubtree an...
Tyler Wilcock
Reported 2022-09-02 13:16:11 PDT
We do a lot of repeated live tree reads in these codepaths, so we should make sure we are caching is-ignored for better performance.
Attachments
Patch (4.41 KB, patch)
2022-09-02 13:23 PDT, Tyler Wilcock
no flags
Patch (4.56 KB, patch)
2023-05-23 17:34 PDT, Tyler Wilcock
no flags
Patch (4.53 KB, patch)
2023-05-24 10:36 PDT, Tyler Wilcock
no flags
Radar WebKit Bug Importer
Comment 1 2022-09-02 13:16:21 PDT
Tyler Wilcock
Comment 2 2022-09-02 13:23:50 PDT
chris fleizach
Comment 3 2022-09-05 23:12:03 PDT
Comment on attachment 462104 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=462104&action=review > COMMIT_MESSAGE:12 > +This patch also AXAttributeCacheEnabler to not disable the AXComputedObjectAttributeCache also modifies(?) > Source/WebCore/accessibility/AXObjectCache.h:605 > + bool m_wasAlreadyCachingAttributes { false }; wasAlready feel redundant to just having "m_cachingAttributes"... or maybe something shorter "m_inAttributeCaching"
Andres Gonzalez
Comment 4 2022-09-07 05:59:16 PDT
(In reply to Tyler Wilcock from comment #2) > Created attachment 462104 [details] > Patch --- a/Source/WebCore/accessibility/AXObjectCache.h +++ a/Source/WebCore/accessibility/AXObjectCache.h + bool m_wasAlreadyCachingAttributes { false }; Why do we need this extra flag? --- a/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp +++ a/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp @@ -205,6 +205,8 @@ void AXIsolatedTree::generateSubtree(AXCoreObject& axObject) if (!axObject.objectID().isValid()) return; + // We're about to a lot of read-only work, so start the attribute cache. "to a lot" -> "to do a lot" What do you mean by "read-only work"? Not read-only for this isolated tree. @@ -533,6 +535,9 @@ void AXIsolatedTree::updateChildren(AccessibilityObject& axObject, ResolveNodeCh if (!axObject.document() || !axObject.document()->hasLivingRenderTree()) return; + // We're about to a lot of read-only work, so start the attribute cache. Dito.
Tyler Wilcock
Comment 5 2023-05-23 17:34:36 PDT
Tyler Wilcock
Comment 6 2023-05-23 17:38:09 PDT
(In reply to chris fleizach from comment #3) > Comment on attachment 462104 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=462104&action=review > > > COMMIT_MESSAGE:12 > > +This patch also AXAttributeCacheEnabler to not disable the AXComputedObjectAttributeCache > > also modifies(?) > > > Source/WebCore/accessibility/AXObjectCache.h:605 > > + bool m_wasAlreadyCachingAttributes { false }; > > wasAlready feel redundant to just having "m_cachingAttributes"... or maybe > something shorter "m_inAttributeCaching" The intent I'm trying to capture is whether AXObjectCache::computedObjectAttributeCache existed before this AXAttributeCacheEnabler was created (i.e. we were already caching attributes). If so, we need to set this flag so we don't destroy it when this AXAttributeCacheEnabler is destroyed. I feel like m_inAttributeCaching or m_cachingAttributes don't capture that as well as m_wasAlreadyCachingAttributes...but I don't feel too strongly about it.
Tyler Wilcock
Comment 7 2023-05-23 17:38:50 PDT
(In reply to Andres Gonzalez from comment #4) > (In reply to Tyler Wilcock from comment #2) > > Created attachment 462104 [details] > > Patch > > --- a/Source/WebCore/accessibility/AXObjectCache.h > +++ a/Source/WebCore/accessibility/AXObjectCache.h > > + bool m_wasAlreadyCachingAttributes { false }; > > Why do we need this extra flag? I tried to describe this in the commit message, but let me know if that needs some more clarity.
Andres Gonzalez
Comment 8 2023-05-24 08:46:37 PDT
(In reply to Tyler Wilcock from comment #5) > Created attachment 466469 [details] > Patch --- a/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp +++ b/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp + // We're about to a lot of read-only work, so start the attribute cache. about to a lot -> about to do a lot ? Is traversing the live tree always read-only? I think there are cases where getting the children for an object, for instance, can change the role of that object.
Andres Gonzalez
Comment 9 2023-05-24 09:00:24 PDT
(In reply to Tyler Wilcock from comment #6) > (In reply to chris fleizach from comment #3) > > Comment on attachment 462104 [details] > > Patch > > > > View in context: > > https://bugs.webkit.org/attachment.cgi?id=462104&action=review > > > > > COMMIT_MESSAGE:12 > > > +This patch also AXAttributeCacheEnabler to not disable the AXComputedObjectAttributeCache > > > > also modifies(?) > > > > > Source/WebCore/accessibility/AXObjectCache.h:605 > > > + bool m_wasAlreadyCachingAttributes { false }; > > > > wasAlready feel redundant to just having "m_cachingAttributes"... or maybe > > something shorter "m_inAttributeCaching" > The intent I'm trying to capture is whether > AXObjectCache::computedObjectAttributeCache existed before this > AXAttributeCacheEnabler was created (i.e. we were already caching > attributes). If so, we need to set this flag so we don't destroy it when > this AXAttributeCacheEnabler is destroyed. > > I feel like m_inAttributeCaching or m_cachingAttributes don't capture that > as well as m_wasAlreadyCachingAttributes...but I don't feel too strongly > about it. Agree that it should be a shorter name. Where is this flag turned off? generateSubtree and updateChildren will turn it on but not off, i.e., once it is on, it will be on until something else turns it off. I believe this whole mechanism is quite weak and bug prone.
Tyler Wilcock
Comment 10 2023-05-24 10:36:26 PDT
Tyler Wilcock
Comment 11 2023-05-24 10:43:26 PDT
(In reply to Andres Gonzalez from comment #9) > (In reply to Tyler Wilcock from comment #6) > > (In reply to chris fleizach from comment #3) > > > Comment on attachment 462104 [details] > > > Patch > > > > > > View in context: > > > https://bugs.webkit.org/attachment.cgi?id=462104&action=review > > > > > > > COMMIT_MESSAGE:12 > > > > +This patch also AXAttributeCacheEnabler to not disable the AXComputedObjectAttributeCache > > > > > > also modifies(?) > > > > > > > Source/WebCore/accessibility/AXObjectCache.h:605 > > > > + bool m_wasAlreadyCachingAttributes { false }; > > > > > > wasAlready feel redundant to just having "m_cachingAttributes"... or maybe > > > something shorter "m_inAttributeCaching" > > The intent I'm trying to capture is whether > > AXObjectCache::computedObjectAttributeCache existed before this > > AXAttributeCacheEnabler was created (i.e. we were already caching > > attributes). If so, we need to set this flag so we don't destroy it when > > this AXAttributeCacheEnabler is destroyed. > > > > I feel like m_inAttributeCaching or m_cachingAttributes don't capture that > > as well as m_wasAlreadyCachingAttributes...but I don't feel too strongly > > about it. > > Agree that it should be a shorter name. > > Where is this flag turned off? generateSubtree and updateChildren will turn > it on but not off, i.e., once it is on, it will be on until something else > turns it off. I believe this whole mechanism is quite weak and bug prone. Re-capping our conversation off Bugzilla for posterity: The cache is turned off when the highest-most-stackframe AXAttributeCacheEnabler is destroyed, or when we post any notification. We should be safe from this causing bugs because we unconditionally bust the cache in every known way the tree mutates such that a different is-ignored value would be computed.
Tyler Wilcock
Comment 12 2023-05-24 10:44:12 PDT
Also made the name of the flag shorter.
EWS
Comment 13 2023-05-25 10:28:54 PDT
Committed 264524@main (9128760a1c6a): <https://commits.webkit.org/264524@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 466483 [details].
Note You need to log in before you can comment on or make changes to this bug.