Title: [272956] branches/safari-611-branch
Revision
272956
Author
repst...@apple.com
Date
2021-02-16 17:18:15 -0800 (Tue, 16 Feb 2021)

Log Message

Cherry-pick r272583. rdar://problem/74409637

    MediaStream-backed video elements should not compute the mediaType based on track muted states
    https://bugs.webkit.org/show_bug.cgi?id=221601

    Reviewed by Eric Carlson.

    Source/WebCore:

    In case of entering background, two things happen:
    - video elements get paused
    - local video capture track gets muted
    When entering foreground:
    - video element should resume but did not as the local video track was muted and video element was considered as an audio element.
    - local video capture track gets unmuted but this is too late.
    To fix this, compute hasVideo/hasAudio based on available tracks, no matter their active state.

    Test: fast/mediastream/MediaStream-video-element-enter-background.html

    * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
    (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::hasVideo const):
    (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::hasAudio const):

    LayoutTests:

    * fast/mediastream/MediaStream-video-element-enter-background-expected.txt: Added.
    * fast/mediastream/MediaStream-video-element-enter-background.html: Added.

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272583 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Added Paths

Diff

Modified: branches/safari-611-branch/LayoutTests/ChangeLog (272955 => 272956)


--- branches/safari-611-branch/LayoutTests/ChangeLog	2021-02-17 01:18:00 UTC (rev 272955)
+++ branches/safari-611-branch/LayoutTests/ChangeLog	2021-02-17 01:18:15 UTC (rev 272956)
@@ -1,5 +1,48 @@
 2021-02-16  Ruben Turcios  <rubent...@apple.com>
 
+        Cherry-pick r272583. rdar://problem/74409637
+
+    MediaStream-backed video elements should not compute the mediaType based on track muted states
+    https://bugs.webkit.org/show_bug.cgi?id=221601
+    
+    Reviewed by Eric Carlson.
+    
+    Source/WebCore:
+    
+    In case of entering background, two things happen:
+    - video elements get paused
+    - local video capture track gets muted
+    When entering foreground:
+    - video element should resume but did not as the local video track was muted and video element was considered as an audio element.
+    - local video capture track gets unmuted but this is too late.
+    To fix this, compute hasVideo/hasAudio based on available tracks, no matter their active state.
+    
+    Test: fast/mediastream/MediaStream-video-element-enter-background.html
+    
+    * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
+    (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::hasVideo const):
+    (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::hasAudio const):
+    
+    LayoutTests:
+    
+    * fast/mediastream/MediaStream-video-element-enter-background-expected.txt: Added.
+    * fast/mediastream/MediaStream-video-element-enter-background.html: Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272583 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-02-09  Youenn Fablet  <you...@apple.com>
+
+            MediaStream-backed video elements should not compute the mediaType based on track muted states
+            https://bugs.webkit.org/show_bug.cgi?id=221601
+
+            Reviewed by Eric Carlson.
+
+            * fast/mediastream/MediaStream-video-element-enter-background-expected.txt: Added.
+            * fast/mediastream/MediaStream-video-element-enter-background.html: Added.
+
+2021-02-16  Ruben Turcios  <rubent...@apple.com>
+
         Cherry-pick r272567. rdar://problem/74410033
 
     REGRESSION (r269458): yahoo.com social / comments bar shows as transparent when scrolling page

Added: branches/safari-611-branch/LayoutTests/fast/mediastream/MediaStream-video-element-enter-background-expected.txt (0 => 272956)


--- branches/safari-611-branch/LayoutTests/fast/mediastream/MediaStream-video-element-enter-background-expected.txt	                        (rev 0)
+++ branches/safari-611-branch/LayoutTests/fast/mediastream/MediaStream-video-element-enter-background-expected.txt	2021-02-17 01:18:15 UTC (rev 272956)
@@ -0,0 +1,4 @@
+
+
+PASS MediaStream video should restart when going to foreground
+

Added: branches/safari-611-branch/LayoutTests/fast/mediastream/MediaStream-video-element-enter-background.html (0 => 272956)


--- branches/safari-611-branch/LayoutTests/fast/mediastream/MediaStream-video-element-enter-background.html	                        (rev 0)
+++ branches/safari-611-branch/LayoutTests/fast/mediastream/MediaStream-video-element-enter-background.html	2021-02-17 01:18:15 UTC (rev 272956)
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <title>Testing MediaDevices addEventListener/removeEventListener</title>
+    <script src=""
+    <script src=""
+</head>
+<body>
+    <video id="video" autoplay playsInline></video>
+    <script>
+promise_test(async (test) => {
+    video.srcObject = await navigator.mediaDevices.getUserMedia({ video: true });
+    const track = video.srcObject.getTracks()[0];
+
+    await video.play();
+
+    if (!window.internals)
+       return;
+    internals.setMediaSessionRestrictions("video", "backgroundprocessplaybackrestricted");
+
+    let mutePromise = new Promise(resolve => track._onmute_ = resolve);
+    internals.applicationDidEnterBackground(true);
+    internals.setMediaStreamTrackMuted(track, true);
+    await mutePromise;
+
+    let counter = 100
+    while (!video.paused && --counter > 0)
+        await new Promise(resolve => setTimeout(resolve, 50));
+    assert_true(video.paused, "video paused");
+
+    let unmutePromise = new Promise(resolve => track._onunmute_ = resolve);
+    internals.applicationWillEnterForeground(false);
+    internals.setMediaStreamTrackMuted(track, false);
+    await unmutePromise;
+
+    counter = 100;
+    while (video.paused && --counter > 0)
+       await new Promise(resolve => setTimeout(resolve, 50));
+    assert_false(video.paused, "video resumed");
+
+}, "MediaStream video should restart when going to foreground");
+    </script>
+</body>
+</html>

Modified: branches/safari-611-branch/Source/WebCore/ChangeLog (272955 => 272956)


--- branches/safari-611-branch/Source/WebCore/ChangeLog	2021-02-17 01:18:00 UTC (rev 272955)
+++ branches/safari-611-branch/Source/WebCore/ChangeLog	2021-02-17 01:18:15 UTC (rev 272956)
@@ -1,5 +1,59 @@
 2021-02-16  Ruben Turcios  <rubent...@apple.com>
 
+        Cherry-pick r272583. rdar://problem/74409637
+
+    MediaStream-backed video elements should not compute the mediaType based on track muted states
+    https://bugs.webkit.org/show_bug.cgi?id=221601
+    
+    Reviewed by Eric Carlson.
+    
+    Source/WebCore:
+    
+    In case of entering background, two things happen:
+    - video elements get paused
+    - local video capture track gets muted
+    When entering foreground:
+    - video element should resume but did not as the local video track was muted and video element was considered as an audio element.
+    - local video capture track gets unmuted but this is too late.
+    To fix this, compute hasVideo/hasAudio based on available tracks, no matter their active state.
+    
+    Test: fast/mediastream/MediaStream-video-element-enter-background.html
+    
+    * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
+    (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::hasVideo const):
+    (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::hasAudio const):
+    
+    LayoutTests:
+    
+    * fast/mediastream/MediaStream-video-element-enter-background-expected.txt: Added.
+    * fast/mediastream/MediaStream-video-element-enter-background.html: Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272583 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-02-09  Youenn Fablet  <you...@apple.com>
+
+            MediaStream-backed video elements should not compute the mediaType based on track muted states
+            https://bugs.webkit.org/show_bug.cgi?id=221601
+
+            Reviewed by Eric Carlson.
+
+            In case of entering background, two things happen:
+            - video elements get paused
+            - local video capture track gets muted
+            When entering foreground:
+            - video element should resume but did not as the local video track was muted and video element was considered as an audio element.
+            - local video capture track gets unmuted but this is too late.
+            To fix this, compute hasVideo/hasAudio based on available tracks, no matter their active state.
+
+            Test: fast/mediastream/MediaStream-video-element-enter-background.html
+
+            * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
+            (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::hasVideo const):
+            (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::hasAudio const):
+
+2021-02-16  Ruben Turcios  <rubent...@apple.com>
+
         Cherry-pick r272567. rdar://problem/74410033
 
     REGRESSION (r269458): yahoo.com social / comments bar shows as transparent when scrolling page

Modified: branches/safari-611-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm (272955 => 272956)


--- branches/safari-611-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm	2021-02-17 01:18:00 UTC (rev 272955)
+++ branches/safari-611-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm	2021-02-17 01:18:15 UTC (rev 272956)
@@ -577,18 +577,12 @@
 
 bool MediaPlayerPrivateMediaStreamAVFObjC::hasVideo() const
 {
-    if (!metaDataAvailable())
-        return false;
-    
-    return m_mediaStreamPrivate->hasVideo();
+    return !m_videoTrackMap.isEmpty();
 }
 
 bool MediaPlayerPrivateMediaStreamAVFObjC::hasAudio() const
 {
-    if (!metaDataAvailable())
-        return false;
-    
-    return m_mediaStreamPrivate->hasAudio();
+    return !m_audioTrackMap.isEmpty();
 }
 
 void MediaPlayerPrivateMediaStreamAVFObjC::setVisible(bool visible)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to