Title: [251879] branches/safari-608.3.10.0-branch/Source/WebKit
- Revision
- 251879
- Author
- alanc...@apple.com
- Date
- 2019-10-31 14:32:29 -0700 (Thu, 31 Oct 2019)
Log Message
Cherry-pick r251304. rdar://problem/56763315
[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.3.10.0-branch/Source/WebKit/ChangeLog (251878 => 251879)
--- branches/safari-608.3.10.0-branch/Source/WebKit/ChangeLog 2019-10-31 21:29:38 UTC (rev 251878)
+++ branches/safari-608.3.10.0-branch/Source/WebKit/ChangeLog 2019-10-31 21:32:29 UTC (rev 251879)
@@ -1,3 +1,54 @@
+2019-10-31 Alan Coon <alanc...@apple.com>
+
+ Cherry-pick r251304. rdar://problem/56763315
+
+ [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 <cdu...@apple.com>
+
+ [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-15 Alan Coon <alanc...@apple.com>
Cherry-pick r250773. rdar://problem/56271907
Modified: branches/safari-608.3.10.0-branch/Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm (251878 => 251879)
--- branches/safari-608.3.10.0-branch/Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm 2019-10-31 21:29:38 UTC (rev 251878)
+++ branches/safari-608.3.10.0-branch/Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm 2019-10-31 21:32:29 UTC (rev 251879)
@@ -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.3.10.0-branch/Source/WebKit/WebProcess/WebProcess.cpp (251878 => 251879)
--- branches/safari-608.3.10.0-branch/Source/WebKit/WebProcess/WebProcess.cpp 2019-10-31 21:29:38 UTC (rev 251878)
+++ branches/safari-608.3.10.0-branch/Source/WebKit/WebProcess/WebProcess.cpp 2019-10-31 21:32:29 UTC (rev 251879)
@@ -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.3.10.0-branch/Source/WebKit/WebProcess/WebProcess.h (251878 => 251879)
--- branches/safari-608.3.10.0-branch/Source/WebKit/WebProcess/WebProcess.h 2019-10-31 21:29:38 UTC (rev 251878)
+++ branches/safari-608.3.10.0-branch/Source/WebKit/WebProcess/WebProcess.h 2019-10-31 21:32:29 UTC (rev 251879)
@@ -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.3.10.0-branch/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (251878 => 251879)
--- branches/safari-608.3.10.0-branch/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm 2019-10-31 21:29:38 UTC (rev 251878)
+++ branches/safari-608.3.10.0-branch/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm 2019-10-31 21:32:29 UTC (rev 251879)
@@ -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
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes