Skip to content

Commit 1a6eda5

Browse files
authored
Keep rendering to screen in iOS inactive state (flutter#25196)
Co-authored-by: Aaron Clarke <gaaclarke>
1 parent 39a2905 commit 1a6eda5

2 files changed

Lines changed: 9 additions & 16 deletions

File tree

‎shell/platform/darwin/ios/framework/Source/FlutterEngine.mm‎

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -155,18 +155,13 @@ - (instancetype)initWithName:(NSString*)labelPrefix
155155
object:nil];
156156

157157
[center addObserver:self
158-
selector:@selector(applicationDidEnterBackground:)
159-
name:UIApplicationDidEnterBackgroundNotification
160-
object:nil];
161-
162-
[center addObserver:self
163-
selector:@selector(applicationBecameActive:)
164-
name:UIApplicationDidBecomeActiveNotification
158+
selector:@selector(applicationWillEnterForeground:)
159+
name:UIApplicationWillEnterForegroundNotification
165160
object:nil];
166161

167162
[center addObserver:self
168-
selector:@selector(applicationWillResignActive:)
169-
name:UIApplicationWillResignActiveNotification
163+
selector:@selector(applicationDidEnterBackground:)
164+
name:UIApplicationDidEnterBackgroundNotification
170165
object:nil];
171166

172167
[center addObserver:self
@@ -610,7 +605,8 @@ - (BOOL)createShell:(NSString*)entrypoint
610605
_threadHost->io_thread->GetTaskRunner() // io
611606
);
612607

613-
_isGpuDisabled = [UIApplication sharedApplication].applicationState != UIApplicationStateActive;
608+
_isGpuDisabled =
609+
[UIApplication sharedApplication].applicationState == UIApplicationStateBackground;
614610
// Create the shell. This is a blocking operation.
615611
std::unique_ptr<flutter::Shell> shell = flutter::Shell::Create(
616612
/*platform_data=*/std::move(platformData),
@@ -886,15 +882,12 @@ - (NSObject*)valuePublishedByPlugin:(NSString*)pluginKey {
886882

887883
#pragma mark - Notifications
888884

889-
- (void)applicationBecameActive:(NSNotification*)notification {
885+
- (void)applicationWillEnterForeground:(NSNotification*)notification {
890886
[self setIsGpuDisabled:NO];
891887
}
892888

893-
- (void)applicationWillResignActive:(NSNotification*)notification {
894-
[self setIsGpuDisabled:YES];
895-
}
896-
897889
- (void)applicationDidEnterBackground:(NSNotification*)notification {
890+
[self setIsGpuDisabled:YES];
898891
[self notifyLowMemory];
899892
}
900893

‎shell/platform/darwin/ios/framework/Source/FlutterViewController.mm‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,12 +743,12 @@ - (void)applicationBecameActive:(NSNotification*)notification {
743743

744744
- (void)applicationWillResignActive:(NSNotification*)notification {
745745
TRACE_EVENT0("flutter", "applicationWillResignActive");
746-
[self surfaceUpdated:NO];
747746
[self goToApplicationLifecycle:@"AppLifecycleState.inactive"];
748747
}
749748

750749
- (void)applicationDidEnterBackground:(NSNotification*)notification {
751750
TRACE_EVENT0("flutter", "applicationDidEnterBackground");
751+
[self surfaceUpdated:NO];
752752
[self goToApplicationLifecycle:@"AppLifecycleState.paused"];
753753
}
754754

0 commit comments

Comments
 (0)