- Revision
- 253742
- Author
- [email protected]
- Date
- 2019-12-19 01:03:07 -0800 (Thu, 19 Dec 2019)
Log Message
Safari resumes autoplay audio elements after getUserMedia
https://bugs.webkit.org/show_bug.cgi?id=197688
<rdar://problem/57674395>
Reviewed by Eric Carlson.
Source/WebCore:
Covered by updated test.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::mediaStreamCaptureStarted):
Previously, we were piggybacking on resuming autoplay, which happens after interuption.
This is incorrect as it tries to play paused elements.
Instead we just try to play a media element if it can autoplay without changing the m_autoplaying value.
* html/HTMLMediaElement.h:
(WebCore::HTMLMediaElement::mediaStreamCaptureStarted): Deleted.
LayoutTests:
* webrtc/video-autoplay-expected.txt:
* webrtc/video-autoplay.html:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (253741 => 253742)
--- trunk/LayoutTests/ChangeLog 2019-12-19 08:35:47 UTC (rev 253741)
+++ trunk/LayoutTests/ChangeLog 2019-12-19 09:03:07 UTC (rev 253742)
@@ -1,3 +1,14 @@
+2019-12-19 youenn fablet <[email protected]>
+
+ Safari resumes autoplay audio elements after getUserMedia
+ https://bugs.webkit.org/show_bug.cgi?id=197688
+ <rdar://problem/57674395>
+
+ Reviewed by Eric Carlson.
+
+ * webrtc/video-autoplay-expected.txt:
+ * webrtc/video-autoplay.html:
+
2019-12-18 Ryosuke Niwa <[email protected]>
REGRESSION: [ Mac wk2 ] tiled-drawing/scrolling/fast-scroll-div-latched-mainframe-with-handler.html is a flakey failure
Modified: trunk/LayoutTests/webrtc/video-autoplay-expected.txt (253741 => 253742)
--- trunk/LayoutTests/webrtc/video-autoplay-expected.txt 2019-12-19 08:35:47 UTC (rev 253741)
+++ trunk/LayoutTests/webrtc/video-autoplay-expected.txt 2019-12-19 09:03:07 UTC (rev 253742)
@@ -1,3 +1,4 @@
+
PASS Ensuring autoplay does not work on regular video elements
@@ -4,4 +5,6 @@
PASS Ensuring autoplay does not work on regular video elements when getUserMedia is on
PASS Local media stream autoplay
PASS Remote media stream autoplay
+PASS Granting getUserMedia should not start paused media
+PASS Granting getUserMedia should not start paused media or media that cannot autoplay due to autoplay restrictions
Modified: trunk/LayoutTests/webrtc/video-autoplay.html (253741 => 253742)
--- trunk/LayoutTests/webrtc/video-autoplay.html 2019-12-19 08:35:47 UTC (rev 253741)
+++ trunk/LayoutTests/webrtc/video-autoplay.html 2019-12-19 09:03:07 UTC (rev 253742)
@@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
- <title>Testing basic video exchange from offerer to receiver</title>
+ <title>Testing basic autoplay with getUserMedia</title>
<script src=""
<script src=""
<script src=""
@@ -10,6 +10,16 @@
</head>
<body>
<video id="video" autoplay></video>
+ <br>
+ <video id="video1" loop autoplay playsInline></video>
+ <video id="video2" loop autoplay playsInline></video>
+ <video id="video3" loop autoplay playsInline></video>
+ <video id="video4" loop autoplay playsInline></video>
+ <br>
+ <video id="video10" loop autoplay playsInline></video>
+ <video id="video20" loop autoplay playsInline></video>
+ <video id="video30" loop autoplay playsInline></video>
+ <video id="video40" loop autoplay playsInline></video>
<script src =""
<script>
video = document.getElementById("video");
@@ -63,6 +73,75 @@
});
}, "Remote media stream autoplay");
+promise_test(async (test) => {
+ if (window.internals) {
+ internals.setMediaElementRestrictions(video1, "");
+ internals.setMediaElementRestrictions(video2, "");
+ internals.setMediaElementRestrictions(video3, "");
+ internals.setMediaElementRestrictions(video4, "");
+ }
+
+ video1.src = "" "../media/content/audio-tracks");
+ video2.src = "" "../media/content/audio-tracks");
+ video3.src = "" "../media/content/audio-tracks");
+
+ await video1.play();
+ await video2.play();
+ await video3.play();
+
+ await video1.pause();
+ let removedVideo2 = video2;
+ removedVideo2.remove();
+
+ video4.srcObject = await navigator.mediaDevices.getUserMedia({ video : true });
+
+ while (video4.paused)
+ await new Promise(resolve => setTimeout(resolve, 50));
+
+ assert_true(video1.paused, "paused video");
+ assert_true(removedVideo2.paused, "out of DOM video");
+ assert_false(video3.paused, "still playing video");
+
+ video1.remove();
+ video3.remove();
+ video4.remove();
+}, "Granting getUserMedia should not start paused media");
+
+promise_test(async (test) => {
+ if (window.internals) {
+ internals.setMediaElementRestrictions(video10, "RequireUserGestureForVideoRateChange");
+ internals.setMediaElementRestrictions(video20, "RequireUserGestureForVideoRateChange");
+ internals.setMediaElementRestrictions(video30, "RequireUserGestureForVideoRateChange");
+ internals.setMediaElementRestrictions(video40, "RequireUserGestureForVideoRateChange");
+ }
+
+ video10.src = "" "../media/content/audio-tracks");
+ video20.src = "" "../media/content/audio-tracks");
+ video30.src = "" "../media/content/audio-tracks");
+
+ await new Promise(resolve => setTimeout(resolve, 50));
+ assert_true(video10.paused, "paused video");
+ assert_true(video20.paused, "paused video");
+ assert_true(video30.paused, "paused video");
+
+ video10.pause();
+ let removedVideo20 = video20;
+ removedVideo20.remove();
+
+ video40.srcObject = await navigator.mediaDevices.getUserMedia({ video : true });
+
+ while (video40.paused)
+ await new Promise(resolve => setTimeout(resolve, 50));
+
+ assert_true(video10.paused, "paused video");
+ assert_true(removedVideo20.paused, "out of DOM video");
+ assert_true(video30.paused, "still not autoplaying video");
+
+ video10.remove();
+ video30.remove();
+ video40.remove();
+}, "Granting getUserMedia should not start paused media or media that cannot autoplay due to autoplay restrictions");
+
</script>
</body>
</html>
Modified: trunk/Source/WebCore/ChangeLog (253741 => 253742)
--- trunk/Source/WebCore/ChangeLog 2019-12-19 08:35:47 UTC (rev 253741)
+++ trunk/Source/WebCore/ChangeLog 2019-12-19 09:03:07 UTC (rev 253742)
@@ -1,3 +1,21 @@
+2019-12-19 youenn fablet <[email protected]>
+
+ Safari resumes autoplay audio elements after getUserMedia
+ https://bugs.webkit.org/show_bug.cgi?id=197688
+ <rdar://problem/57674395>
+
+ Reviewed by Eric Carlson.
+
+ Covered by updated test.
+
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::mediaStreamCaptureStarted):
+ Previously, we were piggybacking on resuming autoplay, which happens after interuption.
+ This is incorrect as it tries to play paused elements.
+ Instead we just try to play a media element if it can autoplay without changing the m_autoplaying value.
+ * html/HTMLMediaElement.h:
+ (WebCore::HTMLMediaElement::mediaStreamCaptureStarted): Deleted.
+
2019-12-18 Sihui Liu <[email protected]>
IndexedDB: perform IDBServer work only on background thread
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (253741 => 253742)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2019-12-19 08:35:47 UTC (rev 253741)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2019-12-19 09:03:07 UTC (rev 253742)
@@ -8164,6 +8164,14 @@
#endif
}
+#if ENABLE(MEDIA_STREAM)
+void HTMLMediaElement::mediaStreamCaptureStarted()
+{
+ if (canTransitionFromAutoplayToPlay())
+ play();
+}
+#endif
+
void HTMLMediaElement::enqueueTaskForDispatcher(Function<void()>&& function)
{
if (!isMainThread()) {
Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (253741 => 253742)
--- trunk/Source/WebCore/html/HTMLMediaElement.h 2019-12-19 08:35:47 UTC (rev 253741)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h 2019-12-19 09:03:07 UTC (rev 253742)
@@ -559,7 +559,7 @@
WEBCORE_EXPORT const MediaResourceLoader* lastMediaResourceLoaderForTesting() const;
#if ENABLE(MEDIA_STREAM)
- void mediaStreamCaptureStarted() { resumeAutoplaying(); }
+ void mediaStreamCaptureStarted();
bool hasMediaStreamSrcObject() const { return m_mediaProvider && WTF::holds_alternative<RefPtr<MediaStream>>(*m_mediaProvider); }
#endif