Keep rendering to screen in iOS inactive state (flutter/engine#25196)

Co-authored-by: Aaron Clarke <gaaclarke>
This commit is contained in:
Pieter van Loon
2021-03-30 01:45:34 +02:00
committed by GitHub
parent bc034502d7
commit d6e0e468e3
2 changed files with 10 additions and 17 deletions

View File

@@ -154,21 +154,16 @@ static constexpr int kNumProfilerSamplesPerSec = 5;
name:UIApplicationDidReceiveMemoryWarningNotification
object:nil];
[center addObserver:self
selector:@selector(applicationWillEnterForeground:)
name:UIApplicationWillEnterForegroundNotification
object:nil];
[center addObserver:self
selector:@selector(applicationDidEnterBackground:)
name:UIApplicationDidEnterBackgroundNotification
object:nil];
[center addObserver:self
selector:@selector(applicationBecameActive:)
name:UIApplicationDidBecomeActiveNotification
object:nil];
[center addObserver:self
selector:@selector(applicationWillResignActive:)
name:UIApplicationWillResignActiveNotification
object:nil];
[center addObserver:self
selector:@selector(onLocaleUpdated:)
name:NSCurrentLocaleDidChangeNotification
@@ -610,7 +605,8 @@ static void SetEntryPoint(flutter::Settings* settings, NSString* entrypoint, NSS
_threadHost->io_thread->GetTaskRunner() // io
);
_isGpuDisabled = [UIApplication sharedApplication].applicationState != UIApplicationStateActive;
_isGpuDisabled =
[UIApplication sharedApplication].applicationState == UIApplicationStateBackground;
// Create the shell. This is a blocking operation.
std::unique_ptr<flutter::Shell> shell = flutter::Shell::Create(
/*platform_data=*/std::move(platformData),
@@ -886,15 +882,12 @@ static void SetEntryPoint(flutter::Settings* settings, NSString* entrypoint, NSS
#pragma mark - Notifications
- (void)applicationBecameActive:(NSNotification*)notification {
- (void)applicationWillEnterForeground:(NSNotification*)notification {
[self setIsGpuDisabled:NO];
}
- (void)applicationWillResignActive:(NSNotification*)notification {
[self setIsGpuDisabled:YES];
}
- (void)applicationDidEnterBackground:(NSNotification*)notification {
[self setIsGpuDisabled:YES];
[self notifyLowMemory];
}

View File

@@ -743,12 +743,12 @@ static void sendFakeTouchEvent(FlutterEngine* engine,
- (void)applicationWillResignActive:(NSNotification*)notification {
TRACE_EVENT0("flutter", "applicationWillResignActive");
[self surfaceUpdated:NO];
[self goToApplicationLifecycle:@"AppLifecycleState.inactive"];
}
- (void)applicationDidEnterBackground:(NSNotification*)notification {
TRACE_EVENT0("flutter", "applicationDidEnterBackground");
[self surfaceUpdated:NO];
[self goToApplicationLifecycle:@"AppLifecycleState.paused"];
}