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
merged 1 commit into from
Aug 4, 2023

Conversation

cbracken
Copy link
Member

@cbracken cbracken commented Aug 4, 2023

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

cbracken commented Aug 4, 2023

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
@cbracken cbracken force-pushed the macos-reference-cycle branch 4 times, most recently from 0906a1d to c3482ce Compare August 4, 2023 20:06
@cbracken cbracken force-pushed the macos-reference-cycle branch 2 times, most recently from 172f755 to 8b06b1b Compare August 4, 2023 20:28
@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
Copy link
Contributor

auto-submit bot commented Aug 4, 2023

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 force-pushed the macos-reference-cycle branch from 8b06b1b to 4eb5c59 Compare August 4, 2023 20:55
@cbracken cbracken merged commit ad109d3 into flutter:main Aug 4, 2023
@cbracken cbracken deleted the macos-reference-cycle branch August 4, 2023 22:24
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 4, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 5, 2023
fluttermirroringbot pushed a commit to flutter/flutter that referenced this pull request Aug 5, 2023
…131972)

flutter/engine@a0d650e...138a1ea

2023-08-04 [email protected] Roll Skia from 7cf7e2da3557 to b2a0382bb587 (1 revision) (flutter/engine#44407)
2023-08-04 [email protected] [Darwin] Move FlutterBinaryMessengerRelay to common (flutter/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 [email protected],[email protected],[email protected] 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 to cbracken/flutter_engine that referenced this pull request Aug 7, 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 flutter#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.

Issue: flutter/flutter#116445
cbracken added a commit to cbracken/flutter_engine that referenced this pull request Aug 7, 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 flutter#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.

Issue: flutter/flutter#116445
cbracken added a commit to cbracken/flutter_engine that referenced this pull request Aug 7, 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 flutter#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.

Issue: flutter/flutter#116445
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
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
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#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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants