Skip to content

Conversation

@cyanglaz
Copy link
Contributor

@cyanglaz cyanglaz commented Mar 13, 2019

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.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes tests for all changed/updated/fixed behaviors (See Test Coverage).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require Flutter developers to manually update their apps to accommodate your change?

void describeSemanticsConfiguration (SemanticsConfiguration config) {
super.describeSemanticsConfiguration(config);
config.isSemanticBoundary = true;
config.platformViewId = _viewController.id;
Copy link
Member

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?)

Copy link
Contributor Author

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) {
Copy link
Member

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.

Copy link
Contributor Author

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 =
Copy link
Member

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.

Copy link
Contributor Author

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 =
Copy link
Member

Choose a reason for hiding this comment

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

nit: no line break.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@goderbauer goderbauer added platform-ios iOS applications specifically framework flutter/packages/flutter repository. See also f: labels. a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) a: platform-views Embedding Android/iOS views in Flutter apps labels Mar 13, 2019
Copy link
Contributor

@amirh amirh left a 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;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: needsSmeanticsUpdate

Copy link
Contributor Author

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);
}

}
Copy link
Member

@cbracken cbracken Mar 15, 2019

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor Author

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?

Copy link
Member

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.
Copy link
Member

@cbracken cbracken Mar 15, 2019

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?)

Copy link
Contributor Author

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.

});
});
}
}
Copy link
Member

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.

Copy link
Contributor Author

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;
Copy link
Member

@cbracken cbracken Mar 15, 2019

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.

Copy link
Contributor Author

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],
Copy link
Member

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],
Copy link
Member

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.

@cyanglaz cyanglaz requested a review from cbracken March 15, 2019 18:14
@goderbauer
Copy link
Member

Looks like some debug prints (and commented out code) made it into this PR?

@cyanglaz
Copy link
Contributor Author

Looks like some debug prints (and commented out code) made it into this PR?

oops. Fixed it.

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

LGTM

cyanglaz pushed a commit to flutter/engine that referenced this pull request Mar 26, 2019
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
@cyanglaz cyanglaz merged commit 3b3f6c7 into flutter:master Mar 27, 2019
@cyanglaz cyanglaz deleted the ios_a11y_platformviews branch March 27, 2019 20:56
RBogie pushed a commit to RBogie/flutter-engine that referenced this pull request Apr 8, 2019
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
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) a: platform-views Embedding Android/iOS views in Flutter apps framework flutter/packages/flutter repository. See also f: labels. platform-ios iOS applications specifically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants