Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@cyanglaz
Copy link
Contributor

@cyanglaz cyanglaz commented Oct 2, 2023

The PlatformView does not have a semantics container when added to semantics tree, this PR gives it a semantics container to ensure accessibility traversal works.

This fixes flutter/flutter#135504, which is a regression of b8332e3

Before b8332e3, the traversal works because the PlatformView is added to the accessibilityElements of the FlutterPlatFormViewSemanticsContainer, which implicitly made the FlutterPlatFormViewSemanticsContainer as the PlatformVIew's AccessibilityContainer.

Now we use the PlatformVIew as the nativeAccessibility of the FlutterPlatFormViewSemanticsContainer, we need to expilicitly set the container.

This needs to be cherry-picked since the commit caused the regression was cherry-picked in b8332e3

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@end

@implementation FlutterScrollableSemanticsObject {
fml::scoped_nsobject<SemanticsObjectContainer> _container;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unrelated to the PR, but the variable is unused so I removed it

Comment on lines -887 to -889
- (NSArray*)accessibilityElements {
return @[ _platformView ];
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We implemented nativeAccessibility, this is not necessary.

const float kFloatCompareEpsilon = 0.001;

@interface FlutterTouchInterceptingView (Test)
- (id)accessibilityContainer;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make a _Test.h file instead of re-declaring methods directly in test files.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entire redeclaration block should be removed in favor of including the test header.


@protocol FlutterSemanticsProtocol <NSObject>
// Adding functionalities for any object to assign accessibilityContainer.
// For example, this allows the PlatformView be able to link back to the accessibility tree.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused by what this property is actually for. I see where it's set, but I don't see anything reading it except in tests. Am I missing some non-test behavior that's influenced by this?

Copy link
Contributor Author

@cyanglaz cyanglaz Oct 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is read in FlutterTouchInterceptingView: accessibilityContainer, it is a UIAccessibilty property that is read by the UIKit.

I initially added the method to the FlutterTouchInterceptingView so that FlutterTouchInterceptingView can access the container in its accessibiltiyContainer method.

Then I discovered that SemanticsObjectTests is ARC, so we couldn't not include FlutterTouchInterceptingView (which uses MRC features) in the header of SemanticsObjectTests, thus the protocl was added.

This does make the code more confusing. Maybe I should revert back to my initial implementation (no protocol, FlutterTouchInterceptingView has a setFlutterAccessiblityContainer method), then move the related tests to mrc.

format

review
@cyanglaz
Copy link
Contributor Author

cyanglaz commented Oct 2, 2023

@stuartmorgan I removed the protocol to reduce confusion, I also refactored the platform view related tests to a separate file + other review comments. PTAL

@cyanglaz cyanglaz force-pushed the a11y_regression_platformview branch from 073536f to 63a75a3 Compare October 3, 2023 16:21
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

..._Test.h seems to be the established convention in this directory.

const float kFloatCompareEpsilon = 0.001;

@interface FlutterTouchInterceptingView (Test)
- (id)accessibilityContainer;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entire redeclaration block should be removed in favor of including the test header.

// Get embedded view
- (UIView*)embeddedView;

// The FlutterTouchInterceptingView assigns `flutterAccessibilityContainer` as its
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instance methods don't need to say that they are about the class they are on; this can just say "Sets flutterAccessibilityContainer as this view's accessibilityContainer."

// Check if there's no more strong references to `platformView` after container and platformView
// are released.
[container release];
XCTAssertEqual(platformView.retainCount, 1u);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fragile to implementation details of the code using the platform view. It would help to at least wrap all the code between the declaration and here in an autorelease pool.

@cyanglaz
Copy link
Contributor Author

cyanglaz commented Oct 3, 2023

@stuartmorgan Updated, PTAL!

Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with one last nit.

// If the `FlutterPlatformViewsController` does not contain any `FlutterPlatformView` object or
// a `FlutterPlatformView` object associated with the view_id cannot be found, the method
// returns nil.
FlutterTouchInterceptingView* GetFlutterTouchInterceptingViewByID(int64_t);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I missed that this parameter doesn't have a name; it should be int64_t view_id.

@cyanglaz cyanglaz added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 4, 2023
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 4, 2023
@auto-submit
Copy link
Contributor

auto-submit bot commented Oct 4, 2023

auto label is removed for flutter/engine/46471, due to - The status or check suite Linux Web Framework tests has failed. Please fix the issues identified (or deflake) before re-applying this label.

@cyanglaz cyanglaz added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 4, 2023
@auto-submit auto-submit bot merged commit 250daad into flutter:main Oct 4, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 4, 2023
@cyanglaz cyanglaz deleted the a11y_regression_platformview branch October 4, 2023 23:29
fluttermirroringbot pushed a commit to flutter/flutter that referenced this pull request Oct 5, 2023
…136007)

flutter/engine@8e6dd23...8e3a05c

2023-10-04 chinmaygarde@google.com Update buildroot to 5d60bd2. (flutter/engine#46564)
2023-10-04 ychris@google.com [ios] Link PlatformView back to semantics tree (flutter/engine#46471)
2023-10-04 skia-flutter-autoroll@skia.org Roll Skia from d061d21eed0d to 073737b7f4ab (2 revisions) (flutter/engine#46563)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC chinmaygarde@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
cyanglaz pushed a commit to cyanglaz/engine that referenced this pull request Oct 10, 2023
The PlatformView does not have a semantics container when added to semantics tree, this PR gives it a semantics container to ensure accessibility traversal works.

This fixes flutter/flutter#135504, which is a regression of flutter@b8332e3

Before flutter@b8332e3, the traversal works because the PlatformView is added to the accessibilityElements of the FlutterPlatFormViewSemanticsContainer, which implicitly made the FlutterPlatFormViewSemanticsContainer as the PlatformVIew's AccessibilityContainer. 

Now we use the PlatformVIew as the nativeAccessibility of the  FlutterPlatFormViewSemanticsContainer, we need to expilicitly set the container. 

This needs to be cherry-picked since the commit caused the regression was cherry-picked in flutter@b8332e3

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
Mairramer pushed a commit to Mairramer/flutter that referenced this pull request Oct 10, 2023
…lutter#136007)

flutter/engine@8e6dd23...8e3a05c

2023-10-04 chinmaygarde@google.com Update buildroot to 5d60bd2. (flutter/engine#46564)
2023-10-04 ychris@google.com [ios] Link PlatformView back to semantics tree (flutter/engine#46471)
2023-10-04 skia-flutter-autoroll@skia.org Roll Skia from d061d21eed0d to 073737b7f4ab (2 revisions) (flutter/engine#46563)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC chinmaygarde@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
cyanglaz pushed a commit to cyanglaz/engine that referenced this pull request Oct 11, 2023
auto-submit bot pushed a commit that referenced this pull request Oct 11, 2023
Cherry pick 250daad

Cherry pick issue flutter/flutter#136266

Description:

The PlatformView does not have a semantics container when added to semantics tree, this PR gives it a semantics container to ensure accessibility traversal works.

This fixes flutter/flutter#135504, which is a regression of b8332e3

Before b8332e3, the traversal works because the PlatformView is added to the accessibilityElements of the FlutterPlatFormViewSemanticsContainer, which implicitly made the FlutterPlatFormViewSemanticsContainer as the PlatformVIew's AccessibilityContainer. 

Now we use the PlatformVIew as the nativeAccessibility of the  FlutterPlatFormViewSemanticsContainer, we need to expilicitly set the container. 

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
cyanglaz pushed a commit to cyanglaz/engine that referenced this pull request Oct 13, 2023
The PlatformView does not have a semantics container when added to semantics tree, this PR gives it a semantics container to ensure accessibility traversal works.

This fixes flutter/flutter#135504, which is a regression of flutter@b8332e3

Before flutter@b8332e3, the traversal works because the PlatformView is added to the accessibilityElements of the FlutterPlatFormViewSemanticsContainer, which implicitly made the FlutterPlatFormViewSemanticsContainer as the PlatformVIew's AccessibilityContainer.

Now we use the PlatformVIew as the nativeAccessibility of the  FlutterPlatFormViewSemanticsContainer, we need to expilicitly set the container.

This needs to be cherry-picked since the commit caused the regression was cherry-picked in flutter@b8332e3

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
auto-submit bot pushed a commit that referenced this pull request Oct 17, 2023
Cherry pick 250daad

Cherry pick issue flutter/flutter#136552

Description:

The PlatformView does not have a semantics container when added to semantics tree, this PR gives it a semantics container to ensure accessibility traversal works.

This fixes flutter/flutter#135504, which is a regression of b8332e3

Before b8332e3, the traversal works because the PlatformView is added to the accessibilityElements of the FlutterPlatFormViewSemanticsContainer, which implicitly made the FlutterPlatFormViewSemanticsContainer as the PlatformVIew's AccessibilityContainer. 

Now we use the PlatformVIew as the nativeAccessibility of the  FlutterPlatFormViewSemanticsContainer, we need to expilicitly set the container. 

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
harryterkelsen pushed a commit that referenced this pull request Oct 23, 2023
The PlatformView does not have a semantics container when added to semantics tree, this PR gives it a semantics container to ensure accessibility traversal works.

This fixes flutter/flutter#135504, which is a regression of b8332e3

Before b8332e3, the traversal works because the PlatformView is added to the accessibilityElements of the FlutterPlatFormViewSemanticsContainer, which implicitly made the FlutterPlatFormViewSemanticsContainer as the PlatformVIew's AccessibilityContainer. 

Now we use the PlatformVIew as the nativeAccessibility of the  FlutterPlatFormViewSemanticsContainer, we need to expilicitly set the container. 

This needs to be cherry-picked since the commit caused the regression was cherry-picked in b8332e3

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App platform-ios

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[iOS][a11y] VoiceOver on UIKitView seems to be broken

2 participants