-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Include platformViewId in semantics tree for iOS #29304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| void describeSemanticsConfiguration (SemanticsConfiguration config) { | ||
| super.describeSemanticsConfiguration(config); | ||
| config.isSemanticBoundary = true; | ||
| config.platformViewId = _viewController.id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: you'll have to remove the whitespace at the and of these lines to make the analyzer happy on Cirrus.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| final SemanticsHandle handle = tester.ensureSemantics(); | ||
| final int currentViewId = platformViewsRegistry.getNextPlatformViewId(); | ||
| expect(currentViewId, greaterThanOrEqualTo(0)); | ||
| final FakeIosPlatformViewsController viewsController = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: no need to linebreak here, it makes the code harder to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| // is not yet in the tree. | ||
| await tester.pump(); | ||
|
|
||
| final SemanticsNode semantics = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: no line break.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
amirh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM modulo nit
| UiKitViewController get viewController => _viewController; | ||
| UiKitViewController _viewController; | ||
| set viewController(UiKitViewController viewController) { | ||
| final bool needsSemantics = _viewController.id != viewController.id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: needsSmeanticsUpdate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| !(event is PointerDownEvent) && !(event is PointerUpEvent); | ||
| } | ||
|
|
||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: please re-add the trailing newline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems format analyzer fails if we added a trailing newline?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and below: can you clarify what you mean here? (Which other semantic configurations?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| }); | ||
| }); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: re-add the trailing newline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| UiKitViewController get viewController => _viewController; | ||
| UiKitViewController _viewController; | ||
| set viewController(UiKitViewController viewController) { | ||
| final bool needsSemanticsUpdate = _viewController.id != viewController.id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| /// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
goderbauer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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?