Changeset 251304 in webkit
- Timestamp:
- Oct 18, 2019 3:45:42 PM (5 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r251298 r251304 1 2019-10-18 Chris Dumez <cdumez@apple.com> 2 3 [iOS] "Unexpectedly Resumed" process assertion may cause us to get terminated 4 https://bugs.webkit.org/show_bug.cgi?id=203046 5 <rdar://problem/56179592> 6 7 Reviewed by Geoffrey Garen. 8 9 This patch implements the following to avoid getting terminated: 10 1. Schedule the task to release the assertion on a background thread instead of 11 the main thread so that we end up releasing the task even if the main thread 12 is somehow hung. 13 2. Add an invalidation handler to the process assertion which releases the assertion 14 upon expiration. 15 16 * UIProcess/Cocoa/WebProcessProxyCocoa.mm: 17 (WebKit::WebProcessProxy::processWasUnexpectedlyUnsuspended): 18 * WebProcess/WebProcess.cpp: 19 (WebKit::WebProcess::processDidResume): 20 * WebProcess/WebProcess.h: 21 * WebProcess/cocoa/WebProcessCocoa.mm: 22 (WebKit::WebProcess::processTaskStateDidChange): 23 1 24 2019-10-18 Jer Noble <jer.noble@apple.com> 2 25 -
trunk/Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm
r250428 r251304 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 } -
trunk/Source/WebKit/WebProcess/WebProcess.cpp
r251220 r251304 1539 1539 SQLiteDatabase::setIsDatabaseOpeningForbidden(false); 1540 1540 accessibilityProcessSuspendedNotification(false); 1541 { 1542 LockHolder holder(m_unexpectedlyResumedUIAssertionLock); 1543 m_unexpectedlyResumedUIAssertion = nullptr; 1544 } 1541 1545 #endif 1542 1546 -
trunk/Source/WebKit/WebProcess/WebProcess.h
r251220 r251304 66 66 #if PLATFORM(IOS_FAMILY) 67 67 #include "ProcessTaskStateObserver.h" 68 OBJC_CLASS BKSProcessAssertion; 68 69 #endif 69 70 … … 535 536 WebSQLiteDatabaseTracker m_webSQLiteDatabaseTracker; 536 537 Ref<ProcessTaskStateObserver> m_taskStateObserver; 538 Lock m_unexpectedlyResumedUIAssertionLock; 539 RetainPtr<BKSProcessAssertion> m_unexpectedlyResumedUIAssertion; 537 540 #endif 538 541 -
trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm
r250723 r251304 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.