Diff
Modified: trunk/LayoutTests/ChangeLog (217733 => 217734)
--- trunk/LayoutTests/ChangeLog 2017-06-02 20:57:17 UTC (rev 217733)
+++ trunk/LayoutTests/ChangeLog 2017-06-02 21:16:53 UTC (rev 217734)
@@ -1,3 +1,13 @@
+2017-06-02 Eric Carlson <eric.carl...@apple.com>
+
+ [MediaStream iOS] Cleanup video muting/unmuting when tab visibility changes
+ https://bugs.webkit.org/show_bug.cgi?id=172858
+
+ Reviewed by Youenn Fablet.
+
+ * platform/ios/mediastream/video-muted-in-background-tab-expected.txt: Added.
+ * platform/ios/mediastream/video-muted-in-background-tab.html: Added.
+
2017-06-02 Matt Lewis <jlew...@apple.com>
Moved test expectation for http/tests/preload/viewport/meta-viewport-link-headers.php to correct file.
Added: trunk/LayoutTests/platform/ios/mediastream/video-muted-in-background-tab-expected.txt (0 => 217734)
--- trunk/LayoutTests/platform/ios/mediastream/video-muted-in-background-tab-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/ios/mediastream/video-muted-in-background-tab-expected.txt 2017-06-02 21:16:53 UTC (rev 217734)
@@ -0,0 +1,7 @@
+
+PASS Setup stream
+PASS Hide page, only video 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
+
Added: trunk/LayoutTests/platform/ios/mediastream/video-muted-in-background-tab.html (0 => 217734)
--- trunk/LayoutTests/platform/ios/mediastream/video-muted-in-background-tab.html (rev 0)
+++ trunk/LayoutTests/platform/ios/mediastream/video-muted-in-background-tab.html 2017-06-02 21:16:53 UTC (rev 217734)
@@ -0,0 +1,70 @@
+
+<!doctype html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Don't unmute video when a tab becomes visible unless it was muted when the tab was hidden</title>
+ <script src=""
+ <script src=""
+ </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");
+
+ 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_false(audioTrack.muted, "audio track is active");
+ assert_true(videoTrack.muted, "video track is muted");
+ }, "Hide page, only video 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>
\ No newline at end of file
Modified: trunk/Source/WebCore/ChangeLog (217733 => 217734)
--- trunk/Source/WebCore/ChangeLog 2017-06-02 20:57:17 UTC (rev 217733)
+++ trunk/Source/WebCore/ChangeLog 2017-06-02 21:16:53 UTC (rev 217734)
@@ -1,3 +1,36 @@
+2017-06-02 Eric Carlson <eric.carl...@apple.com>
+
+ [MediaStream iOS] Cleanup video muting/unmuting when tab visibility changes
+ https://bugs.webkit.org/show_bug.cgi?id=172858
+
+ Reviewed by Youenn Fablet.
+
+ Test: platform/ios/mediastream/video-muted-in-background-tab.html
+
+ * dom/Document.cpp:
+ (WebCore::Document::visibilityStateChanged): Call notifyMediaCaptureOfVisibilityChanged.
+ (WebCore::Document::notifyMediaCaptureOfVisibilityChanged): Renamed from notifyVisibilityChangedToMediaCapture.
+ Set m_videoCaptureMutedForVisibilityChange when capture is muted because the document is hidden,
+ and clear it when visibility changes when capture is disabled. Don't unmute when the document
+ becomes visible unless this m_videoCaptureMutedForVisibilityChange is still true.
+ (WebCore::Document::notifyVisibilityChangedToMediaCapture): Deleted.
+ * dom/Document.h:
+
+ * platform/mediastream/RealtimeMediaSource.h:
+ * platform/mediastream/RealtimeMediaSourceCenter.cpp:
+ (WebCore::RealtimeMediaSourceCenter::setVideoCaptureMutedForPageVisibility): Renamed from
+ setVisibility.
+ (WebCore::RealtimeMediaSourceCenter::setVisibility): Deleted.
+ * platform/mediastream/RealtimeMediaSourceCenter.h:
+
+ * platform/mediastream/mac/AVVideoCaptureSource.mm:
+ (WebCore::AVVideoCaptureSourceFactory::setVideoCaptureMutedForPageVisibility): Ditto.
+ (WebCore::AVVideoCaptureSourceFactory::setVisibility): Deleted.
+
+ * platform/mock/MockRealtimeVideoSource.cpp:
+ (WebCore::MockRealtimeVideoSourceFactory::setVideoCaptureMutedForPageVisibility): Ditto.
+ (WebCore::MockRealtimeVideoSourceFactory::setVisibility): Deleted.
+
2017-06-02 Frederic Wang <fw...@igalia.com>
[Mac] Include frames in the scrolling tree when ScrollingTreeIncludesFrames=true
Modified: trunk/Source/WebCore/dom/Document.cpp (217733 => 217734)
--- trunk/Source/WebCore/dom/Document.cpp 2017-06-02 20:57:17 UTC (rev 217733)
+++ trunk/Source/WebCore/dom/Document.cpp 2017-06-02 21:16:53 UTC (rev 217734)
@@ -1547,7 +1547,7 @@
for (auto* client : m_visibilityStateCallbackClients)
client->visibilityStateChanged();
- notifyVisibilityChangedToMediaCapture();
+ notifyMediaCaptureOfVisibilityChanged();
}
auto Document::visibilityState() const -> VisibilityState
@@ -7005,10 +7005,19 @@
m_orientationNotifier.orientationChanged(orientation);
}
-void Document::notifyVisibilityChangedToMediaCapture()
+void Document::notifyMediaCaptureOfVisibilityChanged()
{
#if ENABLE(MEDIA_STREAM)
- RealtimeMediaSourceCenter::singleton().setVisibility(!hidden());
+ if (!page() || page()->isMediaCaptureMuted()) {
+ m_videoCaptureMutedForVisibilityChange = false;
+ return;
+ }
+
+ if (!hidden() && !m_videoCaptureMutedForVisibilityChange)
+ return;
+
+ m_videoCaptureMutedForVisibilityChange = hidden();
+ RealtimeMediaSourceCenter::singleton().setVideoCaptureMutedForPageVisibility(m_videoCaptureMutedForVisibilityChange);
#endif
}
Modified: trunk/Source/WebCore/dom/Document.h (217733 => 217734)
--- trunk/Source/WebCore/dom/Document.h 2017-06-02 20:57:17 UTC (rev 217733)
+++ trunk/Source/WebCore/dom/Document.h 2017-06-02 21:16:53 UTC (rev 217734)
@@ -1603,7 +1603,7 @@
void clearScriptedAnimationController();
RefPtr<ScriptedAnimationController> m_scriptedAnimationController;
- void notifyVisibilityChangedToMediaCapture();
+ void notifyMediaCaptureOfVisibilityChanged();
#if ENABLE(DEVICE_ORIENTATION) && PLATFORM(IOS)
std::unique_ptr<DeviceMotionClient> m_deviceMotionClient;
@@ -1770,6 +1770,7 @@
HashSet<HTMLMediaElement*> m_mediaStreamStateChangeElements;
String m_idHashSalt;
bool m_hasHadActiveMediaStreamTrack { false };
+ bool m_videoCaptureMutedForVisibilityChange { false };
#endif
#ifndef NDEBUG
Modified: trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h (217733 => 217734)
--- trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h 2017-06-02 20:57:17 UTC (rev 217733)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h 2017-06-02 21:16:53 UTC (rev 217734)
@@ -120,7 +120,7 @@
public:
virtual ~VideoCaptureFactory() = default;
virtual CaptureSourceOrError createVideoCaptureSource(const String& videoDeviceID, const MediaConstraints*) = 0;
- virtual void setVisibility(bool) { }
+ virtual void setVideoCaptureMutedForPageVisibility(bool) { }
protected:
VideoCaptureFactory() = default;
Modified: trunk/Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.cpp (217733 => 217734)
--- trunk/Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.cpp 2017-06-02 20:57:17 UTC (rev 217733)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.cpp 2017-06-02 21:16:53 UTC (rev 217734)
@@ -334,9 +334,9 @@
validHandler(WTFMove(audioSourceIds), WTFMove(videoSourceIds), WTFMove(deviceIdentifierHashSalt));
}
-void RealtimeMediaSourceCenter::setVisibility(bool isVisible)
+void RealtimeMediaSourceCenter::setVideoCaptureMutedForPageVisibility(bool shouldMute)
{
- videoFactory().setVisibility(isVisible);
+ videoFactory().setVideoCaptureMutedForPageVisibility(shouldMute);
}
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.h (217733 => 217734)
--- trunk/Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.h 2017-06-02 20:57:17 UTC (rev 217733)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.h 2017-06-02 21:16:53 UTC (rev 217734)
@@ -100,7 +100,7 @@
void removeDevicesChangedObserver(DevicesChangedObserverToken);
void captureDevicesChanged();
- void setVisibility(bool isVisible);
+ void setVideoCaptureMutedForPageVisibility(bool);
protected:
RealtimeMediaSourceCenter();
Modified: trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm (217733 => 217734)
--- trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm 2017-06-02 20:57:17 UTC (rev 217733)
+++ trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm 2017-06-02 21:16:53 UTC (rev 217734)
@@ -125,10 +125,10 @@
#if PLATFORM(IOS)
private:
- void setVisibility(bool isVisible)
+ void setVideoCaptureMutedForPageVisibility(bool shouldMute)
{
if (activeSource())
- activeSource()->setMuted(!isVisible);
+ activeSource()->setMuted(shouldMute);
}
#endif
};
Modified: trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp (217733 => 217734)
--- trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp 2017-06-02 20:57:17 UTC (rev 217733)
+++ trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp 2017-06-02 21:16:53 UTC (rev 217734)
@@ -63,10 +63,10 @@
}
#if PLATFORM(IOS)
private:
- void setVisibility(bool isVisible)
+ void setVideoCaptureMutedForPageVisibility(bool shouldMute)
{
if (activeSource())
- activeSource()->setMuted(!isVisible);
+ activeSource()->setMuted(shouldMute);
}
#endif
};