Changeset 251879 in webkit
- Timestamp:
- Oct 31, 2019 2:32:29 PM (5 years ago)
- Location:
- branches/safari-608.3.10.0-branch/Source/WebKit
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-608.3.10.0-branch/Source/WebKit/ChangeLog
r251141 r251879 1 2019-10-31 Alan Coon <alancoon@apple.com> 2 3 Cherry-pick r251304. rdar://problem/56763315 4 5 [iOS] "Unexpectedly Resumed" process assertion may cause us to get terminated 6 https://bugs.webkit.org/show_bug.cgi?id=203046 7 <rdar://problem/56179592> 8 9 Reviewed by Geoffrey Garen. 10 11 This patch implements the following to avoid getting terminated: 12 1. Schedule the task to release the assertion on a background thread instead of 13 the main thread so that we end up releasing the task even if the main thread 14 is somehow hung. 15 2. Add an invalidation handler to the process assertion which releases the assertion 16 upon expiration. 17 18 * UIProcess/Cocoa/WebProcessProxyCocoa.mm: 19 (WebKit::WebProcessProxy::processWasUnexpectedlyUnsuspended): 20 * WebProcess/WebProcess.cpp: 21 (WebKit::WebProcess::processDidResume): 22 * WebProcess/WebProcess.h: 23 * WebProcess/cocoa/WebProcessCocoa.mm: 24 (WebKit::WebProcess::processTaskStateDidChange): 25 26 27 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@251304 268f45cc-cd09-0410-ab3c-d52691b4dbfc 28 29 2019-10-18 Chris Dumez <cdumez@apple.com> 30 31 [iOS] "Unexpectedly Resumed" process assertion may cause us to get terminated 32 https://bugs.webkit.org/show_bug.cgi?id=203046 33 <rdar://problem/56179592> 34 35 Reviewed by Geoffrey Garen. 36 37 This patch implements the following to avoid getting terminated: 38 1. Schedule the task to release the assertion on a background thread instead of 39 the main thread so that we end up releasing the task even if the main thread 40 is somehow hung. 41 2. Add an invalidation handler to the process assertion which releases the assertion 42 upon expiration. 43 44 * UIProcess/Cocoa/WebProcessProxyCocoa.mm: 45 (WebKit::WebProcessProxy::processWasUnexpectedlyUnsuspended): 46 * WebProcess/WebProcess.cpp: 47 (WebKit::WebProcess::processDidResume): 48 * WebProcess/WebProcess.h: 49 * WebProcess/cocoa/WebProcessCocoa.mm: 50 (WebKit::WebProcess::processTaskStateDidChange): 51 1 52 2019-10-15 Alan Coon <alancoon@apple.com> 2 53 -
branches/safari-608.3.10.0-branch/Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm
r250530 r251879 195 195 if (m_throttler.shouldBeRunnable()) { 196 196 // The process becoming unsuspended was not unexpected; it likely was notified of its running state 197 // before receiving a proc sessDidResume() message from the UIProcess.197 // before receiving a processDidResume() message from the UIProcess. 198 198 return; 199 199 } -
branches/safari-608.3.10.0-branch/Source/WebKit/WebProcess/WebProcess.cpp
r250530 r251879 1635 1635 SQLiteDatabase::setIsDatabaseOpeningForbidden(false); 1636 1636 accessibilityProcessSuspendedNotification(false); 1637 { 1638 LockHolder holder(m_unexpectedlyResumedUIAssertionLock); 1639 m_unexpectedlyResumedUIAssertion = nullptr; 1640 } 1637 1641 #endif 1638 1642 -
branches/safari-608.3.10.0-branch/Source/WebKit/WebProcess/WebProcess.h
r250530 r251879 63 63 #if PLATFORM(IOS_FAMILY) 64 64 #include "ProcessTaskStateObserver.h" 65 OBJC_CLASS BKSProcessAssertion; 65 66 #endif 66 67 … … 531 532 WebSQLiteDatabaseTracker m_webSQLiteDatabaseTracker; 532 533 Ref<ProcessTaskStateObserver> m_taskStateObserver; 534 Lock m_unexpectedlyResumedUIAssertionLock; 535 RetainPtr<BKSProcessAssertion> m_unexpectedlyResumedUIAssertion; 533 536 #endif 534 537 -
branches/safari-608.3.10.0-branch/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm
r250826 r251879 312 312 return; 313 313 314 LockHolder holder(m_unexpectedlyResumedUIAssertionLock); 315 if (m_unexpectedlyResumedUIAssertion) 316 return; 317 314 318 // We were awakened from suspension unexpectedly. Notify the WebProcessProxy, but take a process assertion on our parent PID 315 319 // to ensure that it too is awakened. 316 317 auto uiProcessAssertion = adoptNS([[BKSProcessAssertion alloc] initWithPID:parentProcessConnection()->remoteProcessID() flags:BKSProcessAssertionPreventTaskSuspend reason:BKSProcessAssertionReasonFinishTask name:@"Unexpectedly resumed" withHandler:nil]); 320 m_unexpectedlyResumedUIAssertion = adoptNS([[BKSProcessAssertion alloc] initWithPID:parentProcessConnection()->remoteProcessID() flags:BKSProcessAssertionPreventTaskSuspend reason:BKSProcessAssertionReasonFinishTask name:@"Unexpectedly resumed" withHandler:nil]); 321 322 auto releaseAssertion = [this] { 323 LockHolder holder(m_unexpectedlyResumedUIAssertionLock); 324 if (!m_unexpectedlyResumedUIAssertion) 325 return; 326 327 [m_unexpectedlyResumedUIAssertion invalidate]; 328 m_unexpectedlyResumedUIAssertion = nullptr; 329 }; 330 331 m_unexpectedlyResumedUIAssertion.get().invalidationHandler = releaseAssertion; 318 332 parentProcessConnection()->send(Messages::WebProcessProxy::ProcessWasUnexpectedlyUnsuspended(), 0); 319 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_ main_queue(), [assertion = WTFMove(uiProcessAssertion)] { [assertion invalidate]; });333 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), releaseAssertion); 320 334 } 321 335 #endif
Note: See TracChangeset
for help on using the changeset viewer.