Skip to content
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

Deprecate single semantics tree assumption from platform dispatcher #36675

Merged
merged 3 commits into from
Oct 10, 2022

Conversation

a-wallen
Copy link
Contributor

@a-wallen a-wallen commented Oct 8, 2022

In an effort to move from a single-rooted flutter view to multiple views in a flutter app, dart::ui should be able to dispatch semantics tree updates to selected views. This PR deprecates semantics APIs that assume one flutter view per app.

This patch will be succeeded by framework changes that migrate from the deprecated APIs. After, the deprecated APIs will be removed in a subsequent PR.

This is a partial fix to flutter/flutter#112221. that issue will be fully fixed when all 3 PRs are landed.

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 Hixie said 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.

@flutter-dashboard flutter-dashboard bot added embedder Related to the embedder API platform-web Code specifically for the web engine labels Oct 8, 2022
@a-wallen a-wallen changed the title Remove single semantics tree assumption from platform dispatcher Deprecate single semantics tree assumption from platform dispatcher Oct 8, 2022
In a multi-view world, the platform dispatcher can no longer provide apis
to update semantics since each view will host its own semantics tree.

Semantics updates must be passed to an individual flutter view. To update
Copy link
Member

Choose a reason for hiding this comment

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

nit: "flutter view" -> FlutterView since its an actual class

@@ -266,6 +266,19 @@ abstract class FlutterView {

@FfiNative<Void Function(Pointer<Void>)>('PlatformConfigurationNativeApi::Render')
external static void _render(Scene scene);

/// Change the retained semantics data about this platform dispatcher.
Copy link
Member

Choose a reason for hiding this comment

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

nit: replace "platform dispatcher" with flutter view?


/// Change the retained semantics data about this platform dispatcher.
///
/// If [semanticsEnabled] is true, the user has requested that this function
Copy link
Member

Choose a reason for hiding this comment

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

nit" semanticsEnabled is a property on the PlatformDispatcher, not the view, right? So, this should probable change to [PlatformDispatcher.semanticsEnabled].

/// Change the retained semantics data about this platform dispatcher.
///
/// If [semanticsEnabled] is true, the user has requested that this function
/// be called whenever the semantic content of this platform dispatcher
Copy link
Member

Choose a reason for hiding this comment

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

platform dispatcher -> flutter view (or maybe just view)

/// be called whenever the semantic content of this platform dispatcher
/// changes.
///
/// In either case, this function disposes the given update, which means the
Copy link
Member

Choose a reason for hiding this comment

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

nit: Maybe remove "in either case" as its just empty prose?

Comment on lines 746 to 753
@override
@Deprecated('''
A singleton flutter window no longer manages semantics trees. In a multi-view
world, each flutter view must manage its own semantics tree.

Call updateSemantics() from FlutterView instead.
''')
void updateSemantics(SemanticsUpdate update) => platformDispatcher.updateSemantics(update);
Copy link
Member

Choose a reason for hiding this comment

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

"SingletonFlutterWindow" extends FlutterView, so updateSemantics continues to be available. Instead of deprecating it, I think you just want to remove this override altogether, so it uses FlutterView.updateSemantics from the base class instead of forwarding to the platform dispatcher.

@@ -758,6 +758,14 @@ class PlatformDispatcher {
///
/// In either case, this function disposes the given update, which means the
/// semantics update cannot be used further.
@Deprecated('''
In a multi-view world, the platform dispatcher can no longer provide apis
Copy link
Member

Choose a reason for hiding this comment

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

nit: indent these lines by two so they are indented more than the @Deprecated line.

Copy link
Member

Choose a reason for hiding this comment

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

(here and for all other @Deprecarted instances below as well.)

Comment on lines 134 to 141
@override
@Deprecated('''
A singleton flutter window no longer manages semantics trees. In a multi-view
world, each flutter view must manage its own semantics tree.

Call updateSemantics() from FlutterView instead.
''')
void updateSemantics(SemanticsUpdate update) => platformDispatcher.updateSemantics(update);
Copy link
Member

Choose a reason for hiding this comment

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

same as for the other SingletonFlutterWindow, just remove this orverride.

Comment on lines 144 to 146
for (final FlutterView view in dispatcher.views) {
view.updateSemantics(semanticsUpdate);
}
Copy link
Member

Choose a reason for hiding this comment

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

In the other tests you online dispatched it to the first view, here its going to all views? Why this difference?

FWIW, choosing the first one everywhere is probably good enough.

@a-wallen a-wallen force-pushed the refactor_update_semantics branch 3 times, most recently from 3e93250 to 88c65fa Compare October 10, 2022 16:48
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

@@ -83,6 +83,14 @@ abstract class PlatformDispatcher {
VoidCallback? get onAccessibilityFeaturesChanged;
set onAccessibilityFeaturesChanged(VoidCallback? callback);

@Deprecated('''
In a multi-view world, the platform dispatcher can no longer provide apis
Copy link
Member

Choose a reason for hiding this comment

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

nit: indent by two more

@@ -698,6 +698,14 @@ class EnginePlatformDispatcher extends ui.PlatformDispatcher {
/// In either case, this function disposes the given update, which means the
/// semantics update cannot be used further.
@override
@Deprecated('''
In a multi-view world, the platform dispatcher can no longer provide apis
Copy link
Member

Choose a reason for hiding this comment

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

nit: indentation

@a-wallen a-wallen marked this pull request as ready for review October 10, 2022 17:32
@a-wallen a-wallen added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 10, 2022
@auto-submit auto-submit bot merged commit 7e03ebc into flutter:main Oct 10, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 10, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 10, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 10, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 10, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 10, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App embedder Related to the embedder API platform-web Code specifically for the web engine
Projects
None yet
2 participants