Terminate debug background task on expiry (flutter/engine#8930)

When backgrounding an app in debug mode, we make a request for
additional background time for the app with a background task. This
prevents us from losing the devfs session used for hot reload. In the
case where the app is backgrounded beyond the additional time provided
by iOS, it's required that we end the background task or the app will
be terminated by the OS.

We previously ended the background task only on foregrounding, but
failed to do so on expiry of the task.
This commit is contained in:
stupidfive
2019-05-14 02:29:05 +08:00
committed by Chris Bracken
parent 3d8b9b1e9c
commit 50c82c816b

View File

@@ -94,6 +94,7 @@ static BOOL isPowerOfTwo(NSUInteger x) {
_debugBackgroundTask = [application
beginBackgroundTaskWithName:@"Flutter debug task"
expirationHandler:^{
[application endBackgroundTask:_debugBackgroundTask];
FML_LOG(WARNING)
<< "\nThe OS has terminated the Flutter debug connection for being "
"inactive in the background for too long.\n\n"