-
Notifications
You must be signed in to change notification settings - Fork 6k
Build iOS and macOS Obj-C with -fapplication-extension flag #40332
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,7 +44,10 @@ source_set("flutter_framework_source_arc") { | |
| cflags_objc = flutter_cflags_objc_arc | ||
| cflags_objcc = flutter_cflags_objcc_arc | ||
|
|
||
| defines = [ "FLUTTER_FRAMEWORK=1" ] | ||
| defines = [ | ||
| "FLUTTER_FRAMEWORK=1", | ||
| "APPLICATION_EXTENSION_API_ONLY=1", | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same, this would be set by a buildroot flag. |
||
| ] | ||
| allow_circular_includes_from = [ ":flutter_framework_source" ] | ||
| deps = [ | ||
| ":flutter_framework_source", | ||
|
|
@@ -153,7 +156,10 @@ source_set("flutter_framework_source") { | |
|
|
||
| sources += _flutter_framework_headers | ||
|
|
||
| defines = [ "FLUTTER_FRAMEWORK=1" ] | ||
| defines = [ | ||
| "FLUTTER_FRAMEWORK=1", | ||
| "APPLICATION_EXTENSION_API_ONLY=1", | ||
| ] | ||
|
|
||
| if (shell_enable_metal) { | ||
| sources += [ | ||
|
|
@@ -320,7 +326,10 @@ shared_library("create_flutter_framework_dylib") { | |
|
|
||
| output_name = "Flutter" | ||
|
|
||
| ldflags = [ "-Wl,-install_name,@rpath/Flutter.framework/Flutter" ] | ||
| ldflags = [ | ||
| "-Wl,-install_name,@rpath/Flutter.framework/Flutter", | ||
| "-fapplication-extension", | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same, behind a new flag, etc. |
||
| ] | ||
|
|
||
| public = _flutter_framework_headers | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -814,9 +814,14 @@ - (void)viewDidAppear:(BOOL)animated { | |
| if ([_engine.get() viewController] == self) { | ||
| [self onUserSettingsChanged:nil]; | ||
| [self onAccessibilityStatusChanged:nil]; | ||
|
|
||
| #if !APPLICATION_EXTENSION_API_ONLY | ||
| if (UIApplication.sharedApplication.applicationState == UIApplicationStateActive) { | ||
| #endif | ||
| [[_engine.get() lifecycleChannel] sendMessage:@"AppLifecycleState.resumed"]; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to end up sending this if the whole process hosting the extension itself was in the background, thus UIApplication.sharedApplication.applicationState != UIApplicationStateActive if we had access to the sharedApplication? If we sent in "resumed" without checking, might be end up in an engine state where we continue to issue GPU commands while in the background and crash?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like a race that I bet could happen in the app extension #23175 |
||
| #if !APPLICATION_EXTENSION_API_ONLY | ||
| } | ||
| #endif | ||
| } | ||
| [super viewDidAppear:animated]; | ||
| } | ||
|
|
@@ -1304,8 +1309,13 @@ - (void)viewDidLayoutSubviews { | |
| // There is no guarantee that UIKit will layout subviews when the application is active. Creating | ||
| // the surface when inactive will cause GPU accesses from the background. Only wait for the first | ||
| // frame to render when the application is actually active. | ||
| bool applicationIsActive = | ||
| BOOL applicationIsActive = | ||
|
|
||
| #if APPLICATION_EXTENSION_API_ONLY | ||
| YES; | ||
| #else | ||
| [UIApplication sharedApplication].applicationState == UIApplicationStateActive; | ||
| #endif | ||
|
|
||
| // This must run after updateViewportMetrics so that the surface creation tasks are queued after | ||
| // the viewport metrics update tasks. | ||
|
|
@@ -1804,6 +1814,7 @@ - (void)onOrientationPreferencesUpdated:(NSNotification*)notification { | |
| } | ||
|
|
||
| - (void)performOrientationUpdate:(UIInterfaceOrientationMask)new_preferences { | ||
| #if !APPLICATION_EXTENSION_API_ONLY | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might be able to fall back to changing |
||
| if (new_preferences != _orientationPreferences) { | ||
| _orientationPreferences = new_preferences; | ||
|
|
||
|
|
@@ -1850,6 +1861,7 @@ - (void)performOrientationUpdate:(UIInterfaceOrientationMask)new_preferences { | |
| } | ||
| } | ||
| } | ||
| #endif | ||
| } | ||
|
|
||
| - (void)onHideHomeIndicatorNotification:(NSNotification*)notification { | ||
|
|
@@ -1951,7 +1963,12 @@ - (void)onUserSettingsChanged:(NSNotification*)notification { | |
| } | ||
|
|
||
| - (CGFloat)textScaleFactor { | ||
| #if APPLICATION_EXTENSION_API_ONLY | ||
| UIContentSizeCategory category = | ||
| self.mainScreenIfViewLoaded.traitCollection.preferredContentSizeCategory; | ||
| #else | ||
| UIContentSizeCategory category = [UIApplication sharedApplication].preferredContentSizeCategory; | ||
| #endif | ||
| // The delta is computed by approximating Apple's typography guidelines: | ||
| // https://developer.apple.com/ios/human-interface-guidelines/visual-design/typography/ | ||
| // | ||
|
|
||
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 would be set by a buildroot flag so the engine can be built with or without app extension safety. I put it here for testing.