Title: [245899] trunk/Source/WebKit
- Revision
- 245899
- Author
- [email protected]
- Date
- 2019-05-30 12:34:19 -0700 (Thu, 30 May 2019)
Log Message
[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 Geoffrey 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]):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (245898 => 245899)
--- trunk/Source/WebKit/ChangeLog 2019-05-30 19:02:40 UTC (rev 245898)
+++ trunk/Source/WebKit/ChangeLog 2019-05-30 19:34:19 UTC (rev 245899)
@@ -1,5 +1,25 @@
2019-05-30 Chris Dumez <[email protected]>
+ [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 Geoffrey 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-05-30 Chris Dumez <[email protected]>
+
[iOS] Third-party extensions using WKWebView are unable to render anything
https://bugs.webkit.org/show_bug.cgi?id=198359
<rdar://problem/51105015>
Modified: trunk/Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm (245898 => 245899)
--- trunk/Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm 2019-05-30 19:02:40 UTC (rev 245898)
+++ trunk/Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm 2019-05-30 19:34:19 UTC (rev 245899)
@@ -150,7 +150,17 @@
}
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).", RunLoop::isMain());
+ 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 _cancelPendingReleaseTask];
+ [self _releaseBackgroundTask];
+ dispatch_async(dispatch_get_main_queue(), ^{
+ [self _updateBackgroundTask];
+ });
+ return;
+ }
// The expiration handler gets called on a non-main thread when the underlying assertion could not be taken (rdar://problem/27278419).
if (RunLoop::isMain())
[self _notifyAssertionsOfImminentSuspension];
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes