Changeset 271440 in webkit
- Timestamp:
- Jan 13, 2021, 7:53:27 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/mediastream/media-stream-track-interrupted.html (modified) (3 diffs)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp (modified) (3 diffs)
-
Source/WebCore/Modules/mediastream/MediaStreamTrack.h (modified) (2 diffs)
-
Source/WebCore/dom/Document.cpp (modified) (2 diffs)
-
Source/WebCore/page/Page.cpp (modified) (2 diffs)
-
Source/WebCore/page/Page.h (modified) (1 diff)
-
Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.cpp (modified) (2 diffs)
-
Source/WebCore/testing/Internals.cpp (modified) (1 diff)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/WebProcess/WebProcess.cpp (modified) (1 diff)
-
Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r271439 r271440 1 2021-01-13 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, reverting r271401. 4 https://bugs.webkit.org/show_bug.cgi?id=220591 5 6 It is breaking iOS audio rendering 7 8 Reverted changeset: 9 10 "Unmuting a track in case of end of interruption by another 11 web process tab is not working well with capture muting icons" 12 https://bugs.webkit.org/show_bug.cgi?id=220058 13 https://trac.webkit.org/changeset/271401 14 1 15 2021-01-13 Martin Robinson <mrobinson@igalia.com> 2 16 -
trunk/LayoutTests/fast/mediastream/media-stream-track-interrupted.html
r271401 r271440 51 51 function testTrack(track, title) 52 52 { 53 promise_test(async (test) => { 54 if (track.muted) 55 await new Promise(resolve => track.onunmute = resolve); 56 57 await new Promise((resolve, reject) => { 53 promise_test((test) => { 54 return new Promise((resolve, reject) => { 58 55 let isVideo = track.kind == "video"; 59 56 if (window.internals) { … … 71 68 waitForPageStateChange(10, pageState, resolve, reject) 72 69 } 70 73 71 if (window.internals) { 74 assert_true(pageMediaState.includes('HasMutedAudioCaptureDevice'), 'audio muted'); 75 assert_true(pageMediaState.includes('HasMutedVideoCaptureDevice'), 'video muted'); 72 assert_true(pageMediaState.includes(isVideo ? 'HasMutedVideoCaptureDevice' : 'HasMutedAudioCaptureDevice')); 73 assert_false(pageMediaState.includes(isVideo ? 'HasMutedAudioCaptureDevice' : 'HasMutedVideoCaptureDevice')); 74 assert_true(pageMediaState.includes(isVideo ? 'HasActiveAudioCaptureDevice' : 'HasActiveVideoCaptureDevice')); 75 assert_false(pageMediaState.includes(isVideo ? 'HasActiveVideoCaptureDevice' : 'HasActiveAudioCaptureDevice')); 76 76 pageState = internals.pageMediaState(); 77 77 internals.setMediaStreamSourceInterrupted(track, false) … … 86 86 setTimeout(() => reject("Muted state did not change in 1 second"), 1000); 87 87 }); 88 track.onmute = () => { };89 track.onunmute = () => { };90 88 }, title); 91 89 } -
trunk/Source/WebCore/ChangeLog
r271439 r271440 1 2021-01-13 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, reverting r271401. 4 https://bugs.webkit.org/show_bug.cgi?id=220591 5 6 It is breaking iOS audio rendering 7 8 Reverted changeset: 9 10 "Unmuting a track in case of end of interruption by another 11 web process tab is not working well with capture muting icons" 12 https://bugs.webkit.org/show_bug.cgi?id=220058 13 https://trac.webkit.org/changeset/271401 14 1 15 2021-01-13 Martin Robinson <mrobinson@igalia.com> 2 16 -
trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp
r271401 r271440 72 72 track->suspendIfNeeded(); 73 73 74 if (track->isCaptureTrack()) { 75 if (auto* page = track->document()->page()) 76 track->updateToPageMutedState(page->mutedState()); 77 } 74 if (track->isCaptureTrack()) 75 track->updateToPageMutedState(); 78 76 79 77 return track; … … 472 470 #endif 473 471 474 void MediaStreamTrack::updateCaptureAccordingToMutedState(Document& document , MediaProducer::MutedStateFlags mutedState)472 void MediaStreamTrack::updateCaptureAccordingToMutedState(Document& document) 475 473 { 476 474 #if PLATFORM(IOS_FAMILY) … … 479 477 return; 480 478 481 bool pageMuted = mutedState & MediaProducer::AudioAndVideoCaptureIsMuted;482 483 auto updateTracksAccordingPageMutedState = [](const Document& document, CaptureDevice::DeviceType deviceType, bool pageMuted) {484 // We can only have one source at a time: we can mute all tracks but unmute only one of them.485 for (auto* captureTrack : allCaptureTracks()) {486 if (captureTrack->document() != &document || captureTrack->ended() || captureTrack->source().deviceType() != deviceType)487 continue;488 captureTrack->m_private->setMuted(pageMuted);489 // If unmuting, unmute the first source of the document we know.490 if (!pageMuted)491 break;492 }493 };494 479 auto* activeAudioSource = RealtimeMediaSourceCenter::singleton().audioCaptureFactory().activeSource(); 495 if (activeAudioSource && isSourceCapturingForTrackInDocument(*activeAudioSource, document)) 480 if (activeAudioSource && isSourceCapturingForTrackInDocument(*activeAudioSource, document)) { 481 bool pageMuted = page->mutedState() & MediaProducer::AudioAndVideoCaptureIsMuted; 496 482 activeAudioSource->setMuted(pageMuted || (document.hidden() && document.settings().interruptAudioOnPageVisibilityChangeEnabled())); 497 else 498 updateTracksAccordingPageMutedState(document, CaptureDevice::DeviceType::Microphone, pageMuted); 483 } 499 484 500 485 auto* activeVideoSource = RealtimeMediaSourceCenter::singleton().videoCaptureFactory().activeSource(); 501 if (activeVideoSource && isSourceCapturingForTrackInDocument(*activeVideoSource, document)) 486 if (activeVideoSource && isSourceCapturingForTrackInDocument(*activeVideoSource, document)) { 487 bool pageMuted = page->mutedState() & MediaProducer::AudioAndVideoCaptureIsMuted; 502 488 activeVideoSource->setMuted(pageMuted || document.hidden()); 503 else 504 updateTracksAccordingPageMutedState(document, CaptureDevice::DeviceType::Camera, pageMuted); 489 } 505 490 #else 506 491 for (auto* captureTrack : allCaptureTracks()) { 507 492 if (captureTrack->document() == &document && !captureTrack->ended()) 508 captureTrack->updateToPageMutedState( mutedState);493 captureTrack->updateToPageMutedState(); 509 494 } 510 495 #endif 511 496 } 512 497 513 void MediaStreamTrack::updateToPageMutedState( MediaProducer::MutedStateFlags mutedState)498 void MediaStreamTrack::updateToPageMutedState() 514 499 { 515 500 ASSERT(isCaptureTrack()); 501 auto* page = document()->page(); 502 if (!page) 503 return; 516 504 517 505 switch (source().deviceType()) { 518 506 case CaptureDevice::DeviceType::Microphone: 519 507 case CaptureDevice::DeviceType::Camera: 520 m_private->setMuted( mutedState& MediaProducer::AudioAndVideoCaptureIsMuted);508 m_private->setMuted(page->mutedState() & MediaProducer::AudioAndVideoCaptureIsMuted); 521 509 break; 522 510 case CaptureDevice::DeviceType::Screen: 523 511 case CaptureDevice::DeviceType::Window: 524 m_private->setMuted( mutedState& MediaProducer::ScreenCaptureIsMuted);512 m_private->setMuted(page->mutedState() & MediaProducer::ScreenCaptureIsMuted); 525 513 break; 526 514 case CaptureDevice::DeviceType::Speaker: -
trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.h
r271401 r271440 73 73 74 74 static MediaProducer::MediaStateFlags captureState(Document&); 75 static void updateCaptureAccordingToMutedState(Document& , MediaProducer::MutedStateFlags);75 static void updateCaptureAccordingToMutedState(Document&); 76 76 77 77 virtual bool isCanvas() const { return false; } … … 170 170 171 171 void configureTrackRendering(); 172 void updateToPageMutedState( MediaProducer::MutedStateFlags);172 void updateToPageMutedState(); 173 173 174 174 // ActiveDOMObject API. -
trunk/Source/WebCore/dom/Document.cpp
r271433 r271440 1810 1810 1811 1811 #if ENABLE(MEDIA_STREAM) && PLATFORM(IOS_FAMILY) 1812 auto* page = this->page();1813 if (!page)1814 return;1815 1816 1812 if (auto mediaSessionManager = PlatformMediaSessionManager::sharedManagerIfExists()) { 1817 1813 if (!mediaSessionManager->isInterrupted()) 1818 MediaStreamTrack::updateCaptureAccordingToMutedState(*this , page->mutedState());1814 MediaStreamTrack::updateCaptureAccordingToMutedState(*this); 1819 1815 } 1820 1816 #endif … … 4302 4298 4303 4299 #if ENABLE(MEDIA_STREAM) 4304 MediaStreamTrack::updateCaptureAccordingToMutedState(*this , page()->mutedState());4300 MediaStreamTrack::updateCaptureAccordingToMutedState(*this); 4305 4301 #endif 4306 4302 } -
trunk/Source/WebCore/page/Page.cpp
r271401 r271440 80 80 #include "MediaCanStartListener.h" 81 81 #include "MediaRecorderProvider.h" 82 #include "MediaStreamTrack.h"83 82 #include "Navigator.h" 84 83 #include "PageConfiguration.h" … … 2076 2075 } 2077 2076 2078 void Page::beginAudioCaptureInterruption()2079 {2080 #if ENABLE(MEDIA_STREAM)2081 forEachDocument([mutedState = mutedState()](auto& document) {2082 MediaStreamTrack::updateCaptureAccordingToMutedState(document, mutedState | MediaProducer::AudioAndVideoCaptureIsMuted);2083 });2084 #endif2085 }2086 2087 void Page::endAudioCaptureInterruption()2088 {2089 #if ENABLE(MEDIA_STREAM)2090 forEachDocument([mutedState = mutedState()](auto& document) {2091 MediaStreamTrack::updateCaptureAccordingToMutedState(document, mutedState);2092 });2093 #endif2094 }2095 2096 2077 bool Page::mediaPlaybackExists() 2097 2078 { -
trunk/Source/WebCore/page/Page.h
r271401 r271440 832 832 void setTextInteractionEnabled(bool value) { m_textInteractionEnabled = value; } 833 833 834 WEBCORE_EXPORT void beginAudioCaptureInterruption();835 WEBCORE_EXPORT void endAudioCaptureInterruption();836 837 834 private: 838 835 struct Navigation { -
trunk/Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.cpp
r271401 r271440 184 184 reconfigure(); 185 185 } 186 187 ASSERT(!m_producingCount); 188 189 forEachClient([](auto& client) { 190 client.setMuted(false); 191 }); 192 186 193 return 0; 187 194 } … … 195 202 m_suspended = true; 196 203 stopInternal(); 204 205 forEachClient([](auto& client) { 206 client.setMuted(true); 207 }); 208 209 ASSERT(!m_producingCount); 210 197 211 return 0; 198 212 } -
trunk/Source/WebCore/testing/Internals.cpp
r271414 r271440 5279 5279 void Internals::setMediaStreamSourceInterrupted(MediaStreamTrack& track, bool interrupted) 5280 5280 { 5281 auto* document = contextDocument();5282 auto* page = document ? document->page() : nullptr;5283 if (!page)5284 return;5285 5286 5281 track.source().setInterruptedForTesting(interrupted); 5287 if (interrupted)5288 page->beginAudioCaptureInterruption();5289 else5290 page->endAudioCaptureInterruption();5291 5282 } 5292 5283 -
trunk/Source/WebKit/ChangeLog
r271424 r271440 1 2021-01-13 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, reverting r271401. 4 https://bugs.webkit.org/show_bug.cgi?id=220591 5 6 It is breaking iOS audio rendering 7 8 Reverted changeset: 9 10 "Unmuting a track in case of end of interruption by another 11 web process tab is not working well with capture muting icons" 12 https://bugs.webkit.org/show_bug.cgi?id=220058 13 https://trac.webkit.org/changeset/271401 14 1 15 2021-01-12 BJ Burg <bburg@apple.com> 2 16 -
trunk/Source/WebKit/WebProcess/WebProcess.cpp
r271401 r271440 1815 1815 void WebProcess::revokeUserMediaDeviceSandboxExtensions(const Vector<String>& extensionIDs) 1816 1816 { 1817 if (!MockRealtimeMediaSourceCenter::mockRealtimeMediaSourceCenterEnabled()) 1818 checkDocumentsCaptureStateConsistency(extensionIDs); 1817 checkDocumentsCaptureStateConsistency(extensionIDs); 1819 1818 1820 1819 for (const auto& extensionID : extensionIDs) { -
trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm
r271401 r271440 55 55 #import <WebCore/AVAssetMIMETypeCache.h> 56 56 #import <WebCore/AXObjectCache.h> 57 #import <WebCore/AudioSession.h>58 57 #import <WebCore/CPUMonitor.h> 59 58 #import <WebCore/DisplayRefreshMonitorManager.h> … … 172 171 #endif 173 172 174 #if PLATFORM(IOS)175 static void listenToAudioSessionInterruption();176 #endif177 178 173 void WebProcess::platformSetCacheModel(CacheModel) 179 174 { … … 412 407 413 408 WebCore::IOSurface::setMaximumSize(parameters.maximumIOSurfaceSize); 414 415 #if PLATFORM(IOS)416 listenToAudioSessionInterruption();417 #endif418 409 } 419 410 … … 1187 1178 } 1188 1179 1189 #if PLATFORM(IOS)1190 class PageAudioSessionInterruptionObserver : public AudioSession::InterruptionObserver {1191 public:1192 PageAudioSessionInterruptionObserver();1193 ~PageAudioSessionInterruptionObserver();1194 1195 private:1196 void beginAudioSessionInterruption() final;1197 void endAudioSessionInterruption(WebCore::AudioSession::MayResume) final;1198 };1199 1200 PageAudioSessionInterruptionObserver::PageAudioSessionInterruptionObserver()1201 {1202 AudioSession::sharedSession().addInterruptionObserver(*this);1203 }1204 1205 PageAudioSessionInterruptionObserver::~PageAudioSessionInterruptionObserver()1206 {1207 AudioSession::sharedSession().removeInterruptionObserver(*this);1208 }1209 1210 void PageAudioSessionInterruptionObserver::beginAudioSessionInterruption()1211 {1212 Page::forEachPage([](auto& page) {1213 page.beginAudioCaptureInterruption();1214 });1215 }1216 1217 void PageAudioSessionInterruptionObserver::endAudioSessionInterruption(AudioSession::MayResume mayResume)1218 {1219 if (mayResume == AudioSession::MayResume::No)1220 return;1221 Page::forEachPage([](auto& page) {1222 page.endAudioCaptureInterruption();1223 });1224 }1225 1226 void listenToAudioSessionInterruption()1227 {1228 static NeverDestroyed<PageAudioSessionInterruptionObserver> observer;1229 }1230 #endif1231 1232 1180 } // namespace WebKit 1233 1181
Note:
See TracChangeset
for help on using the changeset viewer.