Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Add callback to Embedder API to respond to new channel listeners, and use for Windows lifecycle #44827

Merged
merged 39 commits into from
Aug 29, 2023

Conversation

yaakovschectman
Copy link
Contributor

Supplant the temporary solution #44238 with a more elegant solution with am embedder API callback. The windows engine provides a callback that enables graceful exit and app lifecycle when the platform and lifecycle channels are listened to, respectively.

flutter/flutter#131616

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.

@yaakovschectman yaakovschectman self-assigned this Aug 17, 2023
@github-actions github-actions bot removed the embedder Related to the embedder API label Aug 17, 2023
@yaakovschectman yaakovschectman marked this pull request as ready for review August 18, 2023 17:06
Copy link
Member

@loic-sharma loic-sharma left a comment

Choose a reason for hiding this comment

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

Looks great, excellent work! Please get an approval from @cbracken or @chinmaygarde on the changes in //flutter/shell/platform/embedder/embedder.h before merging.

const char* channel;
/// True if a listener has been set, false if one has been cleared.
bool listening;
} FlutterChannelUpdate;
Copy link
Member

Choose a reason for hiding this comment

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

Are we 100% certain that we'll never want to add more members to this struct? If not, add a size_t struct_size member as the first field in the struct and use safe dereference macros when reading from it.

Copy link
Member

Choose a reason for hiding this comment

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

Oh derp I completely forgot this 🤦. Yup let's add a struct_size to be safe

/// @param[in] listening Whether the listener has been set (true) or
/// cleared (false).
///
virtual void SendChannelUpdate(std::string name, bool listening) = 0;
Copy link
Member

@cbracken cbracken Aug 28, 2023

Choose a reason for hiding this comment

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

This signature doesn't appear to match the implementation. std::string vs const std::string& name. Based on @loic-sharma's comment, looks like maybe this is the correct signature but the one lower down static void SendChannelUpdate(const std::string& name, bool listening); should be corrected?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What non-matching implementation to this signature are you looking at? It is implemented in runtime_controller.cc:405, where the signatures match.

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.

Overall, really nice work! Just a few small nits!

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

@cbracken
Copy link
Member

Looks great -- the lint would prefer const ref for the strings, which seems fine to me. I don't think we're mutating them anywhere.

@yaakovschectman yaakovschectman merged commit 1feb930 into flutter:main Aug 29, 2023
@yaakovschectman yaakovschectman deleted the embedder_channel branch August 29, 2023 20:12
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 29, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Aug 29, 2023
…133604)

flutter/engine@01a1579...1feb930

2023-08-29 109111084+yaakovschectman@users.noreply.github.com Add callback to Embedder API to respond to new channel listeners, and use for Windows lifecycle (flutter/engine#44827)

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 aaclarke@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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
gaaclarke pushed a commit to gaaclarke/engine that referenced this pull request Aug 30, 2023
… use for Windows lifecycle (flutter#44827)

Supplant the temporary solution
flutter#44238 with a more elegant
solution with am embedder API callback. The windows engine provides a
callback that enables graceful exit and app lifecycle when the platform
and lifecycle channels are listened to, respectively.

flutter/flutter#131616

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide] and the [C++,
Objective-C, Java style guides].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] 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.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [ ] I signed the [CLA].
- [x] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat

---------

Co-authored-by: Chris Bracken <chris@bracken.jp>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects: desktop platform-web Code specifically for the web engine platform-windows
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants