Changeset 245255 in webkit
- Timestamp:
- May 13, 2019 3:01:12 PM (5 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r245252 r245255 1 2019-05-13 Jer Noble <jer.noble@apple.com> 2 3 Take out MediaPlayback UI assertion when any WebProcess is playing audible media 4 https://bugs.webkit.org/show_bug.cgi?id=197798 5 6 Reviewed by Chris Dumez. 7 8 To keep the system from suspending the UIProcess (and all the other constellation of processes that 9 are necessary to play media), take a UIProcess assertion with the MediaPlayback reason whenever there 10 is a WebContent process that is playing audible media. 11 12 * Platform/spi/ios/AssertionServicesSPI.h: 13 * UIProcess/ProcessAssertion.h: 14 * UIProcess/WebPageProxy.cpp: 15 (WebKit::WebPageProxy::updatePlayingMediaDidChange): 16 * UIProcess/WebProcessPool.cpp: 17 (WebKit::WebProcessPool::setWebProcessIsPlayingAudibleMedia): 18 (WebKit::WebProcessPool::clearWebProcessIsPlayingAudibleMedia): 19 * UIProcess/WebProcessPool.h: 20 * UIProcess/WebProcessProxy.cpp: 21 (WebKit::WebProcessProxy::webPageMediaStateDidChange): 22 * UIProcess/WebProcessProxy.h: 23 * UIProcess/ios/ProcessAssertionIOS.mm: 24 (WebKit::toBKSProcessAssertionReason): 25 (WebKit::ProcessAssertion::ProcessAssertion): 26 * WebProcess/WebProcess.h: 27 1 28 2019-05-13 Per Arne Vollan <pvollan@apple.com> 2 29 -
trunk/Source/WebKit/Platform/spi/ios/AssertionServicesSPI.h
r244091 r245255 70 70 71 71 enum { 72 BKSProcessAssertionReasonMediaPlayback = 1, 72 73 BKSProcessAssertionReasonFinishTask = 4, 73 74 BKSProcessAssertionReasonExtension = 13, -
trunk/Source/WebKit/UIProcess/ProcessAssertion.h
r244091 r245255 53 53 FinishTask, 54 54 FinishTaskUnbounded, 55 MediaPlayback, 55 56 }; 56 57 -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r245198 r245255 1038 1038 1039 1039 stopAllURLSchemeTasks(); 1040 updatePlayingMediaDidChange(MediaProducer::IsNotPlaying); 1040 1041 } 1041 1042 … … 7071 7072 m_pageLoadState.reset(transaction); 7072 7073 } 7074 7075 updatePlayingMediaDidChange(MediaProducer::IsNotPlaying); 7073 7076 7074 7077 // FIXME: <rdar://problem/38676604> In case of process swaps, the old process should gracefully suspend instead of terminating. … … 8093 8096 focusManager->updatePlaybackAttributesFromMediaState(this, sourceElementID, newState); 8094 8097 #endif 8095 updatePlayingMediaDidChange(newState); 8098 if (!m_isClosed) 8099 updatePlayingMediaDidChange(newState); 8096 8100 } 8097 8101 … … 8131 8135 if ((oldState & MediaProducer::HasAudioOrVideo) != (m_mediaState & MediaProducer::HasAudioOrVideo)) 8132 8136 videoControlsManagerDidChange(); 8137 8138 m_process->webPageMediaStateDidChange(*this); 8133 8139 } 8134 8140 -
trunk/Source/WebKit/UIProcess/WebProcessPool.cpp
r245234 r245255 1101 1101 { 1102 1102 ASSERT(m_processes.contains(process)); 1103 ASSERT(!m_processesPlayingAudibleMedia.contains(process->coreProcessIdentifier())); 1103 1104 1104 1105 if (m_prewarmedProcess == process) { … … 2571 2572 } 2572 2573 2574 void WebProcessPool::setWebProcessIsPlayingAudibleMedia(WebCore::ProcessIdentifier processID) 2575 { 2576 auto* process = WebProcessProxy::processForIdentifier(processID); 2577 ASSERT(process); 2578 2579 RELEASE_LOG(ProcessSuspension, "Web process pid %u is now playing audible media", (unsigned)process->processIdentifier()); 2580 2581 if (m_processesPlayingAudibleMedia.isEmpty()) { 2582 RELEASE_LOG(ProcessSuspension, "The number of processes playing audible media is now one. Taking UI process assertion."); 2583 2584 ASSERT(!m_uiProcessMediaPlaybackAssertion); 2585 m_uiProcessMediaPlaybackAssertion = std::make_unique<ProcessAssertion>(getCurrentProcessID(), "WebKit Media Playback"_s, AssertionState::Foreground, AssertionReason::MediaPlayback); 2586 } 2587 2588 auto result = m_processesPlayingAudibleMedia.add(processID, nullptr); 2589 ASSERT(result.isNewEntry); 2590 result.iterator->value = std::make_unique<ProcessAssertion>(process->processIdentifier(), "WebKit Media Playback"_s, AssertionState::Foreground, AssertionReason::MediaPlayback); 2591 } 2592 2593 void WebProcessPool::clearWebProcessIsPlayingAudibleMedia(WebCore::ProcessIdentifier processID) 2594 { 2595 auto result = m_processesPlayingAudibleMedia.take(processID); 2596 ASSERT_UNUSED(result, result); 2597 2598 auto* process = WebProcessProxy::processForIdentifier(processID); 2599 ASSERT(process); 2600 RELEASE_LOG(ProcessSuspension, "Web process pid %u is no longer playing audible media", (unsigned)process->processIdentifier()); 2601 2602 if (m_processesPlayingAudibleMedia.isEmpty()) { 2603 RELEASE_LOG(ProcessSuspension, "The number of processes playing audible media now zero. Releasing UI process assertion."); 2604 2605 ASSERT(m_uiProcessMediaPlaybackAssertion); 2606 m_uiProcessMediaPlaybackAssertion = nullptr; 2607 } 2608 } 2609 2573 2610 } // namespace WebKit -
trunk/Source/WebKit/UIProcess/WebProcessPool.h
r245149 r245255 506 506 void clearWebProcessHasUploads(WebCore::ProcessIdentifier); 507 507 508 void setWebProcessIsPlayingAudibleMedia(WebCore::ProcessIdentifier); 509 void clearWebProcessIsPlayingAudibleMedia(WebCore::ProcessIdentifier); 510 508 511 void disableDelayedWebProcessLaunch() { m_isDelayedWebProcessLaunchDisabled = true; } 509 512 … … 789 792 HashMap<WebCore::ProcessIdentifier, std::unique_ptr<ProcessAssertion>> m_processesWithUploads; 790 793 std::unique_ptr<ProcessAssertion> m_uiProcessUploadAssertion; 794 795 HashMap<WebCore::ProcessIdentifier, std::unique_ptr<ProcessAssertion>> m_processesPlayingAudibleMedia; 796 std::unique_ptr<ProcessAssertion> m_uiProcessMediaPlaybackAssertion; 797 791 798 #if PLATFORM(IOS) 792 799 // FIXME: Delayed process launch is currently disabled on iOS for performance reasons (rdar://problem/49074131). -
trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp
r245151 r245255 1210 1210 #endif 1211 1211 } 1212 1212 1213 void WebProcessProxy::webPageMediaStateDidChange(WebPageProxy&) 1214 { 1215 bool newHasAudibleWebPage = WTF::anyOf(m_pageMap.values(), [] (auto& page) { return page->isPlayingAudio(); }); 1216 if (m_hasAudibleWebPage == newHasAudibleWebPage) 1217 return; 1218 m_hasAudibleWebPage = newHasAudibleWebPage; 1219 1220 if (m_hasAudibleWebPage) 1221 processPool().setWebProcessIsPlayingAudibleMedia(coreProcessIdentifier()); 1222 else 1223 processPool().clearWebProcessIsPlayingAudibleMedia(coreProcessIdentifier()); 1224 } 1225 1213 1226 void WebProcessProxy::setIsHoldingLockedFiles(bool isHoldingLockedFiles) 1214 1227 { -
trunk/Source/WebKit/UIProcess/WebProcessProxy.h
r244091 r245255 307 307 #endif 308 308 309 void webPageMediaStateDidChange(WebPageProxy&); 310 309 311 protected: 310 312 static uint64_t generatePageID(); … … 486 488 bool m_hasCommittedAnyProvisionalLoads { false }; 487 489 bool m_isPrewarmed; 490 bool m_hasAudibleWebPage { false }; 488 491 489 492 #if PLATFORM(WATCHOS) -
trunk/Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm
r244761 r245255 182 182 case AssertionReason::FinishTaskUnbounded: 183 183 return BKSProcessAssertionReasonFinishTaskUnbounded; 184 case AssertionReason::MediaPlayback: 185 return BKSProcessAssertionReasonMediaPlayback; 184 186 } 185 187 }
Note: See TracChangeset
for help on using the changeset viewer.