Skip to content

Commit

Permalink
Started setting our debug background task id to invalid after complet…
Browse files Browse the repository at this point in the history
…ion. (flutter#12999)
  • Loading branch information
gaaclarke authored Oct 8, 2019
1 parent 0d59c9e commit 9f650ed
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ - (instancetype)init {
[self addObserverFor:UIApplicationWillTerminateNotification
selector:@selector(handleWillTerminate:)];
_delegates = [[NSPointerArray weakObjectsPointerArray] retain];
_debugBackgroundTask = UIBackgroundTaskInvalid;
}
return self;
}
Expand Down Expand Up @@ -143,7 +144,10 @@ - (void)handleDidEnterBackground:(NSNotification*)notification {
_debugBackgroundTask = [application
beginBackgroundTaskWithName:@"Flutter debug task"
expirationHandler:^{
[application endBackgroundTask:_debugBackgroundTask];
if (_debugBackgroundTask != UIBackgroundTaskInvalid) {
[application endBackgroundTask:_debugBackgroundTask];
_debugBackgroundTask = UIBackgroundTaskInvalid;
}
FML_LOG(WARNING)
<< "\nThe OS has terminated the Flutter debug connection for being "
"inactive in the background for too long.\n\n"
Expand All @@ -164,7 +168,10 @@ - (void)handleDidEnterBackground:(NSNotification*)notification {
- (void)handleWillEnterForeground:(NSNotification*)notification {
UIApplication* application = [UIApplication sharedApplication];
#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG
[application endBackgroundTask:_debugBackgroundTask];
if (_debugBackgroundTask != UIBackgroundTaskInvalid) {
[application endBackgroundTask:_debugBackgroundTask];
_debugBackgroundTask = UIBackgroundTaskInvalid;
}
#endif // FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG
for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!delegate) {
Expand Down

0 comments on commit 9f650ed

Please sign in to comment.