Include platformViewId in semantics tree for iOS#29304
Include platformViewId in semantics tree for iOS#29304cyanglaz merged 17 commits intoflutter:masterfrom
Conversation
| void describeSemanticsConfiguration (SemanticsConfiguration config) { | ||
| super.describeSemanticsConfiguration(config); | ||
| config.isSemanticBoundary = true; | ||
| config.platformViewId = _viewController.id; |
There was a problem hiding this comment.
For android, we only add the platform id to the tree if the platform view has actually been created and is ready to go (which may be a few frames after the PlatformView widget has been created). I would assume we want a similar behavior on iOS? (unless on iOS view and widget creation happen in the same frame?)
There was a problem hiding this comment.
I think in iOS, the view controller is only initialized after the view is created. https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/services/platform_views.dart#L133 So it should be safe to assign the platformViewId to _viewController.id directly assuming the view has been successfully created. @amirh could you confirm?
| } | ||
|
|
||
| @override | ||
| void describeSemanticsConfiguration (SemanticsConfiguration config) { |
There was a problem hiding this comment.
nit: you'll have to remove the whitespace at the and of these lines to make the analyzer happy on Cirrus.
| final SemanticsHandle handle = tester.ensureSemantics(); | ||
| final int currentViewId = platformViewsRegistry.getNextPlatformViewId(); | ||
| expect(currentViewId, greaterThanOrEqualTo(0)); | ||
| final FakeIosPlatformViewsController viewsController = |
There was a problem hiding this comment.
nit: no need to linebreak here, it makes the code harder to read.
| // is not yet in the tree. | ||
| await tester.pump(); | ||
|
|
||
| final SemanticsNode semantics = |
| UiKitViewController get viewController => _viewController; | ||
| UiKitViewController _viewController; | ||
| set viewController(UiKitViewController viewController) { | ||
| final bool needsSemantics = _viewController.id != viewController.id; |
| !(event is PointerDownEvent) && !(event is PointerUpEvent); | ||
| } | ||
|
|
||
| } No newline at end of file |
There was a problem hiding this comment.
Seems format analyzer fails if we added a trailing newline?
There was a problem hiding this comment.
@cbracken I believe this was removing an extra blank line at the end of the file, which shouldn't be there. The trailing newline is still there.
| /// If this value is non-null, the SemanticsNode must not have any children | ||
| /// as those would be replaced by the semantics nodes of the referenced | ||
| /// platform view. | ||
| /// platform view, and other semantic configurations are ignored. |
There was a problem hiding this comment.
Here and below: can you clarify what you mean here? (Which other semantic configurations?)
There was a problem hiding this comment.
I have updated the comments to include the things are ignored. Please let me know if you think we can do it a different way.
| }); | ||
| }); | ||
| } | ||
| } No newline at end of file |
There was a problem hiding this comment.
nit: re-add the trailing newline.
| UiKitViewController get viewController => _viewController; | ||
| UiKitViewController _viewController; | ||
| set viewController(UiKitViewController viewController) { | ||
| final bool needsSemanticsUpdate = _viewController.id != viewController.id; |
There was a problem hiding this comment.
Move this below the assert to avoid the potential for a null-pointer exception. Granted either way you get an exception, just the other way is clearer for someone hitting it.
| /// platform view, and other semantic configurations are ignored. The ignored | ||
| /// configurations include: [flags], [actions], [label], [value], [increasedValue], | ||
| /// [decreasedValue], [hint], [textDirection], [textSelection], [scrollChildCount], | ||
| /// [scrollIndex], [scrollPosition], [scrollExtentMax], [scrollExtentMin], [transform], |
There was a problem hiding this comment.
Ignoring transform is odd. Is that actually true? What if the PlatformView is scaled to a smaller/larger size?
| /// platform view. | ||
| /// | ||
| /// platform view, and other semantic configurations are ignored. The ignored | ||
| /// configurations include: [flags], [actions], [label], [value], [increasedValue], |
There was a problem hiding this comment.
This explicit list seems hard to maintain. When we add a new property nobody will remember to add it here.
|
Looks like some debug prints (and commented out code) made it into this PR? |
oops. Fixed it. |
Follow up the framework change in flutter/flutter#29304. Inject the accessibility element tree in the semantic node if the node is for platform views. flutter/flutter#29302
Follow up the framework change in flutter/flutter#29304. Inject the accessibility element tree in the semantic node if the node is for platform views. flutter/flutter#29302
Description
Include the platformViewId of PlatformViews in the semantics tree. The accessibility bridge in the engine can use this id to steal the semantics nodes from the actual platform view and stick them into Flutter's semantics tree.
This PR is the iOS counter part of #28953. It reverts the change in 5b5d6e8 and 03fd797.
Related Issues
#29302
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Does your PR require Flutter developers to manually update their apps to accommodate your change?