-
Notifications
You must be signed in to change notification settings - Fork 6k
Allow macOS plugins to register as app delegates #44587
Allow macOS plugins to register as app delegates #44587
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
I forgot I still needed to add tests; marking as a draft for now. |
Adds `addApplicationDelegate:` to the macOS plugin registrar, following the corresponding iOS method, and wires it up to the existing app delegation forwarding that was recently added for use at the application level. (The actual delegate is non-trivially different between iOS and macOS, but that's not resolveable without a complex migration on the iOS side, so the APIs currently diverge after the level of the `addApplicationDelegate:` method itself.) This doesn't add any new methods to the delegation; those will be added in a follow-up PR. Most of flutter/flutter#41471
9865348
to
1edadc3
Compare
This is now tested and ready for review. |
shell/platform/darwin/common/framework/Source/FlutterBinaryMessengerRelay.mm
Show resolved
Hide resolved
* handlers in FlutterAppLifecycleDelegate to any registered delegates. | ||
*/ | ||
FLUTTER_DARWIN_EXPORT | ||
@protocol FlutterAppLifecycleProvider <NSObject> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change isn't strictly necessary, but it makes us match iOS, and it makes the engine code that uses these methods cleaner.
shell/platform/darwin/macos/framework/Headers/FlutterPluginRegistrarMacOS.h
Show resolved
Hide resolved
@@ -165,7 +170,7 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result; | |||
#pragma mark - | |||
|
|||
@implementation FlutterEngineTerminationHandler { | |||
FlutterEngine* _engine; | |||
__weak FlutterEngine* _engine; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes a retain cycle that will affect essentially all real-word, non-add-to-app cases (and was breaking my new test).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for spotting this.
|
||
- (void)removeApplicationLifecycleDelegate: | ||
(nonnull NSObject<FlutterAppLifecycleDelegate>*)delegate { | ||
auto i = std::find(_delegates.begin(), _delegates.end(), (__bridge void*)delegate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe delegateIndex
for the minor readability benefit given the type is auto
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto label is removed for flutter/engine/44587, due to - The status or check suite Linux mac_unopt has failed. Please fix the issues identified (or deflake) before re-applying this label. |
…132407) flutter/engine@622ded9...832e780 2023-08-11 [email protected] Allow macOS plugins to register as app delegates (flutter/engine#44587) 2023-08-11 [email protected] Roll Skia from 68ea92de8f29 to 7dd695d828cf (1 revision) (flutter/engine#44643) 2023-08-11 [email protected] Roll Dart SDK from 83f96a990792 to ade04f1beb2c (1 revision) (flutter/engine#44642) 2023-08-11 [email protected] Roll Skia from fa30af9c2b80 to 68ea92de8f29 (2 revisions) (flutter/engine#44641) 2023-08-11 [email protected] [Impeller] Added benchmark for advanced blend. (flutter/engine#44450) 2023-08-11 [email protected] [Embedder] Refactor how semantic updates are mapped (flutter/engine#44553) 2023-08-11 [email protected] Roll Skia from cfb9844091fa to fa30af9c2b80 (1 revision) (flutter/engine#44639) 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
Adds `addApplicationDelegate:` to the macOS plugin registrar, following the corresponding iOS method, and wires it up to the existing app delegation forwarding that was recently added for use at the application level. (The actual delegate is non-trivially different between iOS and macOS, but that's not resolveable without a complex migration on the iOS side, so the APIs currently diverge after the level of the `addApplicationDelegate:` method itself.) This doesn't add any new methods to the delegation; those will be added in a follow-up PR. Also fixes a retain cycle in the termination handler that prevented the new test from working. Most of flutter/flutter#41471 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
Adds
addApplicationDelegate:
to the macOS plugin registrar, following the corresponding iOS method, and wires it up to the existing app delegation forwarding that was recently added for use at the application level. (The actual delegate is non-trivially different between iOS and macOS, but that's not resolveable without a complex migration on the iOS side, so the APIs currently diverge after the level of theaddApplicationDelegate:
method itself.)This doesn't add any new methods to the delegation; those will be added in a follow-up PR.
Also fixes a retain cycle in the termination handler that prevented the new test from working.
Most of flutter/flutter#41471
Pre-launch Checklist
///
).