Bug 235646 - AX ITM: Defer to the tree when determining AX object loading progress
Summary: AX ITM: Defer to the tree when determining AX object loading progress
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Accessibility (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Tyler Wilcock
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-01-26 09:08 PST by Tyler Wilcock
Modified: 2022-01-27 12:47 PST (History)
13 users (show)

See Also:


Attachments
Patch (25.13 KB, patch)
2022-01-26 09:58 PST, Tyler Wilcock
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (24.94 KB, patch)
2022-01-26 10:13 PST, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (26.31 KB, patch)
2022-01-26 11:06 PST, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (25.73 KB, patch)
2022-01-26 11:23 PST, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (30.23 KB, patch)
2022-01-26 12:16 PST, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (30.85 KB, patch)
2022-01-26 14:35 PST, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (30.60 KB, patch)
2022-01-26 15:17 PST, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (30.59 KB, patch)
2022-01-26 17:00 PST, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (30.58 KB, patch)
2022-01-26 17:04 PST, 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-01-26 09:08:40 PST
Currently, we set AXPropertyName::IsLoaded and AXPropertyName::EstimatedLoadingProgress once in AXIsolatedObject::initializeAttributeData and never update it.

This means that if an object is created while the page is at some non-100% load percentage, AX clients will always think the object isn't loaded.
Comment 1 Radar WebKit Bug Importer 2022-01-26 09:08:52 PST
<rdar://problem/88078376>
Comment 2 Tyler Wilcock 2022-01-26 09:58:11 PST
Created attachment 450031 [details]
Patch
Comment 3 Tyler Wilcock 2022-01-26 10:13:33 PST
Created attachment 450034 [details]
Patch
Comment 4 Tyler Wilcock 2022-01-26 11:06:38 PST
Created attachment 450038 [details]
Patch
Comment 5 Tyler Wilcock 2022-01-26 11:23:41 PST
Created attachment 450042 [details]
Patch
Comment 6 Andres Gonzalez 2022-01-26 11:24:53 PST
(In reply to Tyler Wilcock from comment #3)
> Created attachment 450034 [details]
> Patch

--- a/Source/WebCore/accessibility/AXObjectCache.cpp
+++ a/Source/WebCore/accessibility/AXObjectCache.cpp

+        m_estimatedLoadingProgress = newProgressValue;

Why estimated? This is the best we are going to know, right? So for us is the truth.

--- a/Source/WebCore/accessibility/AXObjectCache.h
+++ a/Source/WebCore/accessibility/AXObjectCache.h

+    void updateEstimatedLoadingProgress(double);
+    void loadingProgressFinished() { updateEstimatedLoadingProgress(1); }
+    double estimatedLoadingProgress() const { return m_estimatedLoadingProgress; }

consider updateLoadingProgress, loadingFinished and loadingProgress instead.

--- a/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h
+++ a/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h

-    double estimatedLoadingProgress() const override { return doubleAttributeValue(AXPropertyName::EstimatedLoadingProgress); }
+    double estimatedLoadingProgress() const override { return tree()->estimatedLoadingProgress(); }

Would get rid of "estimated". We are not estimating anything.

--- a/Source/WebCore/page/Page.cpp
+++ a/Source/WebCore/page/Page.cpp

+void Page::progressEstimateChanged(Frame& frameWithProgressUpdate) const
+{
+    if (auto* document = frameWithProgressUpdate.document()) {
+        if (auto* axObjectCache = document->axObjectCache())
+            axObjectCache->updateEstimatedLoadingProgress(progress().estimatedProgress());
+    }
+}
+
+void Page::progressFinished(Frame& frameWithCompletedProgress) const
+{
+    if (auto* document = frameWithCompletedProgress.document()) {
+        if (auto* axObjectCache = document->axObjectCache())
+            axObjectCache->loadingProgressFinished();
+    }
+}
+
Perhaps we want to do document->axObjectCacheIfExist() instead? Because I think document->axObjectCache() creates it if it doesn't exist, but I'm going by memory here.
Comment 7 Tyler Wilcock 2022-01-26 11:46:20 PST
(In reply to Andres Gonzalez from comment #6)
> (In reply to Tyler Wilcock from comment #3)
> > Created attachment 450034 [details]
> > Patch
> 
> --- a/Source/WebCore/accessibility/AXObjectCache.cpp
> +++ a/Source/WebCore/accessibility/AXObjectCache.cpp
> 
> +        m_estimatedLoadingProgress = newProgressValue;
> 
> Why estimated? This is the best we are going to know, right? So for us is
> the truth.
> 
> --- a/Source/WebCore/accessibility/AXObjectCache.h
> +++ a/Source/WebCore/accessibility/AXObjectCache.h
> 
> +    void updateEstimatedLoadingProgress(double);
> +    void loadingProgressFinished() { updateEstimatedLoadingProgress(1); }
> +    double estimatedLoadingProgress() const { return
> m_estimatedLoadingProgress; }
> 
> consider updateLoadingProgress, loadingFinished and loadingProgress instead.
> 
> --- a/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h
> +++ a/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h
> 
> -    double estimatedLoadingProgress() const override { return
> doubleAttributeValue(AXPropertyName::EstimatedLoadingProgress); }
> +    double estimatedLoadingProgress() const override { return
> tree()->estimatedLoadingProgress(); }
> 
> Would get rid of "estimated". We are not estimating anything.
> 
> --- a/Source/WebCore/page/Page.cpp
> +++ a/Source/WebCore/page/Page.cpp
> 
> +void Page::progressEstimateChanged(Frame& frameWithProgressUpdate) const
> +{
> +    if (auto* document = frameWithProgressUpdate.document()) {
> +        if (auto* axObjectCache = document->axObjectCache())
> +           
> axObjectCache->updateEstimatedLoadingProgress(progress().
> estimatedProgress());
> +    }
> +}
> +
> +void Page::progressFinished(Frame& frameWithCompletedProgress) const
> +{
> +    if (auto* document = frameWithCompletedProgress.document()) {
> +        if (auto* axObjectCache = document->axObjectCache())
> +            axObjectCache->loadingProgressFinished();
> +    }
> +}
> +
> Perhaps we want to do document->axObjectCacheIfExist() instead? Because I
> think document->axObjectCache() creates it if it doesn't exist, but I'm
> going by memory here.
Ah, axObjectCacheIfExists() is definitely what we want. Thanks!

I chose to name things like "estimatedLoadingProgress" instead of "loadingProgress" to be consistent with that naming in ProgressTracker, and in the AXCoreObject interface, which has a method called estimatedLoadingProgress.

I do agree that "loading progress" is better naming than "estimated loading progress", so I'm going to fix this by renaming the AXCoreObject interface method.
Comment 8 Tyler Wilcock 2022-01-26 12:16:32 PST
Created attachment 450054 [details]
Patch
Comment 9 Tyler Wilcock 2022-01-26 14:35:23 PST
Created attachment 450071 [details]
Patch
Comment 10 Tyler Wilcock 2022-01-26 15:17:13 PST
Created attachment 450076 [details]
Patch
Comment 11 chris fleizach 2022-01-26 15:58:06 PST
Comment on attachment 450076 [details]
Patch

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

> Source/WebCore/accessibility/AXObjectCache.h:529
> +    double m_loadingProgress { 0.25 };

how come default is .25

> Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.h:363
> +    void updateLoadingProgress(double newProgress);

not necessary to name newProgress here

> Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.h:416
> +    double m_loadingProgress { 0.25 };

defaults .25?
Comment 12 Tyler Wilcock 2022-01-26 16:58:08 PST
(In reply to chris fleizach from comment #11)
> Comment on attachment 450076 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=450076&action=review
> 
> > Source/WebCore/accessibility/AXObjectCache.h:529
> > +    double m_loadingProgress { 0.25 };
> 
> how come default is .25
> 
> > Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.h:363
> > +    void updateLoadingProgress(double newProgress);
> 
> not necessary to name newProgress here
> 
> > Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.h:416
> > +    double m_loadingProgress { 0.25 };
> 
> defaults .25?
The default is mostly arbitrary so long as it's not 100% since it will be overwritten as the page loads / reloads. I figured that by the time the cache / tree is created, we can guess the page will be at least 25% loaded, but no science there. In my testing this default is never actually used, but we should default initialize the value to something if not this.
Comment 13 chris fleizach 2022-01-26 16:59:20 PST
(In reply to Tyler Wilcock from comment #12)
> (In reply to chris fleizach from comment #11)
> > Comment on attachment 450076 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=450076&action=review
> > 
> > > Source/WebCore/accessibility/AXObjectCache.h:529
> > > +    double m_loadingProgress { 0.25 };
> > 
> > how come default is .25
> > 
> > > Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.h:363
> > > +    void updateLoadingProgress(double newProgress);
> > 
> > not necessary to name newProgress here
> > 
> > > Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.h:416
> > > +    double m_loadingProgress { 0.25 };
> > 
> > defaults .25?
> The default is mostly arbitrary so long as it's not 100% since it will be
> overwritten as the page loads / reloads. I figured that by the time the
> cache / tree is created, we can guess the page will be at least 25% loaded,
> but no science there. In my testing this default is never actually used, but
> we should default initialize the value to something if not this.

Ok if it doesn't matter, might be less confusing to just leave as zero (for other programmers looking at this)
Comment 14 Tyler Wilcock 2022-01-26 17:00:14 PST
Created attachment 450085 [details]
Patch
Comment 15 Tyler Wilcock 2022-01-26 17:04:03 PST
Created attachment 450086 [details]
Patch
Comment 16 Tyler Wilcock 2022-01-26 17:04:39 PST
> Ok if it doesn't matter, might be less confusing to just leave as zero (for
> other programmers looking at this)
OK, done.
Comment 17 EWS 2022-01-27 08:52:41 PST
Committed r288674 (246480@main): <https://commits.webkit.org/246480@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 450086 [details].
Comment 18 Don Olmstead 2022-01-27 12:38:58 PST
This broke !ENABLE(ACCESSIBILITY) builds because updateLoadingProgress wasn't added to in the block of inlined methods below.

Following up in with a patch in https://bugs.webkit.org/show_bug.cgi?id=235727
Comment 19 Tyler Wilcock 2022-01-27 12:46:20 PST
Sorry about that. Thanks for fixing it.
Comment 20 Don Olmstead 2022-01-27 12:47:48 PST
(In reply to Tyler Wilcock from comment #19)
> Sorry about that. Thanks for fixing it.

No worries it happens since none of the EWS bots are !ENABLE(ACCESSIBILITY).