⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 271440 in webkit


Ignore:
Timestamp:
Jan 13, 2021, 7:53:27 AM (6 years ago)
Author:
commit-queue@webkit.org
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

Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r271439 r271440  
     12021-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
    1152021-01-13  Martin Robinson  <mrobinson@igalia.com>
    216
  • trunk/LayoutTests/fast/mediastream/media-stream-track-interrupted.html

    r271401 r271440  
    5151    function testTrack(track, title)
    5252    {
    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) => {
    5855                let isVideo = track.kind == "video";
    5956                if (window.internals) {
     
    7168                            waitForPageStateChange(10, pageState, resolve, reject)
    7269                        }
     70
    7371                        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'));
    7676                            pageState = internals.pageMediaState();
    7777                            internals.setMediaStreamSourceInterrupted(track, false)
     
    8686                setTimeout(() => reject("Muted state did not change in 1 second"), 1000);
    8787            });
    88             track.onmute = () => { };
    89             track.onunmute = () => { };
    9088        }, title);
    9189    }
  • trunk/Source/WebCore/ChangeLog

    r271439 r271440  
     12021-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
    1152021-01-13  Martin Robinson  <mrobinson@igalia.com>
    216
  • trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp

    r271401 r271440  
    7272    track->suspendIfNeeded();
    7373
    74     if (track->isCaptureTrack()) {
    75         if (auto* page = track->document()->page())
    76             track->updateToPageMutedState(page->mutedState());
    77     }
     74    if (track->isCaptureTrack())
     75        track->updateToPageMutedState();
    7876
    7977    return track;
     
    472470#endif
    473471
    474 void MediaStreamTrack::updateCaptureAccordingToMutedState(Document& document, MediaProducer::MutedStateFlags mutedState)
     472void MediaStreamTrack::updateCaptureAccordingToMutedState(Document& document)
    475473{
    476474#if PLATFORM(IOS_FAMILY)
     
    479477        return;
    480478
    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     };
    494479    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;
    496482        activeAudioSource->setMuted(pageMuted || (document.hidden() && document.settings().interruptAudioOnPageVisibilityChangeEnabled()));
    497     else
    498         updateTracksAccordingPageMutedState(document, CaptureDevice::DeviceType::Microphone, pageMuted);
     483    }
    499484
    500485    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;
    502488        activeVideoSource->setMuted(pageMuted || document.hidden());
    503     else
    504         updateTracksAccordingPageMutedState(document, CaptureDevice::DeviceType::Camera, pageMuted);
     489    }
    505490#else
    506491    for (auto* captureTrack : allCaptureTracks()) {
    507492        if (captureTrack->document() == &document && !captureTrack->ended())
    508             captureTrack->updateToPageMutedState(mutedState);
     493            captureTrack->updateToPageMutedState();
    509494    }
    510495#endif
    511496}
    512497
    513 void MediaStreamTrack::updateToPageMutedState(MediaProducer::MutedStateFlags mutedState)
     498void MediaStreamTrack::updateToPageMutedState()
    514499{
    515500    ASSERT(isCaptureTrack());
     501    auto* page = document()->page();
     502    if (!page)
     503        return;
    516504
    517505    switch (source().deviceType()) {
    518506    case CaptureDevice::DeviceType::Microphone:
    519507    case CaptureDevice::DeviceType::Camera:
    520         m_private->setMuted(mutedState & MediaProducer::AudioAndVideoCaptureIsMuted);
     508        m_private->setMuted(page->mutedState() & MediaProducer::AudioAndVideoCaptureIsMuted);
    521509        break;
    522510    case CaptureDevice::DeviceType::Screen:
    523511    case CaptureDevice::DeviceType::Window:
    524         m_private->setMuted(mutedState & MediaProducer::ScreenCaptureIsMuted);
     512        m_private->setMuted(page->mutedState() & MediaProducer::ScreenCaptureIsMuted);
    525513        break;
    526514    case CaptureDevice::DeviceType::Speaker:
  • trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.h

    r271401 r271440  
    7373
    7474    static MediaProducer::MediaStateFlags captureState(Document&);
    75     static void updateCaptureAccordingToMutedState(Document&, MediaProducer::MutedStateFlags);
     75    static void updateCaptureAccordingToMutedState(Document&);
    7676
    7777    virtual bool isCanvas() const { return false; }
     
    170170
    171171    void configureTrackRendering();
    172     void updateToPageMutedState(MediaProducer::MutedStateFlags);
     172    void updateToPageMutedState();
    173173
    174174    // ActiveDOMObject API.
  • trunk/Source/WebCore/dom/Document.cpp

    r271433 r271440  
    18101810
    18111811#if ENABLE(MEDIA_STREAM) && PLATFORM(IOS_FAMILY)
    1812     auto* page = this->page();
    1813     if (!page)
    1814         return;
    1815 
    18161812    if (auto mediaSessionManager = PlatformMediaSessionManager::sharedManagerIfExists()) {
    18171813        if (!mediaSessionManager->isInterrupted())
    1818             MediaStreamTrack::updateCaptureAccordingToMutedState(*this, page->mutedState());
     1814            MediaStreamTrack::updateCaptureAccordingToMutedState(*this);
    18191815    }
    18201816#endif
     
    43024298
    43034299#if ENABLE(MEDIA_STREAM)
    4304     MediaStreamTrack::updateCaptureAccordingToMutedState(*this, page()->mutedState());
     4300    MediaStreamTrack::updateCaptureAccordingToMutedState(*this);
    43054301#endif
    43064302}
  • trunk/Source/WebCore/page/Page.cpp

    r271401 r271440  
    8080#include "MediaCanStartListener.h"
    8181#include "MediaRecorderProvider.h"
    82 #include "MediaStreamTrack.h"
    8382#include "Navigator.h"
    8483#include "PageConfiguration.h"
     
    20762075}
    20772076
    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 #endif
    2085 }
    2086 
    2087 void Page::endAudioCaptureInterruption()
    2088 {
    2089 #if ENABLE(MEDIA_STREAM)
    2090     forEachDocument([mutedState = mutedState()](auto& document) {
    2091         MediaStreamTrack::updateCaptureAccordingToMutedState(document, mutedState);
    2092     });
    2093 #endif
    2094 }
    2095 
    20962077bool Page::mediaPlaybackExists()
    20972078{
  • trunk/Source/WebCore/page/Page.h

    r271401 r271440  
    832832    void setTextInteractionEnabled(bool value) { m_textInteractionEnabled = value; }
    833833
    834     WEBCORE_EXPORT void beginAudioCaptureInterruption();
    835     WEBCORE_EXPORT void endAudioCaptureInterruption();
    836 
    837834private:
    838835    struct Navigation {
  • trunk/Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.cpp

    r271401 r271440  
    184184        reconfigure();
    185185    }
     186
     187    ASSERT(!m_producingCount);
     188
     189    forEachClient([](auto& client) {
     190        client.setMuted(false);
     191    });
     192
    186193    return 0;
    187194}
     
    195202    m_suspended = true;
    196203    stopInternal();
     204
     205    forEachClient([](auto& client) {
     206        client.setMuted(true);
     207    });
     208
     209    ASSERT(!m_producingCount);
     210
    197211    return 0;
    198212}
  • trunk/Source/WebCore/testing/Internals.cpp

    r271414 r271440  
    52795279void Internals::setMediaStreamSourceInterrupted(MediaStreamTrack& track, bool interrupted)
    52805280{
    5281     auto* document = contextDocument();
    5282     auto* page = document ? document->page() : nullptr;
    5283     if (!page)
    5284         return;
    5285 
    52865281    track.source().setInterruptedForTesting(interrupted);
    5287     if (interrupted)
    5288         page->beginAudioCaptureInterruption();
    5289     else
    5290         page->endAudioCaptureInterruption();
    52915282}
    52925283
  • trunk/Source/WebKit/ChangeLog

    r271424 r271440  
     12021-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
    1152021-01-12  BJ Burg  <bburg@apple.com>
    216
  • trunk/Source/WebKit/WebProcess/WebProcess.cpp

    r271401 r271440  
    18151815void WebProcess::revokeUserMediaDeviceSandboxExtensions(const Vector<String>& extensionIDs)
    18161816{
    1817     if (!MockRealtimeMediaSourceCenter::mockRealtimeMediaSourceCenterEnabled())
    1818         checkDocumentsCaptureStateConsistency(extensionIDs);
     1817    checkDocumentsCaptureStateConsistency(extensionIDs);
    18191818
    18201819    for (const auto& extensionID : extensionIDs) {
  • trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm

    r271401 r271440  
    5555#import <WebCore/AVAssetMIMETypeCache.h>
    5656#import <WebCore/AXObjectCache.h>
    57 #import <WebCore/AudioSession.h>
    5857#import <WebCore/CPUMonitor.h>
    5958#import <WebCore/DisplayRefreshMonitorManager.h>
     
    172171#endif
    173172
    174 #if PLATFORM(IOS)
    175 static void listenToAudioSessionInterruption();
    176 #endif
    177 
    178173void WebProcess::platformSetCacheModel(CacheModel)
    179174{
     
    412407
    413408    WebCore::IOSurface::setMaximumSize(parameters.maximumIOSurfaceSize);
    414 
    415 #if PLATFORM(IOS)
    416     listenToAudioSessionInterruption();
    417 #endif
    418409}
    419410
     
    11871178}
    11881179
    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 #endif
    1231 
    12321180} // namespace WebKit
    12331181
Note: See TracChangeset for help on using the changeset viewer.