Bug 257065 - AX: Stop clearing caching info for table components
Summary: AX: Stop clearing caching info for table components
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Accessibility (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: chris fleizach
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-05-19 17:06 PDT by chris fleizach
Modified: 2023-05-22 12:09 PDT (History)
10 users (show)

See Also:


Attachments
Patch (5.87 KB, patch)
2023-05-19 17:12 PDT, chris fleizach
no flags Details | Formatted Diff | Diff
Patch (1.80 KB, patch)
2023-05-20 10:21 PDT, chris fleizach
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description chris fleizach 2023-05-19 17:06:20 PDT
We should stop clearing caching for table components. The table hierarchy is a bit weird and has a non standard parent child relationship.
Comment 1 Radar WebKit Bug Importer 2023-05-19 17:06:34 PDT
<rdar://problem/109589379>
Comment 2 chris fleizach 2023-05-19 17:12:01 PDT
Created attachment 466428 [details]
Patch
Comment 3 Tyler Wilcock 2023-05-19 19:56:49 PDT
Comment on attachment 466428 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=466428&action=review

> Source/WebCore/accessibility/AccessibilityObject.h:746
> +    virtual bool shouldClearIgnoredDataForChild(AccessibilityObject&);

Can this be const?

> Source/WebCore/accessibility/AccessibilityTable.cpp:117
> +    if (is<AccessibilityTableRow>(child))
> +        return downcast<AccessibilityTableRow>(child).parentTable() != this;

Is checking that the parentTable == this necessary? `parentTable()` is not cheap, so I wonder if we should just allow any row like so until we have a real bug where this matters. Also, parentTable() returns nullptr if the table is not exposable, which seems like a strange reason to break the cache.

if (is<AccessibilityTableRow>(child))
    return false;

return AccessibilityObject::shouldClearIgnoredDataForChild(child);

> Source/WebCore/accessibility/AccessibilityTable.h:102
> +    bool shouldClearIgnoredDataForChild(AccessibilityObject&) override;

Can this be final instead of override?

> Source/WebCore/accessibility/AccessibilityTableColumn.h:60
> +    // Don't calculate ignored because this is not a "real" parent for its children.
> +    bool shouldClearIgnoredDataForChild(AccessibilityObject&) override { return false; };

Maybe I'm misreading, but I feel like this comment may not describe what this override is doing. We still calculate whether this object is ignored. Would something like this be accurate?

// Don't clear accessibilityIsIgnored caching for children of this object because it's a mock object inserted between actual DOM / render tree accessibility objects.

Also, can this be `final` instead of `override`? The former can help the optimizer reduce the effects of virtualization.

Ditto all of these comments for TableHeaderContainer.h.
Comment 4 Tyler Wilcock 2023-05-19 20:46:18 PDT
Comment on attachment 466428 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=466428&action=review

> Source/WebCore/accessibility/AccessibilityObject.cpp:4270
> -    if (child->parentObject() != this) {
> +    if (shouldClearIgnoredDataForChild(*child)) {
>          child->clearIsIgnoredFromParentData();
>          return;
>      }

I wonder if the right thing to do is to just delete this block.

It was added here:

https://github.com/WebKit/WebKit/commit/ce4a8c5a1b6a9349a2c0d3bbc1df42c6b5ceb2e3

With test accessibility/insert-children-assert.html. But I just built release and debug with this block commented out and all the tests pass.
Comment 5 chris fleizach 2023-05-19 21:02:40 PDT
(In reply to Tyler Wilcock from comment #4)
> Comment on attachment 466428 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=466428&action=review
> 
> > Source/WebCore/accessibility/AccessibilityObject.cpp:4270
> > -    if (child->parentObject() != this) {
> > +    if (shouldClearIgnoredDataForChild(*child)) {
> >          child->clearIsIgnoredFromParentData();
> >          return;
> >      }
> 
> I wonder if the right thing to do is to just delete this block.
> 
> It was added here:
> 
> https://github.com/WebKit/WebKit/commit/
> ce4a8c5a1b6a9349a2c0d3bbc1df42c6b5ceb2e3
> 
> With test accessibility/insert-children-assert.html. But I just built
> release and debug with this block commented out and all the tests pass.

Does it seem like that was added for correctness in some other flow?
Comment 6 Tyler Wilcock 2023-05-19 21:20:19 PDT
(In reply to chris fleizach from comment #5)
> (In reply to Tyler Wilcock from comment #4)
> > Comment on attachment 466428 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=466428&action=review
> > 
> > > Source/WebCore/accessibility/AccessibilityObject.cpp:4270
> > > -    if (child->parentObject() != this) {
> > > +    if (shouldClearIgnoredDataForChild(*child)) {
> > >          child->clearIsIgnoredFromParentData();
> > >          return;
> > >      }
> > 
> > I wonder if the right thing to do is to just delete this block.
> > 
> > It was added here:
> > 
> > https://github.com/WebKit/WebKit/commit/
> > ce4a8c5a1b6a9349a2c0d3bbc1df42c6b5ceb2e3
> > 
> > With test accessibility/insert-children-assert.html. But I just built
> > release and debug with this block commented out and all the tests pass.
> 
> Does it seem like that was added for correctness in some other flow?
Oops, looks like my GitHub link got broken. Here it is:

https://github.com/WebKit/WebKit/commit/ce4a8c5a1b6a9349a2c0d3bbc1df42c6b5ceb2e3

And actually, the `child->parentObject() != this` check was really added here:

https://github.com/WebKit/WebKit/commit/f031d0084a1585510bf5a6009a26fad4b4541255

If this prevents a bug, then we should have a test for that. But all tests pass without it. To me, this seems like added complexity with no measurable benefit (and measurable detriment -- a call to parentObject() and other virtual functions in one of our hotter codepaths).

What do you think?
Comment 7 chris fleizach 2023-05-19 21:36:50 PDT
(In reply to Tyler Wilcock from comment #6)
> (In reply to chris fleizach from comment #5)
> > (In reply to Tyler Wilcock from comment #4)
> > > Comment on attachment 466428 [details]
> > > Patch
> > > 
> > > View in context:
> > > https://bugs.webkit.org/attachment.cgi?id=466428&action=review
> > > 
> > > > Source/WebCore/accessibility/AccessibilityObject.cpp:4270
> > > > -    if (child->parentObject() != this) {
> > > > +    if (shouldClearIgnoredDataForChild(*child)) {
> > > >          child->clearIsIgnoredFromParentData();
> > > >          return;
> > > >      }
> > > 
> > > I wonder if the right thing to do is to just delete this block.
> > > 
> > > It was added here:
> > > 
> > > https://github.com/WebKit/WebKit/commit/
> > > ce4a8c5a1b6a9349a2c0d3bbc1df42c6b5ceb2e3
> > > 
> > > With test accessibility/insert-children-assert.html. But I just built
> > > release and debug with this block commented out and all the tests pass.
> > 
> > Does it seem like that was added for correctness in some other flow?
> Oops, looks like my GitHub link got broken. Here it is:
> 
> https://github.com/WebKit/WebKit/commit/
> ce4a8c5a1b6a9349a2c0d3bbc1df42c6b5ceb2e3
> 
> And actually, the `child->parentObject() != this` check was really added
> here:
> 
> https://github.com/WebKit/WebKit/commit/
> f031d0084a1585510bf5a6009a26fad4b4541255
> 
> If this prevents a bug, then we should have a test for that. But all tests
> pass without it. To me, this seems like added complexity with no measurable
> benefit (and measurable detriment -- a call to parentObject() and other
> virtual functions in one of our hotter codepaths).
> 
> What do you think?

Meant to improve performance but no way to check that. Do you think this will somehow regress performance? It's sort of hard for me to believe
Comment 8 Tyler Wilcock 2023-05-19 21:47:00 PDT
(In reply to chris fleizach from comment #7)
> (In reply to Tyler Wilcock from comment #6)
> > (In reply to chris fleizach from comment #5)
> > > (In reply to Tyler Wilcock from comment #4)
> > > > Comment on attachment 466428 [details]
> > > > Patch
> > > > 
> > > > View in context:
> > > > https://bugs.webkit.org/attachment.cgi?id=466428&action=review
> > > > 
> > > > > Source/WebCore/accessibility/AccessibilityObject.cpp:4270
> > > > > -    if (child->parentObject() != this) {
> > > > > +    if (shouldClearIgnoredDataForChild(*child)) {
> > > > >          child->clearIsIgnoredFromParentData();
> > > > >          return;
> > > > >      }
> > > > 
> > > > I wonder if the right thing to do is to just delete this block.
> > > > 
> > > > It was added here:
> > > > 
> > > > https://github.com/WebKit/WebKit/commit/
> > > > ce4a8c5a1b6a9349a2c0d3bbc1df42c6b5ceb2e3
> > > > 
> > > > With test accessibility/insert-children-assert.html. But I just built
> > > > release and debug with this block commented out and all the tests pass.
> > > 
> > > Does it seem like that was added for correctness in some other flow?
> > Oops, looks like my GitHub link got broken. Here it is:
> > 
> > https://github.com/WebKit/WebKit/commit/
> > ce4a8c5a1b6a9349a2c0d3bbc1df42c6b5ceb2e3
> > 
> > And actually, the `child->parentObject() != this` check was really added
> > here:
> > 
> > https://github.com/WebKit/WebKit/commit/
> > f031d0084a1585510bf5a6009a26fad4b4541255
> > 
> > If this prevents a bug, then we should have a test for that. But all tests
> > pass without it. To me, this seems like added complexity with no measurable
> > benefit (and measurable detriment -- a call to parentObject() and other
> > virtual functions in one of our hotter codepaths).
> > 
> > What do you think?
> 
> Meant to improve performance but no way to check that. Do you think this
> will somehow regress performance? It's sort of hard for me to believe
I think this patch as-is will definitely improve performance for tables. But I think removing this block:

    if (child->parentObject() != this) {
        child->clearIsIgnoredFromParentData();
        return;
    }

Will improve it even more, and for everything else too. It seems like we're bending over backwards to accommodate this logic when it's not even clear that it's necessary since no test relies on it.
Comment 9 Tyler Wilcock 2023-05-19 21:50:34 PDT
If we remove that block, we don't need any of the changes in this patch, making our code as a whole more simple. This would improve performance for everything by a bit, and improve performance for tables by a lot.
Comment 10 chris fleizach 2023-05-20 10:21:45 PDT
Created attachment 466437 [details]
Patch
Comment 11 EWS 2023-05-22 12:09:56 PDT
Committed 264340@main (e1b48c3d6e0d): <https://commits.webkit.org/264340@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 466437 [details].