WebKit Bugzilla
Attachment 370986 Details for
Bug 198307
: Add an option to mute audio capture automatically when page is not visible
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for landing
bug-198307-20190530154617.patch (text/plain), 33.67 KB, created by
youenn fablet
on 2019-05-30 15:46:18 PDT
(
hide
)
Description:
Patch for landing
Filename:
MIME Type:
Creator:
youenn fablet
Created:
2019-05-30 15:46:18 PDT
Size:
33.67 KB
patch
obsolete
>Subversion Revision: 245886 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 0ef8ff452f56afa9835d52e2e748a6d87ed95b0c..602a0cb210362ef8485d9c7d97bf64758619edab 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,49 @@ >+2019-05-30 Youenn Fablet <youenn@apple.com> >+ >+ Add an option to mute audio capture automatically when page is not visible >+ https://bugs.webkit.org/show_bug.cgi?id=198307 >+ >+ Reviewed by Eric Carlson. >+ >+ Reuse video capture mechanism for audio capture. >+ In case document gets in the background, interrupt the audio track if the audio factory requires it. >+ CoreAudioCaptureSourceIOS requires the audio source be interrupted if the app has not the right background mode. >+ It also allows interrupting the audio capture based on a runtime flag. >+ >+ Add a runtime flag to control this. >+ Internals API is used to set it for test purposes, off by default. >+ For regular cases, the runtime flag is set through web preferences. >+ >+ Test: platform/ios/mediastream/audio-muted-in-background-tab.html >+ >+ * dom/Document.cpp: >+ (WebCore::Document::notifyMediaCaptureOfVisibilityChanged): >+ * page/RuntimeEnabledFeatures.h: >+ (WebCore::RuntimeEnabledFeatures::interruptAudioOnPageVisibilityChangeEnabled const): >+ (WebCore::RuntimeEnabledFeatures::setInterruptAudioOnPageVisibilityChangeEnabled): >+ * platform/mediastream/RealtimeMediaSourceCenter.cpp: >+ (WebCore::RealtimeMediaSourceCenter::RealtimeMediaSourceCenter): >+ (WebCore::RealtimeMediaSourceCenter::initializeShouldInterruptAudioOnPageVisibilityChange): >+ (WebCore::RealtimeMediaSourceCenter::setCapturePageState): >+ (WebCore::RealtimeMediaSourceCenter::visibilityDidChange): >+ * platform/mediastream/RealtimeMediaSourceCenter.h: >+ (WebCore::RealtimeMediaSourceCenter::shouldInterruptAudioOnPageVisibilityChange): >+ * platform/mediastream/RealtimeMediaSourceFactory.h: >+ (WebCore::AudioCaptureFactory::setAudioCapturePageState): >+ (WebCore::VideoCaptureFactory::setVideoCapturePageState): >+ * platform/mediastream/ios/CoreAudioCaptureSourceIOS.h: >+ * platform/mediastream/ios/CoreAudioCaptureSourceIOS.mm: >+ (WebCore::CoreAudioCaptureSourceFactory::setAudioCapturePageState): >+ (WebCore::CoreAudioCaptureSourceFactoryIOS::shouldInterruptAudioOnPageVisibilityChange): >+ * platform/mediastream/mac/CoreAudioCaptureSource.h: >+ * platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp: >+ (WebCore::RealtimeMediaSourceCenter::initializeShouldInterruptAudioOnPageVisibilityChange): >+ * testing/Internals.cpp: >+ (WebCore::Internals::resetToConsistentState): >+ (WebCore::Internals::setShouldInterruptAudioOnPageVisibilityChange): >+ * testing/Internals.h: >+ * testing/Internals.idl: >+ > 2019-05-29 Robin Morisset <rmorisset@apple.com> > > [WHLSL] Parsing and lexing the standard library is slow >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index af3dec7d10c023335565f6b7493a69aa53fc7056..6c84b6baafe3947066adbfab876b05af00e0b9b5 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,23 @@ >+2019-05-30 Youenn Fablet <youenn@apple.com> >+ >+ Add an option to mute audio capture automatically when page is not visible >+ https://bugs.webkit.org/show_bug.cgi?id=198307 >+ >+ Reviewed by Eric Carlson. >+ >+ Add API to set the new runtime flag. >+ Make source proxy factories implement this automatic muting. >+ >+ * Shared/WebPreferences.yaml: >+ * UIProcess/API/Cocoa/WKPreferences.mm: >+ (-[WKPreferences _interruptAudioOnPageVisibilityChangeEnabled]): >+ (-[WKPreferences _setInterruptAudioOnPageVisibilityChangeEnabled:]): >+ * UIProcess/API/Cocoa/WKPreferencesPrivate.h: >+ * WebProcess/cocoa/UserMediaCaptureManager.cpp: >+ (WebKit::UserMediaCaptureManager::setAudioCapturePageState): >+ (WebKit::UserMediaCaptureManager::setVideoCapturePageState): >+ * WebProcess/cocoa/UserMediaCaptureManager.h: >+ > 2019-05-30 Philippe Normand <pnormand@igalia.com> > > Unreviewed, WPE without a11y support build fix. >diff --git a/Source/WebCore/SourcesCocoa.txt b/Source/WebCore/SourcesCocoa.txt >index c081198a172ab2094caa64c2d1a63a94873a844f..bd29e5b48cbd60a92435f3cab1be1b7c8fafbb81 100644 >--- a/Source/WebCore/SourcesCocoa.txt >+++ b/Source/WebCore/SourcesCocoa.txt >@@ -542,6 +542,7 @@ platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp > platform/mediastream/mac/RealtimeIncomingAudioSourceCocoa.cpp > platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm > platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp >+platform/mediastream/mac/RealtimeMediaSourceCenterMac.mm > platform/mediastream/mac/RealtimeOutgoingAudioSourceCocoa.cpp > platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.cpp > platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index c00186322788a119275fff4569a71c952db8e890..f921d79afd2d249349d2cf83095ec4846704d3bc 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -7278,6 +7278,7 @@ > 4162A44F101145AE00DFF3ED /* DedicatedWorkerGlobalScope.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DedicatedWorkerGlobalScope.idl; sourceTree = "<group>"; }; > 4162A4551011464700DFF3ED /* JSDedicatedWorkerGlobalScope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDedicatedWorkerGlobalScope.cpp; sourceTree = "<group>"; }; > 4162A4561011464700DFF3ED /* JSDedicatedWorkerGlobalScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDedicatedWorkerGlobalScope.h; sourceTree = "<group>"; }; >+ 416CE4A4229DF12E00A8A686 /* RealtimeMediaSourceCenterMac.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = RealtimeMediaSourceCenterMac.mm; sourceTree = "<group>"; }; > 416D759F20C6441300D02D2C /* NetworkLoadInformation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkLoadInformation.h; sourceTree = "<group>"; }; > 416E0B37209BC3C2004A95D9 /* FetchIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FetchIdentifier.h; sourceTree = "<group>"; }; > 416E29A5102FA962007FC14E /* WorkerReportingProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkerReportingProxy.h; sourceTree = "<group>"; }; >@@ -15879,6 +15880,7 @@ > 5CDD833A1E4324BB00621E83 /* RealtimeIncomingVideoSourceCocoa.h */, > 5CDD83391E4324BB00621E83 /* RealtimeIncomingVideoSourceCocoa.mm */, > 4A0FFAA31AAF5EF60062803B /* RealtimeMediaSourceCenterMac.cpp */, >+ 416CE4A4229DF12E00A8A686 /* RealtimeMediaSourceCenterMac.mm */, > 41103AA71E39790A00769F14 /* RealtimeOutgoingAudioSourceCocoa.cpp */, > 41103AA81E39790A00769F14 /* RealtimeOutgoingAudioSourceCocoa.h */, > 5CDD833B1E4324BB00621B83 /* RealtimeOutgoingVideoSourceCocoa.cpp */, >@@ -16383,8 +16385,6 @@ > 115CFA9A208BC140001E6991 /* inlineformatting */ = { > isa = PBXGroup; > children = ( >- 6F0CD694229ED32700C5994E /* InlineLine.h */, >- 6F0CD692229ED31900C5994E /* InlineLine.cpp */, > 6FE7DDDD20EC6E8B008B5B4E /* text */, > 6F7CA3C9208C2B2E002F29AB /* InlineFormattingContext.cpp */, > 6F7CA3C8208C2B2E002F29AB /* InlineFormattingContext.h */, >@@ -16395,6 +16395,8 @@ > 1123AFDD209ABBBA00736ACC /* InlineInvalidation.cpp */, > 1123AFDC209ABBBA00736ACC /* InlineInvalidation.h */, > 6FE7CFA02177EEF1005B1573 /* InlineItem.h */, >+ 6F0CD692229ED31900C5994E /* InlineLine.cpp */, >+ 6F0CD694229ED32700C5994E /* InlineLine.h */, > 6FB47E612277425A00C7BCB0 /* InlineLineBox.h */, > 6FE198132178397B00446F08 /* InlineLineBreaker.cpp */, > 6FE198152178397C00446F08 /* InlineLineBreaker.h */, >@@ -28185,7 +28187,6 @@ > 714C7C661FDAD2A100F2BEE1 /* AnimationPlaybackEvent.h in Headers */, > 714C7C671FDAD2A900F2BEE1 /* AnimationPlaybackEventInit.h in Headers */, > 71025ECD1F99F0CE004A250C /* AnimationTimeline.h in Headers */, >- 6F0CD695229ED32700C5994E /* InlineLine.h in Headers */, > 0F580FAF149800D400FB5BD8 /* AnimationUtilities.h in Headers */, > 57152B5A21CB3E88000C37CA /* ApduCommand.h in Headers */, > 57152B5C21CC1902000C37CA /* ApduResponse.h in Headers */, >@@ -29491,6 +29492,7 @@ > 11310CF820BA4A6A0065A8D0 /* InlineInvalidation.h in Headers */, > 6FE7CFA22177EEF2005B1573 /* InlineItem.h in Headers */, > BCE789161120D6080060ECE5 /* InlineIterator.h in Headers */, >+ 6F0CD695229ED32700C5994E /* InlineLine.h in Headers */, > 6FB47E632277425A00C7BCB0 /* InlineLineBox.h in Headers */, > 6FE198172178397C00446F08 /* InlineLineBreaker.h in Headers */, > AA4C3A770B2B1679002334A2 /* InlineStyleSheetOwner.h in Headers */, >diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp >index d8f3a7a09980fe2a9516a436d427848273ffb04d..3da963a6f646fb47cc5eac4eca6c99efb10c424d 100644 >--- a/Source/WebCore/dom/Document.cpp >+++ b/Source/WebCore/dom/Document.cpp >@@ -7633,7 +7633,7 @@ void Document::notifyMediaCaptureOfVisibilityChanged() > if (!page()) > return; > >- RealtimeMediaSourceCenter::singleton().setVideoCapturePageState(hidden(), page()->isMediaCaptureMuted()); >+ RealtimeMediaSourceCenter::singleton().setCapturePageState(hidden(), page()->isMediaCaptureMuted()); > #endif > } > >diff --git a/Source/WebCore/page/RuntimeEnabledFeatures.h b/Source/WebCore/page/RuntimeEnabledFeatures.h >index a40c76249297d56d2c6d2c74ec275f90d6a3ef93..9734f0a7aee5906762680ab777d6b003966ff5d8 100644 >--- a/Source/WebCore/page/RuntimeEnabledFeatures.h >+++ b/Source/WebCore/page/RuntimeEnabledFeatures.h >@@ -357,6 +357,9 @@ public: > bool pageAtRuleSupportEnabled() const { return m_pageAtRuleSupportEnabled; } > void setPageAtRuleSupportEnabled(bool isEnabled) { m_pageAtRuleSupportEnabled = isEnabled; } > >+ bool interruptAudioOnPageVisibilityChangeEnabled() const { return m_interruptAudioOnPageVisibilityChangeEnabled; } >+ void setInterruptAudioOnPageVisibilityChangeEnabled(bool enabled) { m_interruptAudioOnPageVisibilityChangeEnabled = enabled; } >+ > WEBCORE_EXPORT static RuntimeEnabledFeatures& sharedFeatures(); > > private: >@@ -540,6 +543,7 @@ private: > bool m_isITPFirstPartyWebsiteDataRemovalEnabled { false }; > > bool m_referrerPolicyAttributeEnabled { false }; >+ bool m_interruptAudioOnPageVisibilityChangeEnabled { false }; > > friend class WTF::NeverDestroyed<RuntimeEnabledFeatures>; > }; >diff --git a/Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.cpp b/Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.cpp >index 3706fad7ffc03f7ecce6ef38c41b7ae3d2d35338..b53f1f7d76385a5fc4cd3f31ad89ab3c69dc32e1 100644 >--- a/Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.cpp >+++ b/Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.cpp >@@ -38,6 +38,7 @@ > #include "CaptureDeviceManager.h" > #include "Logging.h" > #include "MediaStreamPrivate.h" >+#include "RuntimeEnabledFeatures.h" > #include <wtf/SHA1.h> > > namespace WebCore { >@@ -262,8 +263,10 @@ void RealtimeMediaSourceCenter::validateRequestConstraints(ValidConstraintsHandl > validHandler(WTFMove(audioDevices), WTFMove(videoDevices), WTFMove(deviceIdentifierHashSalt)); > } > >-void RealtimeMediaSourceCenter::setVideoCapturePageState(bool interrupted, bool pageMuted) >+void RealtimeMediaSourceCenter::setCapturePageState(bool interrupted, bool pageMuted) > { >+ if (RuntimeEnabledFeatures::sharedFeatures().interruptAudioOnPageVisibilityChangeEnabled()) >+ audioCaptureFactory().setAudioCapturePageState(interrupted, pageMuted); > videoCaptureFactory().setVideoCapturePageState(interrupted, pageMuted); > } > >@@ -317,6 +320,13 @@ DisplayCaptureFactory& RealtimeMediaSourceCenter::displayCaptureFactory() > return m_displayCaptureFactoryOverride ? *m_displayCaptureFactoryOverride : defaultDisplayCaptureFactory(); > } > >+#if !PLATFORM(COCOA) >+bool RealtimeMediaSourceCenter::shouldInterruptAudioOnPageVisibilityChange() >+{ >+ return false; >+} >+#endif >+ > } // namespace WebCore > > #endif // ENABLE(MEDIA_STREAM) >diff --git a/Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.h b/Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.h >index 3bb2594bb091d3637761db9a4dd1233382169827..37387684a512ee67f622c38838cd6f1a2119c057 100644 >--- a/Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.h >+++ b/Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.h >@@ -86,10 +86,12 @@ public: > > WEBCORE_EXPORT void setDevicesChangedObserver(std::function<void()>&&); > >- void setVideoCapturePageState(bool, bool); >+ void setCapturePageState(bool interrupted, bool pageMuted); > > void captureDevicesChanged(); > >+ WEBCORE_EXPORT static bool shouldInterruptAudioOnPageVisibilityChange(); >+ > private: > RealtimeMediaSourceCenter(); > friend class NeverDestroyed<RealtimeMediaSourceCenter>; >@@ -113,6 +115,8 @@ private: > AudioCaptureFactory* m_audioCaptureFactoryOverride { nullptr }; > VideoCaptureFactory* m_videoCaptureFactoryOverride { nullptr }; > DisplayCaptureFactory* m_displayCaptureFactoryOverride { nullptr }; >+ >+ bool m_shouldInterruptAudioOnPageVisibilityChange { false }; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/platform/mediastream/RealtimeMediaSourceFactory.h b/Source/WebCore/platform/mediastream/RealtimeMediaSourceFactory.h >index 4897c64e9372c2a6bc81938554c982561e20f78c..a3d52f0fcb773634cbf453ff94acea5a1a2fc562 100644 >--- a/Source/WebCore/platform/mediastream/RealtimeMediaSourceFactory.h >+++ b/Source/WebCore/platform/mediastream/RealtimeMediaSourceFactory.h >@@ -57,6 +57,11 @@ public: > virtual ~AudioCaptureFactory() = default; > virtual CaptureSourceOrError createAudioCaptureSource(const CaptureDevice&, String&&, const MediaConstraints*) = 0; > virtual CaptureDeviceManager& audioCaptureDeviceManager() = 0; >+ virtual void setAudioCapturePageState(bool interrupted, bool pageMuted) >+ { >+ UNUSED_PARAM(interrupted); >+ UNUSED_PARAM(pageMuted); >+ } > > protected: > AudioCaptureFactory() = default; >@@ -71,7 +76,11 @@ public: > virtual ~VideoCaptureFactory() = default; > virtual CaptureSourceOrError createVideoCaptureSource(const CaptureDevice&, String&&, const MediaConstraints*) = 0; > virtual CaptureDeviceManager& videoCaptureDeviceManager() = 0; >- virtual void setVideoCapturePageState(bool, bool) { } >+ virtual void setVideoCapturePageState(bool interrupted, bool pageMuted) >+ { >+ UNUSED_PARAM(interrupted); >+ UNUSED_PARAM(pageMuted); >+ } > > protected: > VideoCaptureFactory() = default; >@@ -82,7 +91,6 @@ public: > virtual ~DisplayCaptureFactory() = default; > virtual CaptureSourceOrError createDisplayCaptureSource(const CaptureDevice&, const MediaConstraints*) = 0; > virtual CaptureDeviceManager& displayCaptureDeviceManager() = 0; >- virtual void setDisplayCapturePageState(bool , bool) { } > > protected: > DisplayCaptureFactory() = default; >diff --git a/Source/WebCore/platform/mediastream/ios/CoreAudioCaptureSourceIOS.mm b/Source/WebCore/platform/mediastream/ios/CoreAudioCaptureSourceIOS.mm >index 6fb3dad39c2d9e978dc521b7bb83f699a93253ff..4c8264897aada8d690c31f80756857fee9c97bbd 100644 >--- a/Source/WebCore/platform/mediastream/ios/CoreAudioCaptureSourceIOS.mm >+++ b/Source/WebCore/platform/mediastream/ios/CoreAudioCaptureSourceIOS.mm >@@ -126,6 +126,12 @@ CoreAudioCaptureSourceFactory& CoreAudioCaptureSourceFactory::singleton() > return factory.get(); > } > >+void CoreAudioCaptureSourceFactory::setAudioCapturePageState(bool interrupted, bool pageMuted) >+{ >+ if (auto* activeSource = this->activeSource()) >+ activeSource->setInterrupted(interrupted, pageMuted); >+} >+ > } > > #endif // ENABLE(MEDIA_STREAM) && PLATFORM(IOS_FAMILY) >diff --git a/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.h b/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.h >index 1ab816ca077dd8fe56a97b46c4f3107df2ebae89..adbefe7c025a0fe8138895b018f2269c1a64ac0a 100644 >--- a/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.h >+++ b/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.h >@@ -142,6 +142,9 @@ private: > } > > CaptureDeviceManager& audioCaptureDeviceManager() final; >+#if PLATFORM(IOS_FAMILY) >+ void setAudioCapturePageState(bool interrupted, bool pageMuted) final; >+#endif > }; > > } // namespace WebCore >diff --git a/Source/WebCore/platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp b/Source/WebCore/platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp >index a6a0dab5c0b55d1251937ab0ce46db1dc829f9f9..a328cd3a83ecbfca049e54abf70de9d78faf331b 100644 >--- a/Source/WebCore/platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp >+++ b/Source/WebCore/platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp >@@ -38,6 +38,7 @@ > #include "DisplayCaptureManagerCocoa.h" > #include "Logging.h" > #include "MediaStreamPrivate.h" >+#include "RuntimeEnabledFeatures.h" > #include "ScreenDisplayCaptureSourceMac.h" > #include "WindowDisplayCaptureSourceMac.h" > #include <wtf/MainThread.h> >diff --git a/Source/WebCore/platform/mediastream/mac/RealtimeMediaSourceCenterMac.mm b/Source/WebCore/platform/mediastream/mac/RealtimeMediaSourceCenterMac.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..0aa220abf55955fef68224e3834999719d13e4da >--- /dev/null >+++ b/Source/WebCore/platform/mediastream/mac/RealtimeMediaSourceCenterMac.mm >@@ -0,0 +1,53 @@ >+/* >+ * Copyright (C) 2017 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "RealtimeMediaSourceCenter.h" >+ >+#if ENABLE(MEDIA_STREAM) >+ >+namespace WebCore { >+ >+bool RealtimeMediaSourceCenter::shouldInterruptAudioOnPageVisibilityChange() >+{ >+#if PLATFORM(IOS) >+ NSArray *modes = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UIBackgroundModes"]; >+ if (!modes) >+ return true; >+ >+ int modesCount = [modes count]; >+ for (int i = 0; i < modesCount; i++) { >+ if ([[modes objectAtIndex:i] isEqual: @"audio"]) >+ return false; >+ } >+ return true; >+#else >+ return false; >+#endif >+} >+ >+} // namespace WebCore >+ >+#endif // ENABLE(MEDIA_STREAM) >diff --git a/Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.cpp b/Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.cpp >index 69fad4b415e03fe2fd07af76d475c18e0387ab6d..6d83b5095b5054c43cf9e0fd246e1026d6eae54b 100644 >--- a/Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.cpp >+++ b/Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.cpp >@@ -96,7 +96,7 @@ public: > > private: > #if PLATFORM(IOS_FAMILY) >- void setVideoCapturePageState(bool interrupted, bool pageMuted) >+ void setVideoCapturePageState(bool interrupted, bool pageMuted) final > { > if (activeSource()) > activeSource()->setInterrupted(interrupted, pageMuted); >@@ -139,6 +139,13 @@ public: > return MockRealtimeAudioSource::create(String { device.persistentId() }, String { device.label() }, WTFMove(hashSalt), constraints); > } > private: >+#if PLATFORM(IOS_FAMILY) >+ void setAudioCapturePageState(bool interrupted, bool pageMuted) final >+ { >+ if (activeSource()) >+ activeSource()->setInterrupted(interrupted, pageMuted); >+ } >+#endif > CaptureDeviceManager& audioCaptureDeviceManager() final { return MockRealtimeMediaSourceCenter::singleton().audioCaptureDeviceManager(); } > }; > >diff --git a/Source/WebCore/testing/Internals.cpp b/Source/WebCore/testing/Internals.cpp >index 510ef0d31b6ea420e4ab09bfe81f415a318f2efe..532407f9a97b36c907a9e0fcb9752fadb576f6b7 100644 >--- a/Source/WebCore/testing/Internals.cpp >+++ b/Source/WebCore/testing/Internals.cpp >@@ -531,6 +531,10 @@ void Internals::resetToConsistentState(Page& page) > page.setFullscreenControlsHidden(false); > > MediaEngineConfigurationFactory::disableMock(); >+ >+#if ENABLE(MEDIA_STREAM) >+ RuntimeEnabledFeatures::sharedFeatures().setInterruptAudioOnPageVisibilityChangeEnabled(false); >+#endif > } > > Internals::Internals(Document& document) >@@ -1501,6 +1505,10 @@ void Internals::applyRotationForOutgoingVideoSources(RTCPeerConnection& connecti > #endif > > #if ENABLE(MEDIA_STREAM) >+void Internals::setShouldInterruptAudioOnPageVisibilityChange(bool shouldInterrupt) >+{ >+ RuntimeEnabledFeatures::sharedFeatures().setInterruptAudioOnPageVisibilityChangeEnabled(shouldInterrupt); >+} > > void Internals::setMockMediaCaptureDevicesEnabled(bool enabled) > { >diff --git a/Source/WebCore/testing/Internals.h b/Source/WebCore/testing/Internals.h >index 3ac66f72598030c089f71202b4481308379f7946..895a0eb2912ecbb255374f700b4d74bff0e2fe01 100644 >--- a/Source/WebCore/testing/Internals.h >+++ b/Source/WebCore/testing/Internals.h >@@ -516,6 +516,7 @@ public: > #endif > > #if ENABLE(MEDIA_STREAM) >+ void setShouldInterruptAudioOnPageVisibilityChange(bool); > void setMockMediaCaptureDevicesEnabled(bool); > void setMediaCaptureRequiresSecureConnection(bool); > void setCustomPrivateRecorderCreator(); >diff --git a/Source/WebCore/testing/Internals.idl b/Source/WebCore/testing/Internals.idl >index ca2bc545b3e04a7868c3d48940ae077249d147a7..114e445bc47a59eb6f317ca77a31c4061e679d60 100644 >--- a/Source/WebCore/testing/Internals.idl >+++ b/Source/WebCore/testing/Internals.idl >@@ -672,6 +672,7 @@ enum CompositingPolicy { > [Conditional=WEB_RTC] void setH264HardwareEncoderAllowed(boolean allowed); > [Conditional=WEB_RTC] void applyRotationForOutgoingVideoSources(RTCPeerConnection connection); > >+ [Conditional=MEDIA_STREAM] void setShouldInterruptAudioOnPageVisibilityChange(boolean shouldInterrupt); > [Conditional=MEDIA_STREAM] void setCameraMediaStreamTrackOrientation(MediaStreamTrack track, short orientation); > [Conditional=MEDIA_STREAM] void observeMediaStreamTrack(MediaStreamTrack track); > [Conditional=MEDIA_STREAM] Promise<ImageData> grabNextMediaStreamTrackFrame(); >diff --git a/Source/WebKit/Scripts/PreferencesTemplates/WebPreferencesStoreDefaultsMap.cpp.erb b/Source/WebKit/Scripts/PreferencesTemplates/WebPreferencesStoreDefaultsMap.cpp.erb >index 7825e122844e87f3589cca311dde77fc2b8f1598..17bae3753712efc5d27685bfeda5ad8f994cb508 100644 >--- a/Source/WebKit/Scripts/PreferencesTemplates/WebPreferencesStoreDefaultsMap.cpp.erb >+++ b/Source/WebKit/Scripts/PreferencesTemplates/WebPreferencesStoreDefaultsMap.cpp.erb >@@ -36,6 +36,7 @@ > // FIXME: These should added via options in WebPreferences.yaml, rather than hardcoded. > #include <WebCore/DeprecatedGlobalSettings.h> > #include <WebCore/LibWebRTCProvider.h> >+#include <WebCore/RealtimeMediaSourceCenter.h> > #include <WebCore/SecurityOrigin.h> > #include <WebCore/Settings.h> > #include <WebCore/TextEncodingRegistry.h> >diff --git a/Source/WebKit/Shared/WebPreferences.yaml b/Source/WebKit/Shared/WebPreferences.yaml >index e59efb801cb31ae07dee12253c15715489d8df56..72798c16dfb5377744395ee402b393fb29c43556 100644 >--- a/Source/WebKit/Shared/WebPreferences.yaml >+++ b/Source/WebKit/Shared/WebPreferences.yaml >@@ -545,6 +545,12 @@ PeerConnectionEnabled: > webcoreBinding: RuntimeEnabledFeatures > condition: ENABLE(WEB_RTC) > >+InterruptAudioOnPageVisibilityChangeEnabled: >+ type: bool >+ defaultValue: WebCore::RealtimeMediaSourceCenter::shouldInterruptAudioOnPageVisibilityChange() >+ webcoreBinding: RuntimeEnabledFeatures >+ condition: ENABLE(MEDIA_STREAM) >+ > WebRTCUnifiedPlanEnabled: > type: bool > defaultValue: true >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm b/Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm >index 65384ec1d046e403e0693821dd8e83b1960404f8..df0b0020dbefd0f33f6d7760b6d472630bff4cd8 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm >@@ -649,6 +649,16 @@ static _WKStorageBlockingPolicy toAPI(WebCore::SecurityOrigin::StorageBlockingPo > _preferences->setInactiveMediaCaptureSteamRepromptIntervalInMinutes(interval); > } > >+- (BOOL)_interruptAudioOnPageVisibilityChangeEnabled >+{ >+ return _preferences->interruptAudioOnPageVisibilityChangeEnabled(); >+} >+ >+- (void)_setInterruptAudioOnPageVisibilityChangeEnabled:(BOOL)enabled >+{ >+ _preferences->setInterruptAudioOnPageVisibilityChangeEnabled(enabled); >+} >+ > - (BOOL)_enumeratingAllNetworkInterfacesEnabled > { > return _preferences->enumeratingAllNetworkInterfacesEnabled(); >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h b/Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h >index 077a3932c7a1a4c44d7528968ccb2d16e8b592fb..ef181936cf137e6e18647148f9172eb9292c9e86 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h >@@ -120,6 +120,7 @@ typedef NS_ENUM(NSInteger, _WKEditableLinkBehavior) { > @property (nonatomic, setter=_setICECandidateFilteringEnabled:) BOOL _iceCandidateFilteringEnabled WK_API_AVAILABLE(macos(10.13.4), ios(11.3)); > @property (nonatomic, setter=_setWebRTCLegacyAPIEnabled:) BOOL _webRTCLegacyAPIEnabled WK_API_AVAILABLE(macos(10.13), ios(11.0)); > @property (nonatomic, setter=_setInactiveMediaCaptureSteamRepromptIntervalInMinutes:) double _inactiveMediaCaptureSteamRepromptIntervalInMinutes WK_API_AVAILABLE(macos(10.13.4), ios(11.3)); >+@property (nonatomic, setter=_setInterruptAudioOnPageVisibilityChangeEnabled:) BOOL _interruptAudioOnPageVisibilityChangeEnabled WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); > > @property (nonatomic, setter=_setJavaScriptCanAccessClipboard:) BOOL _javaScriptCanAccessClipboard WK_API_AVAILABLE(macos(10.13), ios(11.0)); > @property (nonatomic, setter=_setDOMPasteAllowed:) BOOL _domPasteAllowed WK_API_AVAILABLE(macos(10.13), ios(11.0)); >diff --git a/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp b/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp >index d19436d940446a9bc121e8e025f684d405bda059..e70f7d021dce29d246f9f7cdff9adfc75882da3c 100644 >--- a/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp >+++ b/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp >@@ -366,6 +366,20 @@ void UserMediaCaptureManager::applyConstraintsFailed(uint64_t id, String&& faile > source->applyConstraintsFailed(WTFMove(failedConstraint), WTFMove(message)); > } > >+#if PLATFORM(IOS) >+void UserMediaCaptureManager::setAudioCapturePageState(bool interrupted, bool pageMuted) >+{ >+ if (auto* activeSource = static_cast<AudioCaptureFactory*>(this)->activeSource()) >+ activeSource->setInterrupted(interrupted, pageMuted); >+} >+ >+void UserMediaCaptureManager::setVideoCapturePageState(bool interrupted, bool pageMuted) >+{ >+ if (auto* activeSource = static_cast<VideoCaptureFactory*>(this)->activeSource()) >+ activeSource->setInterrupted(interrupted, pageMuted); >+} >+#endif >+ > } > > #endif >diff --git a/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.h b/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.h >index b11ae744c3de1b0bed2712e648a669e1f2305d9f..baed0cd9e09b49d221e94018f649fe6dbcf92519 100644 >--- a/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.h >+++ b/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.h >@@ -79,6 +79,11 @@ private: > WebCore::CaptureDeviceManager& videoCaptureDeviceManager() final { return m_noOpCaptureDeviceManager; } > WebCore::CaptureDeviceManager& displayCaptureDeviceManager() final { return m_noOpCaptureDeviceManager; } > >+#if PLATFORM(IOS_FAMILY) >+ void setAudioCapturePageState(bool interrupted, bool pageMuted) final; >+ void setVideoCapturePageState(bool interrupted, bool pageMuted) final; >+#endif >+ > // IPC::MessageReceiver > void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final; > >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index e7da17fe14345c7ede4d8eeed9ccca2b6687c6c6..2d45b84cbb1a75566e7025b2bef5425e65c57894 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,13 @@ >+2019-05-30 Youenn Fablet <youenn@apple.com> >+ >+ Add an option to mute audio capture automatically when page is not visible >+ https://bugs.webkit.org/show_bug.cgi?id=198307 >+ >+ Reviewed by Eric Carlson. >+ >+ * platform/ios/mediastream/audio-muted-in-background-tab-expected.txt: Added. >+ * platform/ios/mediastream/audio-muted-in-background-tab.html: Added. >+ > 2019-05-29 Said Abou-Hallawa <sabouhallawa@apple.com> > > REGRESSION (r244182) [Mac WK2] Layout Test imported/w3c/web-platform-tests/visual-viewport/viewport-resize-event-on-load-overflowing-page.html is a flaky failure >diff --git a/LayoutTests/platform/ios/mediastream/audio-muted-in-background-tab-expected.txt b/LayoutTests/platform/ios/mediastream/audio-muted-in-background-tab-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..408e29c7cbb9b4d05f04cd545bedff012e59472a >--- /dev/null >+++ b/LayoutTests/platform/ios/mediastream/audio-muted-in-background-tab-expected.txt >@@ -0,0 +1,7 @@ >+ >+PASS Setup stream >+PASS Hide page, video and audio should be muted >+PASS Show page, video and audio should be unmuted >+PASS Hide and mute page, video and audio should be muted >+PASS Show page, video and audio should remain muted >+ >diff --git a/LayoutTests/platform/ios/mediastream/audio-muted-in-background-tab.html b/LayoutTests/platform/ios/mediastream/audio-muted-in-background-tab.html >new file mode 100644 >index 0000000000000000000000000000000000000000..80e49edadf1f7a21ac00caf92cf543886817611a >--- /dev/null >+++ b/LayoutTests/platform/ios/mediastream/audio-muted-in-background-tab.html >@@ -0,0 +1,72 @@ >+ >+<!doctype html> >+<html> >+ <head> >+ <meta charset="utf-8"> >+ <title>Don't unmute audio when a tab becomes visible unless it was muted when the tab was hidden</title> >+ <script src="../../../resources/testharness.js"></script> >+ <script src="../../../resources/testharnessreport.js"></script> >+ </head> >+ <body> >+ <script> >+ let audioTrack; >+ let videoTrack; >+ >+ promise_test((t) => { >+ if (window.testRunner) >+ testRunner.setUserMediaPermission(true); >+ if (!window.internals) >+ return Promise.reject("this test needs internals API"); >+ >+ internals.setShouldInterruptAudioOnPageVisibilityChange(true); >+ >+ return navigator.mediaDevices.getUserMedia({ audio: true, video: true }).then((stream) => { >+ audioTrack = stream.getAudioTracks()[0]; >+ videoTrack = stream.getVideoTracks()[0]; >+ >+ assert_false(audioTrack.muted, "audio track is active"); >+ assert_false(videoTrack.muted, "video track is active"); >+ }) >+ >+ .then(() => { >+ test(() => { >+ if (window.internals) >+ window.internals.setPageVisibility(false); >+ assert_true(audioTrack.muted, "audio track is muted"); >+ assert_true(videoTrack.muted, "video track is muted"); >+ }, "Hide page, video and audio should be muted"); >+ }) >+ >+ .then(() => { >+ test(() => { >+ if (window.internals) >+ window.internals.setPageVisibility(true); >+ assert_false(audioTrack.muted, "audio track is active"); >+ assert_false(videoTrack.muted, "video track is active"); >+ }, "Show page, video and audio should be unmuted"); >+ }) >+ >+ .then(() => { >+ test(() => { >+ if (window.internals) { >+ window.internals.setPageVisibility(false); >+ window.internals.setPageMuted("capturedevices"); >+ } >+ assert_true(audioTrack.muted, "audio track is muted"); >+ assert_true(videoTrack.muted, "video track is muted"); >+ }, "Hide and mute page, video and audio should be muted"); >+ }) >+ >+ .then(() => { >+ test(() => { >+ if (window.internals) >+ window.internals.setPageVisibility(true); >+ assert_true(audioTrack.muted, "audio track is muted"); >+ assert_true(videoTrack.muted, "video track is muted"); >+ }, "Show page, video and audio should remain muted"); >+ }) >+ }, "Setup stream"); >+ >+ </script> >+ </body> >+</html>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198307
:
370807
|
370851
|
370862
|
370967
|
370986
|
371013
|
371060