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

[Darwin] Move FlutterBinaryMessengerRelay to common#44395

Merged
cbracken merged 1 commit into
flutter-team-archive:mainfrom
cbracken:macos-reference-cycle
Aug 4, 2023
Merged

[Darwin] Move FlutterBinaryMessengerRelay to common#44395
cbracken merged 1 commit into
flutter-team-archive:mainfrom
cbracken:macos-reference-cycle

Conversation

@cbracken

@cbracken cbracken commented Aug 4, 2023

Copy link
Copy Markdown
Contributor

Migrates FlutterBinaryMessengerRelay to
//flutter/shell/platform/darwin/common so that it can be used in a followup patch on macOS, to fix a memory leak due to a retain cycle.

Migrates the unit tests to be compatible with gtest, which is used by the darwin/common unit tests.

Issue: flutter/flutter#116445

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.

@cbracken

cbracken commented Aug 4, 2023

Copy link
Copy Markdown
Contributor Author

This is currently stacked on top of #44396. The second commit is what will be applied in this patch.

That patch is landed and this is now rebased to tip of tree.

@cbracken cbracken requested a review from gaaclarke August 4, 2023 18:09
Comment thread shell/platform/darwin/common/framework/Source/FlutterBinaryMessengerRelayTest.mm Outdated
Comment thread shell/platform/darwin/common/framework/Source/FlutterBinaryMessengerRelayTest.mm Outdated
@cbracken cbracken added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 4, 2023
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Aug 4, 2023
@auto-submit

auto-submit Bot commented Aug 4, 2023

Copy link
Copy Markdown
Contributor

auto label is removed for flutter/engine/44395, due to - The status or check suite Linux mac_unopt has failed. Please fix the issues identified (or deflake) before re-applying this label.

Migrates FlutterBinaryMessengerRelay to
//flutter/shell/platform/darwin/common so that it can be used in a
followup patch on macOS, to fix a memory leak due to a retain cycle.

Migrates the unit tests to be compatible with gtest, which is used by
the darwin/common unit tests.

Issue: flutter/flutter#116445
@cbracken cbracken merged commit ad109d3 into flutter-team-archive:main Aug 4, 2023
@cbracken cbracken deleted the macos-reference-cycle branch August 4, 2023 22:24
fluttermirroringbot pushed a commit to flutter/flutter that referenced this pull request Aug 5, 2023
flutter-team-archive/engine@a0d650e...138a1ea

2023-08-04 skia-flutter-autoroll@skia.org Roll Skia from 7cf7e2da3557 to b2a0382bb587 (1 revision) (flutter-team-archive/engine#44407)
2023-08-04 chris@bracken.jp [Darwin] Move FlutterBinaryMessengerRelay to common (flutter-team-archive/engine#44395)

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 jacksongardner@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
cbracken added a commit that referenced this pull request Aug 8, 2023
Previously, FlutterEngine.binaryMessenger returned the FlutterEngine
instance itself, which meant that channels/plugins could hold a strong
reference to the engine and thus cause a retain cycle, preventing the
engine from being deallocated.

We introduce FlutterBinaryMessengerRelay, which implements the
FlutterBinaryMessenger protocol, by delegating back to the engine, to
which it holds a weak reference, thus avoiding the retain cycle.

This also changes the FlutterBinaryMessengerRelay.parent property from
an assign property to a weak property since that code is compiled with
ARC enabled as of #44395.

This patch also rearranges the headers to comply with our style guide:
related headers for this file, C headers, C++ headers, other Flutter
headers, in that order.

Fixes: flutter/flutter#116445
gaaclarke pushed a commit to gaaclarke/engine that referenced this pull request Aug 30, 2023
…hive#44395)

Migrates FlutterBinaryMessengerRelay to
//flutter/shell/platform/darwin/common so that it can be used in a
followup patch on macOS, to fix a memory leak due to a retain cycle.

Migrates the unit tests to be compatible with gtest, which is used by
the darwin/common unit tests.

Issue: flutter/flutter#116445


## 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 `///`).
- [X] 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
gaaclarke pushed a commit to gaaclarke/engine that referenced this pull request Aug 30, 2023
…#44471)

Previously, FlutterEngine.binaryMessenger returned the FlutterEngine
instance itself, which meant that channels/plugins could hold a strong
reference to the engine and thus cause a retain cycle, preventing the
engine from being deallocated.

We introduce FlutterBinaryMessengerRelay, which implements the
FlutterBinaryMessenger protocol, by delegating back to the engine, to
which it holds a weak reference, thus avoiding the retain cycle.

This also changes the FlutterBinaryMessengerRelay.parent property from
an assign property to a weak property since that code is compiled with
ARC enabled as of flutter-team-archive#44395.

This patch also rearranges the headers to comply with our style guide:
related headers for this file, C headers, C++ headers, other Flutter
headers, in that order.

Fixes: flutter/flutter#116445
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Development

Successfully merging this pull request may close these issues.

2 participants