Bug 244941 - AX: AXIsolatedTree and some objects within are not cleaned up upon page reload or navigation
Summary: AX: AXIsolatedTree and some objects within are not cleaned up upon page reloa...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Accessibility (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Tyler Wilcock
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-09-08 11:44 PDT by Tyler Wilcock
Modified: 2022-09-12 19:05 PDT (History)
10 users (show)

See Also:


Attachments
Patch (18.11 KB, patch)
2022-09-08 12:04 PDT, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (18.11 KB, patch)
2022-09-08 12:12 PDT, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (18.10 KB, patch)
2022-09-08 12:14 PDT, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (19.82 KB, patch)
2022-09-08 17:49 PDT, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (27.29 KB, patch)
2022-09-09 11:47 PDT, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (28.08 KB, patch)
2022-09-09 14:32 PDT, Tyler Wilcock
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (28.80 KB, patch)
2022-09-09 16:13 PDT, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (28.79 KB, patch)
2022-09-09 20:14 PDT, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (28.84 KB, patch)
2022-09-12 10:44 PDT, Tyler Wilcock
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tyler Wilcock 2022-09-08 11:44:13 PDT
AXIsolatedTree and some objects within are not cleaned up upon page reload or navigation
Comment 1 Radar WebKit Bug Importer 2022-09-08 11:44:24 PDT
<rdar://problem/99708493>
Comment 2 Tyler Wilcock 2022-09-08 11:50:57 PDT
rdar://99574478
Comment 3 Tyler Wilcock 2022-09-08 12:04:48 PDT
Created attachment 462207 [details]
Patch
Comment 4 chris fleizach 2022-09-08 12:10:30 PDT
Comment on attachment 462207 [details]
Patch

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

> COMMIT_MESSAGE:7
> +Prior to this patch, we never seem to prperly clean up any `AXIsolatedTree`s

properly

> COMMIT_MESSAGE:18
> +the trees representation in treeIDCache() and treePageCache().

tree's

> Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityController.idl:33
> +    AccessibilityUIElement getRetainedElement();

getRetainedElement() -> retainedElement() ?
Comment 5 Tyler Wilcock 2022-09-08 12:12:51 PDT
Created attachment 462208 [details]
Patch
Comment 6 Tyler Wilcock 2022-09-08 12:14:08 PDT
Created attachment 462209 [details]
Patch
Comment 7 Tyler Wilcock 2022-09-08 12:14:21 PDT
(In reply to chris fleizach from comment #4)
> Comment on attachment 462207 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=462207&action=review
> 
> > COMMIT_MESSAGE:7
> > +Prior to this patch, we never seem to prperly clean up any `AXIsolatedTree`s
> 
> properly
> 
> > COMMIT_MESSAGE:18
> > +the trees representation in treeIDCache() and treePageCache().
> 
> tree's
> 
> > Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityController.idl:33
> > +    AccessibilityUIElement getRetainedElement();
> 
> getRetainedElement() -> retainedElement() ?

Fixed all of these.
Comment 8 Tyler Wilcock 2022-09-08 17:49:43 PDT
Created attachment 462216 [details]
Patch
Comment 9 Andres Gonzalez 2022-09-09 07:06:03 PDT
(In reply to Tyler Wilcock from comment #8)
> Created attachment 462216 [details]
> Patch

--- a/LayoutTests/accessibility/wrapper-destroyed-on-reload.html
+++ a/LayoutTests/accessibility/wrapper-destroyed-on-reload.html

I would call this test wrapper-retained-through-reload.html which is what the test really does.

+    var testOutput = "This test ensures that when a page is reloaded, we properly clean up the wrappers and AX objects from the previous iteration of the page.\n\n";
+    // This is expected behavior because the wrappers and AX objects from the previous iteration of the page (pre-reload) refer
+    // to DOM, render objects, etc. that no longer exist post-reload.

I don't think this test ensures we clean up the wrappers. It ensures that if the wrapper is retained by a client, the AccessibilityController in the TestRunner, after the reload the wrapper is invalid, meaning it wraps no backing object.

The AccessibilityController is holding to an AccessibilityUIElement that in turn is retaining the wrapper m_element. So the test should be testing that m_element is invalid/defunct, meaning that it doesn't have a backing object.

+            // Note that this actually reloads the test, too, which means the testOutput above will be written once,
+            // then thrown away with the reload, then written again, upon which we should enter the `else` below.
+            internals.forceReload(true);

Doesn't the axButton variable get re-initialized too? Maybe not because it is const?

+            // The wrapper and AX object that back this AccessibilityUIElement should've been destroyed by the reload,
+            // so no role should be returned here.

I don't think the wrapper (m_element) could have been destroyed, it shouldn't have been destroyed. The AX backing object should. Maybe we need to add a method to the wrapper to determine whether it has a backing object or not. So not sure if by checking the role we can tell for sure whether the wrapper is detached or null.

+            testOutput += `Role of #button element retained before forced reload: ${accessibilityController.retainedElement().role}\n`;

Can we clarify this message to indicate that is after the forced reload? A bit confusing to me whether the "before" refers to the retained or to the reload.
Comment 10 Tyler Wilcock 2022-09-09 11:47:01 PDT
Created attachment 462239 [details]
Patch
Comment 11 Tyler Wilcock 2022-09-09 11:51:41 PDT
(In reply to Andres Gonzalez from comment #9)
> (In reply to Tyler Wilcock from comment #8)
> > Created attachment 462216 [details]
> > Patch
> Doesn't the axButton variable get re-initialized too? Maybe not because it
> is const?
It is re-initialized, but the AccessibilityController holds a reference to the original AccessibilityUIElement (which is what axButton is). Then when the page reloads, `const axButton = ...` is run again and a new and different AccessibilityUIElement is created.
Comment 12 Tyler Wilcock 2022-09-09 14:32:34 PDT
Created attachment 462244 [details]
Patch
Comment 13 Tyler Wilcock 2022-09-09 16:13:25 PDT
Created attachment 462245 [details]
Patch
Comment 14 Tyler Wilcock 2022-09-09 20:14:36 PDT
Created attachment 462248 [details]
Patch
Comment 15 Tyler Wilcock 2022-09-12 10:44:29 PDT
Created attachment 462292 [details]
Patch
Comment 16 EWS 2022-09-12 19:05:02 PDT
Committed 254419@main (c808394fb05e): <https://commits.webkit.org/254419@main>

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