Bug 224280 - Accessibility support for image text recognition.
Summary: Accessibility support for image text recognition.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Accessibility (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Andres Gonzalez
URL:
Keywords: InRadar
Depends on:
Blocks: 227440
  Show dependency treegraph
 
Reported: 2021-04-07 08:19 PDT by Andres Gonzalez
Modified: 2021-06-28 02:48 PDT (History)
10 users (show)

See Also:


Attachments
Patch (deleted)
2021-04-07 08:25 PDT, Andres Gonzalez
ews-feeder: commit-queue-
Details
Patch (deleted)
2021-04-07 08:58 PDT, Andres Gonzalez
no flags Details
Patch (14.84 KB, patch)
2021-04-12 08:56 PDT, Andres Gonzalez
no flags Details | Formatted Diff | Diff
Patch (24.63 KB, patch)
2021-04-15 08:11 PDT, Andres Gonzalez
no flags Details | Formatted Diff | Diff
Patch (29.70 KB, patch)
2021-04-15 15:55 PDT, Andres Gonzalez
no flags Details | Formatted Diff | Diff
Patch (34.03 KB, patch)
2021-04-15 18:56 PDT, Andres Gonzalez
no flags Details | Formatted Diff | Diff
Patch (42.77 KB, patch)
2021-05-19 13:04 PDT, Andres Gonzalez
no flags Details | Formatted Diff | Diff
Patch (38.22 KB, patch)
2021-06-17 16:53 PDT, Andres Gonzalez
no flags Details | Formatted Diff | Diff
Patch (37.37 KB, patch)
2021-06-18 06:54 PDT, Andres Gonzalez
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (37.46 KB, patch)
2021-06-18 07:32 PDT, Andres Gonzalez
no flags Details | Formatted Diff | Diff
Patch (37.63 KB, patch)
2021-06-21 08:22 PDT, Andres Gonzalez
no flags Details | Formatted Diff | Diff
Patch (37.62 KB, patch)
2021-06-21 10:54 PDT, Andres Gonzalez
no flags Details | Formatted Diff | Diff
Patch (38.33 KB, patch)
2021-06-22 11:40 PDT, Andres Gonzalez
no flags Details | Formatted Diff | Diff
Patch (39.00 KB, patch)
2021-06-23 08:28 PDT, Andres Gonzalez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andres Gonzalez 2021-04-07 08:19:47 PDT
Preliminary accessibility work to support image text extraction.
Comment 1 Radar WebKit Bug Importer 2021-04-07 08:19:56 PDT
<rdar://problem/76348740>
Comment 2 Andres Gonzalez 2021-04-07 08:25:30 PDT
Created attachment 425396 [details]
Patch
Comment 3 Andres Gonzalez 2021-04-07 08:58:08 PDT
Created attachment 425405 [details]
Patch
Comment 4 David Kilzer (:ddkilzer) 2021-04-07 09:21:25 PDT
The content of attachment 425396 [details] has been deleted
Comment 5 David Kilzer (:ddkilzer) 2021-04-09 09:34:08 PDT
The content of attachment 425405 [details] has been deleted
Comment 6 Andres Gonzalez 2021-04-12 08:56:11 PDT
Created attachment 425752 [details]
Patch
Comment 7 chris fleizach 2021-04-12 09:14:24 PDT
Comment on attachment 425752 [details]
Patch

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

> Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h:469
> +    bool isAXImageInstance() const override;

we should probably call this

isAccessibilityImageInstance() to match the other methods
Comment 8 Andres Gonzalez 2021-04-12 09:35:26 PDT
(In reply to chris fleizach from comment #7)
> Comment on attachment 425752 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=425752&action=review
> 
> > Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h:469
> > +    bool isAXImageInstance() const override;
> 
> we should probably call this
> 
> isAccessibilityImageInstance() to match the other methods

I was following the convention isClassNameInstance, and the class name AXImage, similar to isAXIsolatedObjectInstance. I very much prefer the AX prefix for class names instead of the whole Accessibility, and plan to do a gradual renaming. But I can be persuaded if you feel strongly otherwise.
Comment 9 Andres Gonzalez 2021-04-15 08:11:56 PDT
Created attachment 426105 [details]
Patch
Comment 10 Andres Gonzalez 2021-04-15 15:55:38 PDT
Created attachment 426147 [details]
Patch
Comment 11 Sam Weinig 2021-04-15 17:00:07 PDT
Comment on attachment 426147 [details]
Patch

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

> Source/WebCore/ChangeLog:3
> +        Preliminary accessibility work

Please provide a more clear title.

> Source/WebCore/ChangeLog:8
> +        No new tests (OOPS!).

Please include the reason no tests are being included.
Comment 12 Andres Gonzalez 2021-04-15 18:56:16 PDT
Created attachment 426170 [details]
Patch
Comment 13 chris fleizach 2021-04-15 22:58:59 PDT
Comment on attachment 426170 [details]
Patch

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

> Source/WebCore/accessibility/AXImage.cpp:62
> +    if (m_imageOverlayHost)

should this be !m_imageoverlayHost?
and second, do we want to return an empty array here in that case?

> Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:436
> +- (NSArray *)accessibilityElements
> +{

I don't think we should add this. this is actually more expensive, because to just know how many children there are, we have to create the NSArray and return it, rather than just returning the size of the array in elementCount

I also think that if we find that axElementAtIndex and friends are implemented we prefer that over accessibilityElements.

> Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:1863
> +    auto imageOverlayElements = self.axBackingObject->imageOverlayElements();

I feel like if the count is empty here, we should return nil. it will be a more efficient operation to return nil (which will be the common case(

> Source/WebCore/platform/Logging.cpp:93
> +    LogAccessibility.state = WTFLogChannelState::On;

this should probably be off right

> LayoutTests/ChangeLog:8
> +        * accessibility/image-link-expected.txt:

we'll probably need to skip these on the non supported platforms
Comment 14 Andres Gonzalez 2021-05-19 13:04:09 PDT
Created attachment 429088 [details]
Patch
Comment 15 Andres Gonzalez 2021-05-19 13:25:21 PDT
(In reply to chris fleizach from comment #13)
> Comment on attachment 426170 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=426170&action=review
> 
> > Source/WebCore/accessibility/AXImage.cpp:62
> > +    if (m_imageOverlayHost)
> 
> should this be !m_imageoverlayHost?
> and second, do we want to return an empty array here in that case?

The purpose of the block should be clearer in this revision. The return value of the function is now an Optional.

> 
> > Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:436
> > +- (NSArray *)accessibilityElements
> > +{
> 
> I don't think we should add this. this is actually more expensive, because
> to just know how many children there are, we have to create the NSArray and
> return it, rather than just returning the size of the array in elementCount
> 
> I also think that if we find that axElementAtIndex and friends are
> implemented we prefer that over accessibilityElements.

I removed the comment saying that this is preferable. I'd like to keep the method if possible cause it makes writing scripts clearer. As for what is more efficient, I'm not convinced that neither one is preferable. I believe the critical path is in retrieving the CoreObject children, and in the by index methods that has to happen multiple times to just iterate over the array. In any case, this is not taking away the by index/count methods.

> 
> > Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:1863
> > +    auto imageOverlayElements = self.axBackingObject->imageOverlayElements();
> 
> I feel like if the count is empty here, we should return nil. it will be a
> more efficient operation to return nil (which will be the common case(

Fixed with imageOverlayElements() returning an Optional.

> 
> > Source/WebCore/platform/Logging.cpp:93
> > +    LogAccessibility.state = WTFLogChannelState::On;
> 
> this should probably be off right

Yes.

> 
> > LayoutTests/ChangeLog:8
> > +        * accessibility/image-link-expected.txt:
> 
> we'll probably need to skip these on the non supported platforms

Yes.
Comment 16 chris fleizach 2021-05-19 15:50:29 PDT
Comment on attachment 429088 [details]
Patch

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

> Source/WebCore/accessibility/AXImage.cpp:68
> +        auto* axImage = axObjectCache->getOrCreate(m_imageOverlayHost.get());

this can be done in one line

> Source/WebCore/accessibility/AXImage.cpp:79
> +        WTFLogAlways("aqui estoy %p %p", this, imageOverlayHost.get());

remove this log

> Source/WebCore/accessibility/AXImage.cpp:82
> +        // FIXME: post notification.

what notification do we need here?

> Source/WebCore/accessibility/AXImage.cpp:86
> +    return children(); // FIXME: once notification is added, this should be return WTF::nullopt;

we need to return the image overlay again right?

> Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:433
> +- (NSArray *)accessibilityElements

is this necessary to implement?  isn't this handled by accessibilityElementAtIndex?

> Source/WebCore/platform/Logging.cpp:93
> +    LogAccessibility.state = WTFLogChannelState::On;

undo

> Source/WebKit/UIProcess/ios/PageClientImplIOS.mm:471
> +    WTFLogAlways("PageClientImpl::requestImageExtraction {");

probably remove these logs in this method

> Source/WebKit/WebProcess/WebPage/WebPage.cpp:7348
> +    WTFLogAlways("WebPage::requestImageExtraction {");

remove logging
Comment 17 Andres Gonzalez 2021-06-17 16:53:46 PDT
Created attachment 431742 [details]
Patch
Comment 18 Andres Gonzalez 2021-06-18 06:54:09 PDT
Created attachment 431774 [details]
Patch

Rebasing on master.
Comment 19 Andres Gonzalez 2021-06-18 07:32:03 PDT
Created attachment 431776 [details]
Patch

Build fix for non-Cocoa platforms.
Comment 20 Andres Gonzalez 2021-06-21 08:22:51 PDT
Created attachment 431862 [details]
Patch
Comment 21 Andres Gonzalez 2021-06-21 10:54:56 PDT
Created attachment 431878 [details]
Patch

Fixes accessibility/image-link.html since imageOverlayElements returns nil instead of a 0-element array.
Comment 22 Andres Gonzalez 2021-06-22 11:40:37 PDT
Created attachment 431982 [details]
Patch

Uses new format for internals.installImageOverlay.
Comment 23 Andres Gonzalez 2021-06-23 08:28:30 PDT
Created attachment 432045 [details]
Patch

Skip test on iOS 14.
Comment 24 EWS 2021-06-23 09:59:41 PDT
Committed r279171 (239068@main): <https://commits.webkit.org/239068@main>

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