WebKit Bugzilla
Attachment 368490 Details for
Bug 197385
: [iOS] The UIProcess may get killed for trying to stay runnable in the background for more than 30 seconds
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-197385-20190429140316.patch (text/plain), 4.19 KB, created by
Chris Dumez
on 2019-04-29 14:03:16 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Chris Dumez
Created:
2019-04-29 14:03:16 PDT
Size:
4.19 KB
patch
obsolete
>Subversion Revision: 244735 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 00b570606c3997e50d17e73e5972ca4bb24b902e..d32e45e0f8b28e0296bc1def78e2ff9097b73cad 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,25 @@ >+2019-04-29 Chris Dumez <cdumez@apple.com> >+ >+ [iOS] The UIProcess may get killed for trying to stay runnable in the background for more than 30 seconds >+ https://bugs.webkit.org/show_bug.cgi?id=197385 >+ <rdar://problem/50001505> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ If the UIProcess holds a background assertion for itself for 30 seconds, the assertion's invalidation handler >+ will get called and it is our responsibility to release this assertion or the UIProcess will get killed by the >+ system. The logic in ProcessAssertion would normally do that but it would also happily try and re-take another >+ background process assertion shortly after the previous one expired (and before the UIProcess got suspended). >+ When doing so, the new background assertion would expire right away and we would get killed without its >+ invalidation handler getting called. >+ >+ To address the issue, the logic in ProcessAssertion will now prevent taking a new background assertion after >+ one expires and until the application becomes foreground again. >+ >+ * UIProcess/ios/ProcessAssertionIOS.mm: >+ (-[WKProcessAssertionBackgroundTaskManager init]): >+ (-[WKProcessAssertionBackgroundTaskManager _updateBackgroundTask]): >+ > 2019-04-29 Alex Christensen <achristensen@webkit.org> > > Build fix. >diff --git a/Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm b/Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm >index 0c9adf3f5c13929d160ef44ac09acf27242bcbdf..8aa2dcf04c346e032443d1f9a20334af2224fcac 100644 >--- a/Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm >+++ b/Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm >@@ -50,6 +50,7 @@ @implementation WKProcessAssertionBackgroundTaskManager > { > UIBackgroundTaskIdentifier _backgroundTask; > HashSet<ProcessAndUIAssertion*> _assertionsNeedingBackgroundTask; >+ BOOL _assertionHasExpiredInTheBackground; > } > > + (WKProcessAssertionBackgroundTaskManager *)shared >@@ -66,6 +67,11 @@ - (instancetype)init > > _backgroundTask = UIBackgroundTaskInvalid; > >+ [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillEnterForegroundNotification object:[UIApplication sharedApplication] queue:nil usingBlock:^(NSNotification *) { >+ _assertionHasExpiredInTheBackground = NO; >+ [self _updateBackgroundTask]; >+ }]; >+ > return self; > } > >@@ -98,6 +104,11 @@ - (void)_notifyAssertionsOfImminentSuspension > - (void)_updateBackgroundTask > { > if (!_assertionsNeedingBackgroundTask.isEmpty() && _backgroundTask == UIBackgroundTaskInvalid) { >+ if (_assertionHasExpiredInTheBackground) { >+ RELEASE_LOG_ERROR(ProcessSuspension, "%p - WKProcessAssertionBackgroundTaskManager: Ignored request to start a background task because we're still in the background and the previous task expired", self); >+ // Our invalidation handler would not get called if we tried to re-take a new background assertion at this point, and the UIProcess would get killed (rdar://problem/50001505). >+ return; >+ } > 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()); >@@ -109,6 +120,9 @@ - (void)_updateBackgroundTask > [self _notifyAssertionsOfImminentSuspension]; > }); > } >+ >+ // Remember that the assertion has expired in the background so we do not try to re-take it until the application becomes foreground again. >+ _assertionHasExpiredInTheBackground = YES; > [self _releaseBackgroundTask]; > }]; > } 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 197385
: 368490