Changeset 260574 in webkit
- Timestamp:
- Apr 23, 2020 9:27:03 AM (4 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r260570 r260574 1 2020-04-23 Chris Dumez <cdumez@apple.com> 2 3 [iOS] Port MediaPlayback process assertion to RunningBoard 4 https://bugs.webkit.org/show_bug.cgi?id=210212 5 <rdar://problem/61476951> 6 7 Reviewed by Geoff Garen. 8 9 Port MediaPlayback process assertion to RunningBoard instead of the legacy BKSProcessAssertion. 10 We can now #ifdef out the legacy BKSProcessAssertion on recent iOS builds. 11 12 * UIProcess/ProcessAssertion.h: 13 * UIProcess/ios/ProcessAssertionIOS.mm: 14 (WebKit::runningBoardNameForAssertionType): 15 (WebKit::ProcessAssertion::ProcessAssertion): 16 (WebKit::ProcessAssertion::~ProcessAssertion): 17 1 18 2020-04-23 John Frankish <john.frankish@outlook.com> 2 19 -
trunk/Source/WebKit/UIProcess/ProcessAssertion.h
r260453 r260574 40 40 OBJC_CLASS RBSAssertion; 41 41 OBJC_CLASS WKRBSAssertionDelegate; 42 #if !HAVE(RUNNINGBOARD_VISIBILITY_ASSERTIONS) 42 43 OBJC_CLASS BKSProcessAssertion; 44 #endif 43 45 #endif // PLATFORM(IOS_FAMILY) 44 46 … … 86 88 RetainPtr<RBSAssertion> m_rbsAssertion; 87 89 RetainPtr<WKRBSAssertionDelegate> m_delegate; 90 #if !HAVE(RUNNINGBOARD_VISIBILITY_ASSERTIONS) 88 91 RetainPtr<BKSProcessAssertion> m_bksAssertion; // Legacy. 92 #endif 89 93 Validity m_validity { Validity::Unset }; 90 94 #endif -
trunk/Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm
r260569 r260574 29 29 #if PLATFORM(IOS_FAMILY) 30 30 31 #import "AssertionServicesSPI.h"32 31 #import "Logging.h" 33 32 #import "RunningBoardServicesSPI.h" … … 38 37 #import <wtf/Vector.h> 39 38 #import <wtf/WeakHashSet.h> 39 40 #if !HAVE(RUNNINGBOARD_VISIBILITY_ASSERTIONS) 41 #import "AssertionServicesSPI.h" 42 #endif 40 43 41 44 using WebKit::ProcessAndUIAssertion; … … 314 317 return @"DependentProcessLink"; 315 318 case ProcessAssertionType::MediaPlayback: 316 return nil; // FIXME: Name to be defined in <rdar://problem/61263147>.319 return @"MediaPlayback"; 317 320 } 318 321 #else … … 322 325 #endif 323 326 } 327 328 #if !HAVE(RUNNINGBOARD_VISIBILITY_ASSERTIONS) 324 329 325 330 const BKSProcessAssertionFlags suspendedTabFlags = (BKSProcessAssertionAllowIdleSleep); … … 361 366 } 362 367 368 #endif // !HAVE(RUNNINGBOARD_VISIBILITY_ASSERTIONS) 369 363 370 ProcessAssertion::ProcessAssertion(pid_t pid, const String& reason, ProcessAssertionType assertionType) 364 371 : m_assertionType(assertionType) … … 367 374 auto weakThis = makeWeakPtr(*this); 368 375 NSString *runningBoardAssertionName = runningBoardNameForAssertionType(assertionType); 369 if (runningBoardAssertionName) { 370 if (!pid) { 371 RELEASE_LOG_ERROR(ProcessSuspension, "%p - ProcessAssertion: Failed to acquire RBS %{public}@ assertion '%{public}s' for process because PID is invalid", this, runningBoardAssertionName, reason.utf8().data()); 372 return; 373 } 374 375 RBSTarget *target = [RBSTarget targetWithPid:pid]; 376 RBSDomainAttribute *domainAttribute = [RBSDomainAttribute attributeWithDomain:@"com.apple.webkit" name:runningBoardAssertionName]; 377 m_rbsAssertion = adoptNS([[RBSAssertion alloc] initWithExplanation:reason target:target attributes:@[domainAttribute]]); 378 379 m_delegate = adoptNS([[WKRBSAssertionDelegate alloc] init]); 380 [m_rbsAssertion addObserver:m_delegate.get()]; 381 m_delegate.get().invalidationCallback = ^{ 382 RELEASE_LOG(ProcessSuspension, "%p - ProcessAssertion() RBS %{public}@ assertion for process with PID %d was invalidated", this, runningBoardAssertionName, pid); 383 processAssertionWasInvalidated(); 384 }; 385 386 NSError *acquisitionError = nil; 387 if (![m_rbsAssertion acquireWithError:&acquisitionError]) { 388 RELEASE_LOG_ERROR(ProcessSuspension, "%p - ProcessAssertion: Failed to acquire RBS %{public}@ assertion '%{public}s' for process with PID %d, error: %{public}@", this, runningBoardAssertionName, reason.utf8().data(), pid, acquisitionError); 389 dispatch_async(dispatch_get_main_queue(), ^{ 390 if (weakThis) 391 processAssertionWasInvalidated(); 392 }); 393 } else 394 RELEASE_LOG(ProcessSuspension, "%p - ProcessAssertion: Successfully took RBS %{public}@ assertion '%{public}s' for process with PID %d", this, runningBoardAssertionName, reason.utf8().data(), pid); 395 } else { 376 377 #if !HAVE(RUNNINGBOARD_VISIBILITY_ASSERTIONS) 378 if (!runningBoardAssertionName) { 396 379 // Legacy code path. 397 380 BKSProcessAssertionAcquisitionHandler handler = ^(BOOL acquired) { … … 415 398 }); 416 399 }; 417 } 400 return; 401 } 402 #endif // !HAVE(RUNNINGBOARD_VISIBILITY_ASSERTIONS) 403 404 ASSERT(runningBoardAssertionName); 405 if (!pid) { 406 RELEASE_LOG_ERROR(ProcessSuspension, "%p - ProcessAssertion: Failed to acquire RBS %{public}@ assertion '%{public}s' for process because PID is invalid", this, runningBoardAssertionName, reason.utf8().data()); 407 return; 408 } 409 410 RBSTarget *target = [RBSTarget targetWithPid:pid]; 411 RBSDomainAttribute *domainAttribute = [RBSDomainAttribute attributeWithDomain:@"com.apple.webkit" name:runningBoardAssertionName]; 412 m_rbsAssertion = adoptNS([[RBSAssertion alloc] initWithExplanation:reason target:target attributes:@[domainAttribute]]); 413 414 m_delegate = adoptNS([[WKRBSAssertionDelegate alloc] init]); 415 [m_rbsAssertion addObserver:m_delegate.get()]; 416 m_delegate.get().invalidationCallback = ^{ 417 RELEASE_LOG(ProcessSuspension, "%p - ProcessAssertion() RBS %{public}@ assertion for process with PID %d was invalidated", this, runningBoardAssertionName, pid); 418 processAssertionWasInvalidated(); 419 }; 420 421 NSError *acquisitionError = nil; 422 if (![m_rbsAssertion acquireWithError:&acquisitionError]) { 423 RELEASE_LOG_ERROR(ProcessSuspension, "%p - ProcessAssertion: Failed to acquire RBS %{public}@ assertion '%{public}s' for process with PID %d, error: %{public}@", this, runningBoardAssertionName, reason.utf8().data(), pid, acquisitionError); 424 dispatch_async(dispatch_get_main_queue(), ^{ 425 if (weakThis) 426 processAssertionWasInvalidated(); 427 }); 428 } else 429 RELEASE_LOG(ProcessSuspension, "%p - ProcessAssertion: Successfully took RBS %{public}@ assertion '%{public}s' for process with PID %d", this, runningBoardAssertionName, reason.utf8().data(), pid); 418 430 } 419 431 … … 428 440 [m_rbsAssertion removeObserver:m_delegate.get()]; 429 441 [m_rbsAssertion invalidate]; 430 } else { 442 } 443 444 #if !HAVE(RUNNINGBOARD_VISIBILITY_ASSERTIONS) 445 if (m_bksAssertion) { 431 446 m_bksAssertion.get().invalidationHandler = nil; 432 447 [m_bksAssertion invalidate]; 433 448 } 449 #endif 434 450 } 435 451
Note: See TracChangeset
for help on using the changeset viewer.