WebKit Bugzilla
Attachment 371284 Details for
Bug 198380
: [iOS] UIProcess' background task expiration handler may get called after the app is foreground again
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-198380-20190604083047.patch (text/plain), 3.41 KB, created by
Chris Dumez
on 2019-06-04 08:30:48 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Chris Dumez
Created:
2019-06-04 08:30:48 PDT
Size:
3.41 KB
patch
obsolete
>Subversion Revision: 246053 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index ce82571b79aec000b4b25f3f8468b2f98d3a12b6..76d15cc4291b5ca49c3316c4fe0b9fced21d174f 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,23 @@ >+2019-06-04 Chris Dumez <cdumez@apple.com> >+ >+ [iOS] UIProcess' background task expiration handler may get called after the app is foreground again >+ https://bugs.webkit.org/show_bug.cgi?id=198380 >+ <rdar://problem/49762471> >+ >+ Reviewed by Geoff Garen. >+ >+ UIProcess' background task expiration handler may get called after the app is foreground again. When >+ this happens, we already have a foreground assertion on behalf of the WebContent process, and the view >+ is visible. We would send the WillSuspendImminently IPC to the WebContent process, which would freeze >+ its layers, even though it is visible on screen. >+ >+ To address the issue, we now check if the app is visible in the expiration handler. If it is visible, >+ we do not notify clients of imminent suspension. Instead, we end the background task right away and >+ call _updateBackgroundTask asynchronously to start a new background task if necessary. >+ >+ * UIProcess/ios/ProcessAssertionIOS.mm: >+ (-[WKProcessAssertionBackgroundTaskManager _updateBackgroundTask]): >+ > 2019-06-03 Chris Dumez <cdumez@apple.com> > > [iOS] Do not prevent app suspension for more than 20 seconds after getting backgrounded >diff --git a/Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm b/Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm >index f852b22ac878eb02f93a01895f1788efc2bf093f..f5d2f6446d09f360c4128483ebbe4339e42e302e 100644 >--- a/Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm >+++ b/Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm >@@ -197,6 +197,7 @@ - (void)_cancelReleaseTask > - (void)_backgroundTaskExpired > { > RELEASE_LOG_ERROR(ProcessSuspension, "%p - WKProcessAssertionBackgroundTaskManager - _backgroundTaskExpired", self); >+ ASSERT(_applicationIsBackgrounded); > [self _cancelTimeoutTask]; > > // Tell our child processes they will suspend imminently. >@@ -222,6 +223,17 @@ - (void)_updateBackgroundTask > RELEASE_LOG(ProcessSuspension, "%p - WKProcessAssertionBackgroundTaskManager - beginBackgroundTaskWithName", self); > _backgroundTask = [[UIApplication sharedApplication] beginBackgroundTaskWithName:@"com.apple.WebKit.ProcessAssertion" expirationHandler:^{ > RELEASE_LOG_ERROR(ProcessSuspension, "Background task expired while holding WebKit ProcessAssertion (isMainThread? %d, _applicationIsBackgrounded? %d).", RunLoop::isMain(), _applicationIsBackgrounded); >+ if (!_applicationIsBackgrounded) { >+ // We've received the invalidation warning after the app has become foreground again. In this case, we should not >+ // warn clients of imminent suspension. To be safe (avoid potential killing), we end the task right away and call >+ // _updateBackgroundTask asynchronously to start a new task if necessary. >+ [self _releaseBackgroundTask]; >+ dispatch_async(dispatch_get_main_queue(), ^{ >+ [self _updateBackgroundTask]; >+ }); >+ return; >+ } >+ > [self _backgroundTaskExpired]; > }]; > } else if (_assertionsNeedingBackgroundTask.isEmpty())
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198380
:
370951
|
371163
| 371284