-
Notifications
You must be signed in to change notification settings - Fork 6k
[iOS] Add darwin_extension_safe flag and use UIScene api when building for extensions #43449
Conversation
4b53097 to
8e0369f
Compare
| ] | ||
| }, | ||
| { | ||
| "archives": [ |
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.
Since intel machines are limited and the test suite are the same, only add Apple silicon machine for the ci tests.
|
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. |
| nibName:nil | ||
| bundle:nil]; | ||
| FlutterViewController* engineViewController = | ||
| [[[FlutterViewController alloc] initWithEngine:engine nibName:nil bundle:nil] autorelease]; |
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.
The view controller is leaked, causing the newly added notification tests in other testing files to fail.
| return self; | ||
| } | ||
|
|
||
| - (void)setupSceneLifecycleNotifications:(NSNotificationCenter*)center API_AVAILABLE(ios(13.0)) { |
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.
Nit: setUp... (since "set up" is the verb, while "setup" is the noun).
| } | ||
|
|
||
| return self; | ||
| - (void)setupApplicationLifecycleNotifications:(NSNotificationCenter*)center { |
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.
Same.
|
|
||
| #if APPLICATION_EXTENSION_API_ONLY | ||
| if (@available(iOS 13.0, *)) { | ||
| [self setupSceneLifecycleNotifications:center]; |
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.
Longer term can we unify these code paths (i.e., remove this ifdef), or are there important differences in the notifications?
If the former, a TODO explaining that might be useful.
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.
There aren't any difference for single scene applications. When/if Flutter supports multi-scene, we will need both of them.
|
|
||
| @end | ||
|
|
||
| @interface FlutterEngine (Tests) |
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.
Is redeclaring private methods in test files, rather than using test-specific headers, the standard practice for the iOS engine code?
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.
I don't see a standard. Both methods are used in iOS engine code. However, I did see that FlutterEngineTest uses a test header, so I will move these methods to the test header.
| #if APPLICATION_EXTENSION_API_ONLY | ||
| OCMVerify([mockEngine sceneDidEnterBackground:[OCMArg any]]); | ||
| #else | ||
| OCMVerify([mockEngine applicationDidEnterBackground:[OCMArg any]]); |
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.
Isn't the important thing to verify that the correct state (like GPU status) is updated, not the specific private method that is called? This test would both break for minor internal refactoring, and not break if someone removed critical code from these methods.
| [engineViewController windowSceneIfViewLoaded].keyWindow.rootViewController; | ||
| } else { | ||
| FML_LOG(WARNING) | ||
| << "rootViewController is not available in application extension under iOS 15.0."; |
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.
s/under/prior to/
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.
Although... is this actionable (per https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#only-log-actionable-messages-to-the-console)? It's not clear to me what I would do with this message as a developer if I got it.
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.
Since it is breaking the pop flow, I imagined that the developer would either stop supporting iOS 15. Or redesign the UI for iOS 15 or lower.
I think this message is necessary to let the developer know why the pop button doesn't work. It would be hard to figure out if we only introduced a silence no-op.
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.
We would probably need to update the documentation for this too. However, I think the warning message is more visible and this one won't be too spammy.
| object:nil]; | ||
| } | ||
|
|
||
| - (void)setupSceneLifecycleNotifications:(NSNotificationCenter*)center API_AVAILABLE(ios(13.0)) { |
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.
setUp
| object:nil]; | ||
| } | ||
|
|
||
| - (void)setupApplicationLifecycleNotifications:(NSNotificationCenter*)center { |
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.
setUp
| [self setNeedsUpdateOfSupportedInterfaceOrientations]; | ||
| [self requestGeometryUpdateForWindowScene:windowScene]; | ||
| } | ||
| #endif |
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.
Could we unify this code to have just populating a list of scenes into an ifdef, and then have the actual call to update the geometry be outside the ifdef, so we minimize code path branching.
|
The test failures are unrelated and should be fixed by a rebase. |
8d697bc to
2c7c8f4
Compare
stuartmorgan-g
left a comment
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.
Sorry for the delay getting back to this; LGTM with one bug fix.
| } | ||
| NSSet<UIScene*>* scenes = | ||
| #if APPLICATION_EXTENSION_API_ONLY | ||
| [NSSet setWithObject:self.windowSceneIfViewLoaded ? self.windowSceneIfViewLoaded : nil]; |
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.
It's not valid to insert nil into a collection; if nothing is available the set should be empty.
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.
Fixed to return empty NSSet
draft format draf format draf fix non extension build add extension safe builders generate extension safe output fix build config fix clang tidy complains add to tests fix tests remove test logs fox tests fix test fix memory leak in platform plugin test format review review bug fix format
…en building for extensions (flutter/engine#43449)
…en building for extensions (flutter/engine#43449)
…131706) flutter/engine@10a1f9c...9dae7b7 2023-08-01 [email protected] Made the licenses script output all problems (flutter/engine#44223) 2023-08-01 [email protected] Roll Skia from a7a3646c2c8a to d53f7b880651 (6 revisions) (flutter/engine#44226) 2023-08-01 [email protected] Roll Clang from ebd0b8a0472b to 07c592048780 (flutter/engine#44224) 2023-08-01 [email protected] [iOS] Add darwin_extension_safe flag and use UIScene api when building for extensions (flutter/engine#43449) 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
…lutter#131706) flutter/engine@10a1f9c...9dae7b7 2023-08-01 [email protected] Made the licenses script output all problems (flutter/engine#44223) 2023-08-01 [email protected] Roll Skia from a7a3646c2c8a to d53f7b880651 (6 revisions) (flutter/engine#44226) 2023-08-01 [email protected] Roll Clang from ebd0b8a0472b to 07c592048780 (flutter/engine#44224) 2023-08-01 [email protected] [iOS] Add darwin_extension_safe flag and use UIScene api when building for extensions (flutter/engine#43449) 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
…g for extensions (flutter#43449) iOS extensions forbids the usage of UIApplication.sharedApplication. This PR refactors the engine to use UISceneAPI when darwin_extension_safe flag is on. Using UISceneAPI can help avoid the usage of `UIApplication.sharedApplication` as much as possible. This PR also added a new `_extension_safe` variant for the engine build so all the logic with the `darwin_extension_safe` flag is on can be tested separately. This PR doesn't enable the engine to build for the extension even when darwin_extension_safe is true. part of flutter/flutter#124289 There are several issues related to UIApplication life cycle and I manually tested they still work with the scene API: [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
iOS extensions forbids the usage of UIApplication.sharedApplication. This PR refactors the engine to use UISceneAPI when darwin_extension_safe flag is on. Using UISceneAPI can help avoid the usage of
UIApplication.sharedApplicationas much as possible.This PR also added a new
_extension_safevariant for the engine build so all the logic with thedarwin_extension_safeflag is on can be tested separately.This PR doesn't enable the engine to build for the extension even when darwin_extension_safe is true.
part of flutter/flutter#124289
There are several issues related to UIApplication life cycle and I manually tested they still work with the scene API:
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.