Title: [251722] branches/safari-608-branch/Source/WebKit
- Revision
- 251722
- Author
- [email protected]
- Date
- 2019-10-29 12:51:11 -0700 (Tue, 29 Oct 2019)
Log Message
Cherry-pick r251304. rdar://problem/56579672
[iOS] "Unexpectedly Resumed" process assertion may cause us to get terminated
https://bugs.webkit.org/show_bug.cgi?id=203046
<rdar://problem/56179592>
Reviewed by Geoffrey Garen.
This patch implements the following to avoid getting terminated:
1. Schedule the task to release the assertion on a background thread instead of
the main thread so that we end up releasing the task even if the main thread
is somehow hung.
2. Add an invalidation handler to the process assertion which releases the assertion
upon expiration.
* UIProcess/Cocoa/WebProcessProxyCocoa.mm:
(WebKit::WebProcessProxy::processWasUnexpectedlyUnsuspended):
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::processDidResume):
* WebProcess/WebProcess.h:
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::processTaskStateDidChange):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@251304 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Modified Paths
Diff
Modified: branches/safari-608-branch/Source/WebKit/ChangeLog (251721 => 251722)
--- branches/safari-608-branch/Source/WebKit/ChangeLog 2019-10-29 19:51:08 UTC (rev 251721)
+++ branches/safari-608-branch/Source/WebKit/ChangeLog 2019-10-29 19:51:11 UTC (rev 251722)
@@ -1,3 +1,54 @@
+2019-10-24 Kocsen Chung <[email protected]>
+
+ Cherry-pick r251304. rdar://problem/56579672
+
+ [iOS] "Unexpectedly Resumed" process assertion may cause us to get terminated
+ https://bugs.webkit.org/show_bug.cgi?id=203046
+ <rdar://problem/56179592>
+
+ Reviewed by Geoffrey Garen.
+
+ This patch implements the following to avoid getting terminated:
+ 1. Schedule the task to release the assertion on a background thread instead of
+ the main thread so that we end up releasing the task even if the main thread
+ is somehow hung.
+ 2. Add an invalidation handler to the process assertion which releases the assertion
+ upon expiration.
+
+ * UIProcess/Cocoa/WebProcessProxyCocoa.mm:
+ (WebKit::WebProcessProxy::processWasUnexpectedlyUnsuspended):
+ * WebProcess/WebProcess.cpp:
+ (WebKit::WebProcess::processDidResume):
+ * WebProcess/WebProcess.h:
+ * WebProcess/cocoa/WebProcessCocoa.mm:
+ (WebKit::WebProcess::processTaskStateDidChange):
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@251304 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2019-10-18 Chris Dumez <[email protected]>
+
+ [iOS] "Unexpectedly Resumed" process assertion may cause us to get terminated
+ https://bugs.webkit.org/show_bug.cgi?id=203046
+ <rdar://problem/56179592>
+
+ Reviewed by Geoffrey Garen.
+
+ This patch implements the following to avoid getting terminated:
+ 1. Schedule the task to release the assertion on a background thread instead of
+ the main thread so that we end up releasing the task even if the main thread
+ is somehow hung.
+ 2. Add an invalidation handler to the process assertion which releases the assertion
+ upon expiration.
+
+ * UIProcess/Cocoa/WebProcessProxyCocoa.mm:
+ (WebKit::WebProcessProxy::processWasUnexpectedlyUnsuspended):
+ * WebProcess/WebProcess.cpp:
+ (WebKit::WebProcess::processDidResume):
+ * WebProcess/WebProcess.h:
+ * WebProcess/cocoa/WebProcessCocoa.mm:
+ (WebKit::WebProcess::processTaskStateDidChange):
+
2019-10-21 Dean Jackson <[email protected]>
Cherry-pick r251390. rdar://56579651
Modified: branches/safari-608-branch/Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm (251721 => 251722)
--- branches/safari-608-branch/Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm 2019-10-29 19:51:08 UTC (rev 251721)
+++ branches/safari-608-branch/Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm 2019-10-29 19:51:11 UTC (rev 251722)
@@ -194,7 +194,7 @@
{
if (m_throttler.shouldBeRunnable()) {
// The process becoming unsuspended was not unexpected; it likely was notified of its running state
- // before receiving a procsessDidResume() message from the UIProcess.
+ // before receiving a processDidResume() message from the UIProcess.
return;
}
Modified: branches/safari-608-branch/Source/WebKit/WebProcess/WebProcess.cpp (251721 => 251722)
--- branches/safari-608-branch/Source/WebKit/WebProcess/WebProcess.cpp 2019-10-29 19:51:08 UTC (rev 251721)
+++ branches/safari-608-branch/Source/WebKit/WebProcess/WebProcess.cpp 2019-10-29 19:51:11 UTC (rev 251722)
@@ -1634,6 +1634,10 @@
m_webSQLiteDatabaseTracker.setIsSuspended(false);
SQLiteDatabase::setIsDatabaseOpeningForbidden(false);
accessibilityProcessSuspendedNotification(false);
+ {
+ LockHolder holder(m_unexpectedlyResumedUIAssertionLock);
+ m_unexpectedlyResumedUIAssertion = nullptr;
+ }
#endif
#if ENABLE(VIDEO)
Modified: branches/safari-608-branch/Source/WebKit/WebProcess/WebProcess.h (251721 => 251722)
--- branches/safari-608-branch/Source/WebKit/WebProcess/WebProcess.h 2019-10-29 19:51:08 UTC (rev 251721)
+++ branches/safari-608-branch/Source/WebKit/WebProcess/WebProcess.h 2019-10-29 19:51:11 UTC (rev 251722)
@@ -62,6 +62,7 @@
#if PLATFORM(IOS_FAMILY)
#include "ProcessTaskStateObserver.h"
+OBJC_CLASS BKSProcessAssertion;
#endif
#if PLATFORM(WAYLAND) && USE(WPE_RENDERER)
@@ -530,6 +531,8 @@
#if PLATFORM(IOS_FAMILY)
WebSQLiteDatabaseTracker m_webSQLiteDatabaseTracker;
Ref<ProcessTaskStateObserver> m_taskStateObserver;
+ Lock m_unexpectedlyResumedUIAssertionLock;
+ RetainPtr<BKSProcessAssertion> m_unexpectedlyResumedUIAssertion;
#endif
enum PageMarkingLayersAsVolatileCounterType { };
Modified: branches/safari-608-branch/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (251721 => 251722)
--- branches/safari-608-branch/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm 2019-10-29 19:51:08 UTC (rev 251721)
+++ branches/safari-608-branch/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm 2019-10-29 19:51:11 UTC (rev 251722)
@@ -311,12 +311,26 @@
if (!m_processIsSuspended)
return;
+ LockHolder holder(m_unexpectedlyResumedUIAssertionLock);
+ if (m_unexpectedlyResumedUIAssertion)
+ return;
+
// We were awakened from suspension unexpectedly. Notify the WebProcessProxy, but take a process assertion on our parent PID
// to ensure that it too is awakened.
+ m_unexpectedlyResumedUIAssertion = adoptNS([[BKSProcessAssertion alloc] initWithPID:parentProcessConnection()->remoteProcessID() flags:BKSProcessAssertionPreventTaskSuspend reason:BKSProcessAssertionReasonFinishTask name:@"Unexpectedly resumed" withHandler:nil]);
- auto uiProcessAssertion = adoptNS([[BKSProcessAssertion alloc] initWithPID:parentProcessConnection()->remoteProcessID() flags:BKSProcessAssertionPreventTaskSuspend reason:BKSProcessAssertionReasonFinishTask name:@"Unexpectedly resumed" withHandler:nil]);
+ auto releaseAssertion = [this] {
+ LockHolder holder(m_unexpectedlyResumedUIAssertionLock);
+ if (!m_unexpectedlyResumedUIAssertion)
+ return;
+
+ [m_unexpectedlyResumedUIAssertion invalidate];
+ m_unexpectedlyResumedUIAssertion = nullptr;
+ };
+
+ m_unexpectedlyResumedUIAssertion.get().invalidationHandler = releaseAssertion;
parentProcessConnection()->send(Messages::WebProcessProxy::ProcessWasUnexpectedlyUnsuspended(), 0);
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), [assertion = WTFMove(uiProcessAssertion)] { [assertion invalidate]; });
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), releaseAssertion);
}
#endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes