Title: [271440] trunk
Revision
271440
Author
[email protected]
Date
2021-01-13 07:53:27 -0800 (Wed, 13 Jan 2021)

Log Message

Unreviewed, reverting r271401.
https://bugs.webkit.org/show_bug.cgi?id=220591

It is breaking iOS audio rendering

Reverted changeset:

"Unmuting a track in case of end of interruption by another
web process tab is not working well with capture muting icons"
https://bugs.webkit.org/show_bug.cgi?id=220058
https://trac.webkit.org/changeset/271401

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (271439 => 271440)


--- trunk/LayoutTests/ChangeLog	2021-01-13 14:18:03 UTC (rev 271439)
+++ trunk/LayoutTests/ChangeLog	2021-01-13 15:53:27 UTC (rev 271440)
@@ -1,3 +1,17 @@
+2021-01-13  Commit Queue  <[email protected]>
+
+        Unreviewed, reverting r271401.
+        https://bugs.webkit.org/show_bug.cgi?id=220591
+
+        It is breaking iOS audio rendering
+
+        Reverted changeset:
+
+        "Unmuting a track in case of end of interruption by another
+        web process tab is not working well with capture muting icons"
+        https://bugs.webkit.org/show_bug.cgi?id=220058
+        https://trac.webkit.org/changeset/271401
+
 2021-01-13  Martin Robinson  <[email protected]>
 
         Scroll-snap points should be triggered during programmatic scroll

Modified: trunk/LayoutTests/fast/mediastream/media-stream-track-interrupted.html (271439 => 271440)


--- trunk/LayoutTests/fast/mediastream/media-stream-track-interrupted.html	2021-01-13 14:18:03 UTC (rev 271439)
+++ trunk/LayoutTests/fast/mediastream/media-stream-track-interrupted.html	2021-01-13 15:53:27 UTC (rev 271440)
@@ -50,11 +50,8 @@
 
     function testTrack(track, title)
     {
-        promise_test(async (test) => {
-            if (track.muted)
-                await new Promise(resolve => track._onunmute_ = resolve);
-
-            await new Promise((resolve, reject) => {
+        promise_test((test) => {
+            return new Promise((resolve, reject) => {
                 let isVideo = track.kind == "video";
                 if (window.internals) {
                     assert_false(internals.pageMediaState().includes('HasMutedVideoCaptureDevice'));
@@ -70,9 +67,12 @@
                         track._onunmute_ = (evt) => {
                             waitForPageStateChange(10, pageState, resolve, reject)
                         }
+
                         if (window.internals) {
-                            assert_true(pageMediaState.includes('HasMutedAudioCaptureDevice'), 'audio muted');
-                            assert_true(pageMediaState.includes('HasMutedVideoCaptureDevice'), 'video muted');
+                            assert_true(pageMediaState.includes(isVideo ? 'HasMutedVideoCaptureDevice' : 'HasMutedAudioCaptureDevice'));
+                            assert_false(pageMediaState.includes(isVideo ? 'HasMutedAudioCaptureDevice' : 'HasMutedVideoCaptureDevice'));
+                            assert_true(pageMediaState.includes(isVideo ? 'HasActiveAudioCaptureDevice' : 'HasActiveVideoCaptureDevice'));
+                            assert_false(pageMediaState.includes(isVideo ? 'HasActiveVideoCaptureDevice' : 'HasActiveAudioCaptureDevice'));
                             pageState = internals.pageMediaState();
                             internals.setMediaStreamSourceInterrupted(track, false)
                         }
@@ -85,8 +85,6 @@
                 }
                 setTimeout(() => reject("Muted state did not change in 1 second"), 1000);
             });
-            track._onmute_ = () => { };
-            track._onunmute_ = () => { };
         }, title);
     }
 

Modified: trunk/Source/WebCore/ChangeLog (271439 => 271440)


--- trunk/Source/WebCore/ChangeLog	2021-01-13 14:18:03 UTC (rev 271439)
+++ trunk/Source/WebCore/ChangeLog	2021-01-13 15:53:27 UTC (rev 271440)
@@ -1,3 +1,17 @@
+2021-01-13  Commit Queue  <[email protected]>
+
+        Unreviewed, reverting r271401.
+        https://bugs.webkit.org/show_bug.cgi?id=220591
+
+        It is breaking iOS audio rendering
+
+        Reverted changeset:
+
+        "Unmuting a track in case of end of interruption by another
+        web process tab is not working well with capture muting icons"
+        https://bugs.webkit.org/show_bug.cgi?id=220058
+        https://trac.webkit.org/changeset/271401
+
 2021-01-13  Martin Robinson  <[email protected]>
 
         Scroll-snap points should be triggered during programmatic scroll

Modified: trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp (271439 => 271440)


--- trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp	2021-01-13 14:18:03 UTC (rev 271439)
+++ trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp	2021-01-13 15:53:27 UTC (rev 271440)
@@ -71,10 +71,8 @@
     auto track = adoptRef(*new MediaStreamTrack(context, WTFMove(privateTrack)));
     track->suspendIfNeeded();
 
-    if (track->isCaptureTrack()) {
-        if (auto* page = track->document()->page())
-            track->updateToPageMutedState(page->mutedState());
-    }
+    if (track->isCaptureTrack())
+        track->updateToPageMutedState();
 
     return track;
 }
@@ -471,7 +469,7 @@
 }
 #endif
 
-void MediaStreamTrack::updateCaptureAccordingToMutedState(Document& document, MediaProducer::MutedStateFlags mutedState)
+void MediaStreamTrack::updateCaptureAccordingToMutedState(Document& document)
 {
 #if PLATFORM(IOS_FAMILY)
     auto* page = document.page();
@@ -478,50 +476,40 @@
     if (!page)
         return;
 
-    bool pageMuted = mutedState & MediaProducer::AudioAndVideoCaptureIsMuted;
-
-    auto updateTracksAccordingPageMutedState = [](const Document& document, CaptureDevice::DeviceType deviceType, bool pageMuted) {
-        // We can only have one source at a time: we can mute all tracks but unmute only one of them.
-        for (auto* captureTrack : allCaptureTracks()) {
-            if (captureTrack->document() != &document || captureTrack->ended() || captureTrack->source().deviceType() != deviceType)
-                continue;
-            captureTrack->m_private->setMuted(pageMuted);
-            // If unmuting, unmute the first source of the document we know.
-            if (!pageMuted)
-                break;
-        }
-    };
     auto* activeAudioSource = RealtimeMediaSourceCenter::singleton().audioCaptureFactory().activeSource();
-    if (activeAudioSource && isSourceCapturingForTrackInDocument(*activeAudioSource, document))
+    if (activeAudioSource && isSourceCapturingForTrackInDocument(*activeAudioSource, document)) {
+        bool pageMuted = page->mutedState() & MediaProducer::AudioAndVideoCaptureIsMuted;
         activeAudioSource->setMuted(pageMuted || (document.hidden() && document.settings().interruptAudioOnPageVisibilityChangeEnabled()));
-    else
-        updateTracksAccordingPageMutedState(document, CaptureDevice::DeviceType::Microphone, pageMuted);
+    }
 
     auto* activeVideoSource = RealtimeMediaSourceCenter::singleton().videoCaptureFactory().activeSource();
-    if (activeVideoSource && isSourceCapturingForTrackInDocument(*activeVideoSource, document))
+    if (activeVideoSource && isSourceCapturingForTrackInDocument(*activeVideoSource, document)) {
+        bool pageMuted = page->mutedState() & MediaProducer::AudioAndVideoCaptureIsMuted;
         activeVideoSource->setMuted(pageMuted || document.hidden());
-    else
-        updateTracksAccordingPageMutedState(document, CaptureDevice::DeviceType::Camera, pageMuted);
+    }
 #else
     for (auto* captureTrack : allCaptureTracks()) {
         if (captureTrack->document() == &document && !captureTrack->ended())
-            captureTrack->updateToPageMutedState(mutedState);
+            captureTrack->updateToPageMutedState();
     }
 #endif
 }
 
-void MediaStreamTrack::updateToPageMutedState(MediaProducer::MutedStateFlags mutedState)
+void MediaStreamTrack::updateToPageMutedState()
 {
     ASSERT(isCaptureTrack());
+    auto* page = document()->page();
+    if (!page)
+        return;
 
     switch (source().deviceType()) {
     case CaptureDevice::DeviceType::Microphone:
     case CaptureDevice::DeviceType::Camera:
-        m_private->setMuted(mutedState & MediaProducer::AudioAndVideoCaptureIsMuted);
+        m_private->setMuted(page->mutedState() & MediaProducer::AudioAndVideoCaptureIsMuted);
         break;
     case CaptureDevice::DeviceType::Screen:
     case CaptureDevice::DeviceType::Window:
-        m_private->setMuted(mutedState & MediaProducer::ScreenCaptureIsMuted);
+        m_private->setMuted(page->mutedState() & MediaProducer::ScreenCaptureIsMuted);
         break;
     case CaptureDevice::DeviceType::Speaker:
     case CaptureDevice::DeviceType::Unknown:

Modified: trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.h (271439 => 271440)


--- trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.h	2021-01-13 14:18:03 UTC (rev 271439)
+++ trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.h	2021-01-13 15:53:27 UTC (rev 271440)
@@ -72,7 +72,7 @@
     static void endCapture(Document&);
 
     static MediaProducer::MediaStateFlags captureState(Document&);
-    static void updateCaptureAccordingToMutedState(Document&, MediaProducer::MutedStateFlags);
+    static void updateCaptureAccordingToMutedState(Document&);
 
     virtual bool isCanvas() const { return false; }
 
@@ -169,7 +169,7 @@
     explicit MediaStreamTrack(MediaStreamTrack&);
 
     void configureTrackRendering();
-    void updateToPageMutedState(MediaProducer::MutedStateFlags);
+    void updateToPageMutedState();
 
     // ActiveDOMObject API.
     void stop() final { stopTrack(); }

Modified: trunk/Source/WebCore/dom/Document.cpp (271439 => 271440)


--- trunk/Source/WebCore/dom/Document.cpp	2021-01-13 14:18:03 UTC (rev 271439)
+++ trunk/Source/WebCore/dom/Document.cpp	2021-01-13 15:53:27 UTC (rev 271440)
@@ -1809,13 +1809,9 @@
         client->visibilityStateChanged();
 
 #if ENABLE(MEDIA_STREAM) && PLATFORM(IOS_FAMILY)
-    auto* page = this->page();
-    if (!page)
-        return;
-
     if (auto mediaSessionManager = PlatformMediaSessionManager::sharedManagerIfExists()) {
         if (!mediaSessionManager->isInterrupted())
-            MediaStreamTrack::updateCaptureAccordingToMutedState(*this, page->mutedState());
+            MediaStreamTrack::updateCaptureAccordingToMutedState(*this);
     }
 #endif
 }
@@ -4301,7 +4297,7 @@
         audioProducer.pageMutedStateDidChange();
 
 #if ENABLE(MEDIA_STREAM)
-    MediaStreamTrack::updateCaptureAccordingToMutedState(*this, page()->mutedState());
+    MediaStreamTrack::updateCaptureAccordingToMutedState(*this);
 #endif
 }
 

Modified: trunk/Source/WebCore/page/Page.cpp (271439 => 271440)


--- trunk/Source/WebCore/page/Page.cpp	2021-01-13 14:18:03 UTC (rev 271439)
+++ trunk/Source/WebCore/page/Page.cpp	2021-01-13 15:53:27 UTC (rev 271440)
@@ -79,7 +79,6 @@
 #include "LowPowerModeNotifier.h"
 #include "MediaCanStartListener.h"
 #include "MediaRecorderProvider.h"
-#include "MediaStreamTrack.h"
 #include "Navigator.h"
 #include "PageConfiguration.h"
 #include "PageConsoleClient.h"
@@ -2075,24 +2074,6 @@
 #endif
 }
 
-void Page::beginAudioCaptureInterruption()
-{
-#if ENABLE(MEDIA_STREAM)
-    forEachDocument([mutedState = mutedState()](auto& document) {
-        MediaStreamTrack::updateCaptureAccordingToMutedState(document, mutedState | MediaProducer::AudioAndVideoCaptureIsMuted);
-    });
-#endif
-}
-
-void Page::endAudioCaptureInterruption()
-{
-#if ENABLE(MEDIA_STREAM)
-    forEachDocument([mutedState = mutedState()](auto& document) {
-        MediaStreamTrack::updateCaptureAccordingToMutedState(document, mutedState);
-    });
-#endif
-}
-
 bool Page::mediaPlaybackExists()
 {
 #if ENABLE(VIDEO)

Modified: trunk/Source/WebCore/page/Page.h (271439 => 271440)


--- trunk/Source/WebCore/page/Page.h	2021-01-13 14:18:03 UTC (rev 271439)
+++ trunk/Source/WebCore/page/Page.h	2021-01-13 15:53:27 UTC (rev 271440)
@@ -831,9 +831,6 @@
     bool textInteractionEnabled() { return m_textInteractionEnabled; }
     void setTextInteractionEnabled(bool value) { m_textInteractionEnabled = value; }
 
-    WEBCORE_EXPORT void beginAudioCaptureInterruption();
-    WEBCORE_EXPORT void endAudioCaptureInterruption();
-
 private:
     struct Navigation {
         RegistrableDomain domain;

Modified: trunk/Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.cpp (271439 => 271440)


--- trunk/Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.cpp	2021-01-13 14:18:03 UTC (rev 271439)
+++ trunk/Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.cpp	2021-01-13 15:53:27 UTC (rev 271440)
@@ -183,6 +183,13 @@
         m_needsReconfiguration = false;
         reconfigure();
     }
+
+    ASSERT(!m_producingCount);
+
+    forEachClient([](auto& client) {
+        client.setMuted(false);
+    });
+
     return 0;
 }
 
@@ -194,6 +201,13 @@
 
     m_suspended = true;
     stopInternal();
+
+    forEachClient([](auto& client) {
+        client.setMuted(true);
+    });
+
+    ASSERT(!m_producingCount);
+
     return 0;
 }
 

Modified: trunk/Source/WebCore/testing/Internals.cpp (271439 => 271440)


--- trunk/Source/WebCore/testing/Internals.cpp	2021-01-13 14:18:03 UTC (rev 271439)
+++ trunk/Source/WebCore/testing/Internals.cpp	2021-01-13 15:53:27 UTC (rev 271440)
@@ -5278,16 +5278,7 @@
 
 void Internals::setMediaStreamSourceInterrupted(MediaStreamTrack& track, bool interrupted)
 {
-    auto* document = contextDocument();
-    auto* page = document ? document->page() : nullptr;
-    if (!page)
-        return;
-
     track.source().setInterruptedForTesting(interrupted);
-    if (interrupted)
-        page->beginAudioCaptureInterruption();
-    else
-        page->endAudioCaptureInterruption();
 }
 
 bool Internals::isMediaStreamSourceInterrupted(MediaStreamTrack& track) const

Modified: trunk/Source/WebKit/ChangeLog (271439 => 271440)


--- trunk/Source/WebKit/ChangeLog	2021-01-13 14:18:03 UTC (rev 271439)
+++ trunk/Source/WebKit/ChangeLog	2021-01-13 15:53:27 UTC (rev 271440)
@@ -1,3 +1,17 @@
+2021-01-13  Commit Queue  <[email protected]>
+
+        Unreviewed, reverting r271401.
+        https://bugs.webkit.org/show_bug.cgi?id=220591
+
+        It is breaking iOS audio rendering
+
+        Reverted changeset:
+
+        "Unmuting a track in case of end of interruption by another
+        web process tab is not working well with capture muting icons"
+        https://bugs.webkit.org/show_bug.cgi?id=220058
+        https://trac.webkit.org/changeset/271401
+
 2021-01-12  BJ Burg  <[email protected]>
 
         [Cocoa] Web Inspector: move browser domain activation methods back to WKWebView and UIDelegate

Modified: trunk/Source/WebKit/WebProcess/WebProcess.cpp (271439 => 271440)


--- trunk/Source/WebKit/WebProcess/WebProcess.cpp	2021-01-13 14:18:03 UTC (rev 271439)
+++ trunk/Source/WebKit/WebProcess/WebProcess.cpp	2021-01-13 15:53:27 UTC (rev 271440)
@@ -1814,8 +1814,7 @@
 
 void WebProcess::revokeUserMediaDeviceSandboxExtensions(const Vector<String>& extensionIDs)
 {
-    if (!MockRealtimeMediaSourceCenter::mockRealtimeMediaSourceCenterEnabled())
-        checkDocumentsCaptureStateConsistency(extensionIDs);
+    checkDocumentsCaptureStateConsistency(extensionIDs);
 
     for (const auto& extensionID : extensionIDs) {
         auto extension = m_mediaCaptureSandboxExtensions.take(extensionID);

Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (271439 => 271440)


--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2021-01-13 14:18:03 UTC (rev 271439)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2021-01-13 15:53:27 UTC (rev 271440)
@@ -54,7 +54,6 @@
 #import <_javascript_Core/Options.h>
 #import <WebCore/AVAssetMIMETypeCache.h>
 #import <WebCore/AXObjectCache.h>
-#import <WebCore/AudioSession.h>
 #import <WebCore/CPUMonitor.h>
 #import <WebCore/DisplayRefreshMonitorManager.h>
 #import <WebCore/FontCache.h>
@@ -171,10 +170,6 @@
 static const double serviceWorkerCPULimit { 0.5 }; // 50% average CPU usage over 8 minutes.
 #endif
 
-#if PLATFORM(IOS)
-static void listenToAudioSessionInterruption();
-#endif
-
 void WebProcess::platformSetCacheModel(CacheModel)
 {
 }
@@ -411,10 +406,6 @@
 #endif
 
     WebCore::IOSurface::setMaximumSize(parameters.maximumIOSurfaceSize);
-
-#if PLATFORM(IOS)
-    listenToAudioSessionInterruption();
-#endif
 }
 
 void WebProcess::platformSetWebsiteDataStoreParameters(WebProcessDataStoreParameters&& parameters)
@@ -1186,49 +1177,6 @@
     }
 }
 
-#if PLATFORM(IOS)
-class PageAudioSessionInterruptionObserver : public AudioSession::InterruptionObserver {
-public:
-    PageAudioSessionInterruptionObserver();
-    ~PageAudioSessionInterruptionObserver();
-
-private:
-    void beginAudioSessionInterruption() final;
-    void endAudioSessionInterruption(WebCore::AudioSession::MayResume) final;
-};
-
-PageAudioSessionInterruptionObserver::PageAudioSessionInterruptionObserver()
-{
-    AudioSession::sharedSession().addInterruptionObserver(*this);
-}
-
-PageAudioSessionInterruptionObserver::~PageAudioSessionInterruptionObserver()
-{
-    AudioSession::sharedSession().removeInterruptionObserver(*this);
-}
-
-void PageAudioSessionInterruptionObserver::beginAudioSessionInterruption()
-{
-    Page::forEachPage([](auto& page) {
-        page.beginAudioCaptureInterruption();
-    });
-}
-
-void PageAudioSessionInterruptionObserver::endAudioSessionInterruption(AudioSession::MayResume mayResume)
-{
-    if (mayResume == AudioSession::MayResume::No)
-        return;
-    Page::forEachPage([](auto& page) {
-        page.endAudioCaptureInterruption();
-    });
-}
-
-void listenToAudioSessionInterruption()
-{
-    static NeverDestroyed<PageAudioSessionInterruptionObserver> observer;
-}
-#endif
-
 } // namespace WebKit
 
 #undef RELEASE_LOG_SESSION_ID
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to