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

[Embedder API] Add multi-view present callback #51267

Merged
merged 2 commits into from
Mar 14, 2024

Conversation

loic-sharma
Copy link
Member

@loic-sharma loic-sharma commented Mar 7, 2024

Adds FlutterCompositor.present_view_callback to the embedder API. This new present callback adds a view_id member to allow embedders know which view is being presented.

The embedder API does not allow embedders to create multiple views yet. This will be added in a future pull request.

Design doc: https://flutter.dev/go/multi-view-embedder-apis

Pull request that migrates the Windows embedder to this new embedder API: #51293

Part of flutter/flutter#144806
Part of flutter/flutter#142845

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.

@loic-sharma loic-sharma force-pushed the multi_view_present branch 3 times, most recently from df8109c to dfbe75d Compare March 7, 2024 23:50
@loic-sharma loic-sharma requested a review from dkwingsmt March 7, 2024 23:52
@loic-sharma loic-sharma marked this pull request as ready for review March 7, 2024 23:52
@loic-sharma loic-sharma marked this pull request as draft March 8, 2024 00:17
@flutter-dashboard
Copy link

This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again.

@loic-sharma loic-sharma marked this pull request as ready for review March 8, 2024 02:08
@@ -1022,7 +1090,8 @@ TEST_F(EmbedderTest, NoLayerCreatedForNoOverlayOnTopOfPlatformLayer) {
auto scene_image = context.GetNextSceneImage();

context.GetCompositor().SetNextPresentCallback(
[&](const FlutterLayer** layers, size_t layers_count) {
[&](FlutterViewId view_id, const FlutterLayer** layers,
size_t layers_count) {
ASSERT_EQ(layers_count, 2u);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add ASSERT_EQ(view_id, kImplicitViewId); to all tests like this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Although this value is only passed in by EmbedderConfigBuilder, so it shouldn't matter... but that makes the test even more weird. Why is this callback set in such a way, instead of using public API?

Copy link
Member Author

Choose a reason for hiding this comment

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

Should we add ASSERT_EQ(view_id, kImplicitViewId); to all tests like this?

For now, only EmbedderTest.CanRenderImplicitView and EmbedderTest.CanRenderImplicitViewUsingPresentLayersCallback care about the view_id.

The other EmbedderTests only care that the correct content was rendered, they don't care which view it was rendered to. I don't think verifying the view ID is necessary for these tests.

Once we allow multiple views, we will definitely want new tests that verify the view IDs are expected. I expect these to be new tests that are separate from the existing tests.

Why is this callback set in such a way, instead of using public API?

The tests are doing a bunch of setup magic so that they can render stuff using the different backends.

Copy link
Contributor

@dkwingsmt dkwingsmt left a comment

Choose a reason for hiding this comment

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

LGTM

@loic-sharma
Copy link
Member Author

@cbracken or @chinmaygarde Would you be able to review the changes in embedder.h from an ABI standpoint?

@cbracken
Copy link
Member

Taking a look!

@@ -1751,13 +1769,22 @@ typedef bool (*FlutterLayersPresentCallback)(const FlutterLayer** layers,
size_t layers_count,
void* user_data);

/// The callback invoked when the embedder should present
/// to a view.
Copy link
Member

Choose a reason for hiding this comment

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

nit: does this actually hit 80 columns?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice catch! I had wrapped this manually for the design doc but forgot to update it here - fixed!

Copy link
Member

@cbracken cbracken left a comment

Choose a reason for hiding this comment

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

LGTM stamp from a Japanese personal seal

Changes lgtm! Thanks for the clean error handling of no/both present callbacks.

@loic-sharma loic-sharma added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 13, 2024
@auto-submit auto-submit bot merged commit 599dbd7 into flutter:main Mar 14, 2024
26 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 14, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Mar 14, 2024
…145123)

flutter/engine@6710d10...599dbd7

2024-03-14 737941+loic-sharma@users.noreply.github.com [Embedder API] Add multi-view present callback (flutter/engine#51267)
2024-03-14 skia-flutter-autoroll@skia.org Roll Skia from a315e4572f4e to cac09f152d9b (10 revisions) (flutter/engine#51398)
2024-03-14 dkwingsmt@users.noreply.github.com Multi-view View Metrics (flutter/engine#46174)

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 bdero@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://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants