Changeset 245319 in webkit
- Timestamp:
- May 14, 2019, 10:24:03 PM (7 years ago)
- Location:
- branches/safari-608.1.24-branch/Source/WebKit
- Files:
-
- 9 edited
-
ChangeLog (modified) (1 diff)
-
Platform/spi/ios/AssertionServicesSPI.h (modified) (1 diff)
-
UIProcess/ProcessAssertion.h (modified) (1 diff)
-
UIProcess/WebPageProxy.cpp (modified) (4 diffs)
-
UIProcess/WebProcessPool.cpp (modified) (2 diffs)
-
UIProcess/WebProcessPool.h (modified) (2 diffs)
-
UIProcess/WebProcessProxy.cpp (modified) (1 diff)
-
UIProcess/WebProcessProxy.h (modified) (2 diffs)
-
UIProcess/ios/ProcessAssertionIOS.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-608.1.24-branch/Source/WebKit/ChangeLog
r245310 r245319 1 2019-05-14 Kocsen Chung <kocsen_chung@apple.com> 2 3 Cherry-pick r245255. rdar://problem/50141840 4 5 Take out MediaPlayback UI assertion when any WebProcess is playing audible media 6 https://bugs.webkit.org/show_bug.cgi?id=197798 7 8 Reviewed by Chris Dumez. 9 10 To keep the system from suspending the UIProcess (and all the other constellation of processes that 11 are necessary to play media), take a UIProcess assertion with the MediaPlayback reason whenever there 12 is a WebContent process that is playing audible media. 13 14 * Platform/spi/ios/AssertionServicesSPI.h: 15 * UIProcess/ProcessAssertion.h: 16 * UIProcess/WebPageProxy.cpp: 17 (WebKit::WebPageProxy::updatePlayingMediaDidChange): 18 * UIProcess/WebProcessPool.cpp: 19 (WebKit::WebProcessPool::setWebProcessIsPlayingAudibleMedia): 20 (WebKit::WebProcessPool::clearWebProcessIsPlayingAudibleMedia): 21 * UIProcess/WebProcessPool.h: 22 * UIProcess/WebProcessProxy.cpp: 23 (WebKit::WebProcessProxy::webPageMediaStateDidChange): 24 * UIProcess/WebProcessProxy.h: 25 * UIProcess/ios/ProcessAssertionIOS.mm: 26 (WebKit::toBKSProcessAssertionReason): 27 (WebKit::ProcessAssertion::ProcessAssertion): 28 * WebProcess/WebProcess.h: 29 30 31 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245255 268f45cc-cd09-0410-ab3c-d52691b4dbfc 32 33 2019-05-13 Jer Noble <jer.noble@apple.com> 34 35 Take out MediaPlayback UI assertion when any WebProcess is playing audible media 36 https://bugs.webkit.org/show_bug.cgi?id=197798 37 38 Reviewed by Chris Dumez. 39 40 To keep the system from suspending the UIProcess (and all the other constellation of processes that 41 are necessary to play media), take a UIProcess assertion with the MediaPlayback reason whenever there 42 is a WebContent process that is playing audible media. 43 44 * Platform/spi/ios/AssertionServicesSPI.h: 45 * UIProcess/ProcessAssertion.h: 46 * UIProcess/WebPageProxy.cpp: 47 (WebKit::WebPageProxy::updatePlayingMediaDidChange): 48 * UIProcess/WebProcessPool.cpp: 49 (WebKit::WebProcessPool::setWebProcessIsPlayingAudibleMedia): 50 (WebKit::WebProcessPool::clearWebProcessIsPlayingAudibleMedia): 51 * UIProcess/WebProcessPool.h: 52 * UIProcess/WebProcessProxy.cpp: 53 (WebKit::WebProcessProxy::webPageMediaStateDidChange): 54 * UIProcess/WebProcessProxy.h: 55 * UIProcess/ios/ProcessAssertionIOS.mm: 56 (WebKit::toBKSProcessAssertionReason): 57 (WebKit::ProcessAssertion::ProcessAssertion): 58 * WebProcess/WebProcess.h: 59 1 60 2019-05-14 Alan Coon <alancoon@apple.com> 2 61 -
branches/safari-608.1.24-branch/Source/WebKit/Platform/spi/ios/AssertionServicesSPI.h
r244091 r245319 70 70 71 71 enum { 72 BKSProcessAssertionReasonMediaPlayback = 1, 72 73 BKSProcessAssertionReasonFinishTask = 4, 73 74 BKSProcessAssertionReasonExtension = 13, -
branches/safari-608.1.24-branch/Source/WebKit/UIProcess/ProcessAssertion.h
r244091 r245319 53 53 FinishTask, 54 54 FinishTaskUnbounded, 55 MediaPlayback, 55 56 }; 56 57 -
branches/safari-608.1.24-branch/Source/WebKit/UIProcess/WebPageProxy.cpp
r245228 r245319 1039 1039 1040 1040 stopAllURLSchemeTasks(); 1041 updatePlayingMediaDidChange(MediaProducer::IsNotPlaying); 1041 1042 } 1042 1043 … … 7053 7054 m_pageLoadState.reset(transaction); 7054 7055 } 7056 7057 updatePlayingMediaDidChange(MediaProducer::IsNotPlaying); 7055 7058 7056 7059 // FIXME: <rdar://problem/38676604> In case of process swaps, the old process should gracefully suspend instead of terminating. … … 8075 8078 focusManager->updatePlaybackAttributesFromMediaState(this, sourceElementID, newState); 8076 8079 #endif 8077 updatePlayingMediaDidChange(newState); 8080 if (!m_isClosed) 8081 updatePlayingMediaDidChange(newState); 8078 8082 } 8079 8083 … … 8113 8117 if ((oldState & MediaProducer::HasAudioOrVideo) != (m_mediaState & MediaProducer::HasAudioOrVideo)) 8114 8118 videoControlsManagerDidChange(); 8119 8120 m_process->webPageMediaStateDidChange(*this); 8115 8121 } 8116 8122 -
branches/safari-608.1.24-branch/Source/WebKit/UIProcess/WebProcessPool.cpp
r245075 r245319 1101 1101 { 1102 1102 ASSERT(m_processes.contains(process)); 1103 ASSERT(!m_processesPlayingAudibleMedia.contains(process->coreProcessIdentifier())); 1103 1104 1104 1105 if (m_prewarmedProcess == process) { … … 2576 2577 } 2577 2578 2579 void WebProcessPool::setWebProcessIsPlayingAudibleMedia(WebCore::ProcessIdentifier processID) 2580 { 2581 auto* process = WebProcessProxy::processForIdentifier(processID); 2582 ASSERT(process); 2583 2584 RELEASE_LOG(ProcessSuspension, "Web process pid %u is now playing audible media", (unsigned)process->processIdentifier()); 2585 2586 if (m_processesPlayingAudibleMedia.isEmpty()) { 2587 RELEASE_LOG(ProcessSuspension, "The number of processes playing audible media is now one. Taking UI process assertion."); 2588 2589 ASSERT(!m_uiProcessMediaPlaybackAssertion); 2590 m_uiProcessMediaPlaybackAssertion = std::make_unique<ProcessAssertion>(getCurrentProcessID(), "WebKit Media Playback"_s, AssertionState::Foreground, AssertionReason::MediaPlayback); 2591 } 2592 2593 auto result = m_processesPlayingAudibleMedia.add(processID, nullptr); 2594 ASSERT(result.isNewEntry); 2595 result.iterator->value = std::make_unique<ProcessAssertion>(process->processIdentifier(), "WebKit Media Playback"_s, AssertionState::Foreground, AssertionReason::MediaPlayback); 2596 } 2597 2598 void WebProcessPool::clearWebProcessIsPlayingAudibleMedia(WebCore::ProcessIdentifier processID) 2599 { 2600 auto result = m_processesPlayingAudibleMedia.take(processID); 2601 ASSERT_UNUSED(result, result); 2602 2603 auto* process = WebProcessProxy::processForIdentifier(processID); 2604 ASSERT(process); 2605 RELEASE_LOG(ProcessSuspension, "Web process pid %u is no longer playing audible media", (unsigned)process->processIdentifier()); 2606 2607 if (m_processesPlayingAudibleMedia.isEmpty()) { 2608 RELEASE_LOG(ProcessSuspension, "The number of processes playing audible media now zero. Releasing UI process assertion."); 2609 2610 ASSERT(m_uiProcessMediaPlaybackAssertion); 2611 m_uiProcessMediaPlaybackAssertion = nullptr; 2612 } 2613 } 2614 2578 2615 } // namespace WebKit -
branches/safari-608.1.24-branch/Source/WebKit/UIProcess/WebProcessPool.h
r244521 r245319 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 … … 791 794 HashMap<WebCore::ProcessIdentifier, std::unique_ptr<ProcessAssertion>> m_processesWithUploads; 792 795 std::unique_ptr<ProcessAssertion> m_uiProcessUploadAssertion; 796 797 HashMap<WebCore::ProcessIdentifier, std::unique_ptr<ProcessAssertion>> m_processesPlayingAudibleMedia; 798 std::unique_ptr<ProcessAssertion> m_uiProcessMediaPlaybackAssertion; 799 793 800 #if PLATFORM(IOS) 794 801 // FIXME: Delayed process launch is currently disabled on iOS for performance reasons (rdar://problem/49074131). -
branches/safari-608.1.24-branch/Source/WebKit/UIProcess/WebProcessProxy.cpp
r245310 r245319 1217 1217 #endif 1218 1218 } 1219 1219 1220 void WebProcessProxy::webPageMediaStateDidChange(WebPageProxy&) 1221 { 1222 bool newHasAudibleWebPage = WTF::anyOf(m_pageMap.values(), [] (auto& page) { return page->isPlayingAudio(); }); 1223 if (m_hasAudibleWebPage == newHasAudibleWebPage) 1224 return; 1225 m_hasAudibleWebPage = newHasAudibleWebPage; 1226 1227 if (m_hasAudibleWebPage) 1228 processPool().setWebProcessIsPlayingAudibleMedia(coreProcessIdentifier()); 1229 else 1230 processPool().clearWebProcessIsPlayingAudibleMedia(coreProcessIdentifier()); 1231 } 1232 1220 1233 void WebProcessProxy::setIsHoldingLockedFiles(bool isHoldingLockedFiles) 1221 1234 { -
branches/safari-608.1.24-branch/Source/WebKit/UIProcess/WebProcessProxy.h
r244091 r245319 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) -
branches/safari-608.1.24-branch/Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm
r244761 r245319 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.