Title: [295591] trunk
Revision
295591
Author
[email protected]
Date
2022-06-16 07:37:43 -0700 (Thu, 16 Jun 2022)

Log Message

A black screen appears in a muted video element outside the viewport
https://bugs.webkit.org/show_bug.cgi?id=241152
rdar://problem/94562636

Patch by Youenn Fablet <[email protected]> on 2022-06-16
Reviewed by Eric Carlson.

We sometimes remove the invisible autoplay restrictions.
If we remove it while we are suspended due this restriction, we will not unsuspend and will wait for a user interaction.
To prevent this, we do not return early in updateShouldAutoplay if we are interrupted due to the invisible autoplay restriction.

* LayoutTests/fast/mediastream/video-mediastream-restricted-invisible-autoplay-user-click-expected.txt: Added.
* LayoutTests/fast/mediastream/video-mediastream-restricted-invisible-autoplay-user-click.html: Added.
* Source/WebCore/html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::updateShouldAutoplay):

Canonical link: https://commits.webkit.org/251596@main

Modified Paths

Added Paths

Diff

Added: trunk/LayoutTests/fast/mediastream/video-mediastream-restricted-invisible-autoplay-user-click-expected.txt (0 => 295591)


--- trunk/LayoutTests/fast/mediastream/video-mediastream-restricted-invisible-autoplay-user-click-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/mediastream/video-mediastream-restricted-invisible-autoplay-user-click-expected.txt	2022-06-16 14:37:43 UTC (rev 295591)
@@ -0,0 +1,4 @@
+
+
+PASS Removing behavior restrictions should not disallow invisible uninterruption
+

Added: trunk/LayoutTests/fast/mediastream/video-mediastream-restricted-invisible-autoplay-user-click.html (0 => 295591)


--- trunk/LayoutTests/fast/mediastream/video-mediastream-restricted-invisible-autoplay-user-click.html	                        (rev 0)
+++ trunk/LayoutTests/fast/mediastream/video-mediastream-restricted-invisible-autoplay-user-click.html	2022-06-16 14:37:43 UTC (rev 295591)
@@ -0,0 +1,54 @@
+<html>
+    <head>
+        <script src=""
+        <script src=""
+        <script>
+            if (window.internals)
+                internals.settings.setInvisibleAutoplayNotPermitted(true);
+        </script>
+    </head>
+    <body>
+        <video id="localVideo1" controls autoplay></video>
+        <video id="localVideo2" controls autoplay></video>
+
+        <script>
+async function waitForPlay(video)
+{
+     if (!video.paused)
+          return;
+     return new Promise(resolve => { video._onplay_ = resolve; });
+}
+
+async function waitForPause(video)
+{
+     if (video.paused)
+          return;
+     return new Promise(resolve => { video._onpause_ = resolve; });
+}
+
+promise_test(async () => {
+     const stream = await navigator.mediaDevices.getUserMedia({ video: true });
+     localVideo1.srcObject = stream;
+     localVideo2.srcObject = stream;
+
+     await Promise.all([waitForPlay(localVideo1), waitForPlay(localVideo2)]);
+
+     localVideo1.style.display = "none";
+     localVideo2.style.display = "none";
+
+     await Promise.all([waitForPause(localVideo1), waitForPause(localVideo2)]);
+
+     if (!window.internals)
+         return;
+     internals.withUserGesture(() => {
+         localVideo2.srcObject = stream;
+     });
+
+     localVideo1.style.removeProperty("display");
+     localVideo2.style.removeProperty("display");
+
+     await Promise.all([waitForPlay(localVideo1), waitForPlay(localVideo2)]);
+}, "Removing behavior restrictions should not disallow invisible uninterruption");
+        </script>
+   </body>
+</html>

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (295590 => 295591)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2022-06-16 11:53:16 UTC (rev 295590)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2022-06-16 14:37:43 UTC (rev 295591)
@@ -8384,7 +8384,7 @@
     if (!autoplay())
         return;
 
-    if (!mediaSession().hasBehaviorRestriction(MediaElementSession::InvisibleAutoplayNotPermitted))
+    if (!mediaSession().hasBehaviorRestriction(MediaElementSession::InvisibleAutoplayNotPermitted) && !m_wasInterruptedForInvisibleAutoplay)
         return;
 
     bool canAutoplay = mediaSession().autoplayPermitted();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to