Title: [277795] branches/safari-612.1.15.1-branch
Revision
277795
Author
rubent...@apple.com
Date
2021-05-20 10:32:35 -0700 (Thu, 20 May 2021)

Log Message

Cherry-pick r277726. rdar://problem/78260457

    [Mac] MSE-based video pauses when put in background; PiP context menu disabled
    https://bugs.webkit.org/show_bug.cgi?id=225958
    <rdar://78130303>

    Reviewed by Eric Carlson.

    Source/WebCore:

    Test: media/media-source/media-source-has-audio-video.html

    In r277116, in order to reduce the CPU usage incurred when pushing state changes from
    the GPU process to the WebContent process, state changes to `hasAudio` and `hasVideo`
    were now only updated when the MediaPlayer indicated that its `characteristicsChanged()`.
    However, in SourceBufferPrivateAVFObjC, this call was performed too early, before the
    SourceBuffer in the WebContent process had informed SourceBufferPrivate of newly added
    audio and video tracks. Thus the cached values of `hasAudio` and `hasVideo` inside the
    WebContent process were never updated.

    Call `characteristicsChanged()` from the callback handler of `didReceiveInitializationSegment()`,
    which will be called only after the WebContent process completes its handling of the
    new initialization segment, which includes telling the SourceBufferPrivate in the GPU
    process about newly added audio and video tracks.

    * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
    (WebCore::SourceBufferPrivateAVFObjC::didParseInitializationData):

    LayoutTests:

    * media/media-source/media-source-has-audio-video-expected.txt: Added.
    * media/media-source/media-source-has-audio-video.html: Added.

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

Modified Paths

Added Paths

Diff

Modified: branches/safari-612.1.15.1-branch/LayoutTests/ChangeLog (277794 => 277795)


--- branches/safari-612.1.15.1-branch/LayoutTests/ChangeLog	2021-05-20 17:32:31 UTC (rev 277794)
+++ branches/safari-612.1.15.1-branch/LayoutTests/ChangeLog	2021-05-20 17:32:35 UTC (rev 277795)
@@ -1,3 +1,52 @@
+2021-05-20  Russell Epstein  <repst...@apple.com>
+
+        Cherry-pick r277726. rdar://problem/78260457
+
+    [Mac] MSE-based video pauses when put in background; PiP context menu disabled
+    https://bugs.webkit.org/show_bug.cgi?id=225958
+    <rdar://78130303>
+    
+    Reviewed by Eric Carlson.
+    
+    Source/WebCore:
+    
+    Test: media/media-source/media-source-has-audio-video.html
+    
+    In r277116, in order to reduce the CPU usage incurred when pushing state changes from
+    the GPU process to the WebContent process, state changes to `hasAudio` and `hasVideo`
+    were now only updated when the MediaPlayer indicated that its `characteristicsChanged()`.
+    However, in SourceBufferPrivateAVFObjC, this call was performed too early, before the
+    SourceBuffer in the WebContent process had informed SourceBufferPrivate of newly added
+    audio and video tracks. Thus the cached values of `hasAudio` and `hasVideo` inside the
+    WebContent process were never updated.
+    
+    Call `characteristicsChanged()` from the callback handler of `didReceiveInitializationSegment()`,
+    which will be called only after the WebContent process completes its handling of the
+    new initialization segment, which includes telling the SourceBufferPrivate in the GPU
+    process about newly added audio and video tracks.
+    
+    * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
+    (WebCore::SourceBufferPrivateAVFObjC::didParseInitializationData):
+    
+    LayoutTests:
+    
+    * media/media-source/media-source-has-audio-video-expected.txt: Added.
+    * media/media-source/media-source-has-audio-video.html: Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277726 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-05-19  Jer Noble  <jer.no...@apple.com>
+
+            [Mac] MSE-based video pauses when put in background; PiP context menu disabled
+            https://bugs.webkit.org/show_bug.cgi?id=225958
+            <rdar://78130303>
+
+            Reviewed by Eric Carlson.
+
+            * media/media-source/media-source-has-audio-video-expected.txt: Added.
+            * media/media-source/media-source-has-audio-video.html: Added.
+
 2021-05-19  Alan Coon  <alanc...@apple.com>
 
         Cherry-pick r277665. rdar://problem/78224090

Added: branches/safari-612.1.15.1-branch/LayoutTests/media/media-source/media-source-has-audio-video-expected.txt (0 => 277795)


--- branches/safari-612.1.15.1-branch/LayoutTests/media/media-source/media-source-has-audio-video-expected.txt	                        (rev 0)
+++ branches/safari-612.1.15.1-branch/LayoutTests/media/media-source/media-source-has-audio-video-expected.txt	2021-05-20 17:32:35 UTC (rev 277795)
@@ -0,0 +1,11 @@
+
+RUN(video.src = ""
+EVENT(sourceopen)
+RUN(mediaSource.duration = loader.duration())
+RUN(sourceBuffer = mediaSource.addSourceBuffer(loader.type()))
+RUN(sourceBuffer.appendBuffer(loader.initSegment()))
+EVENT(update)
+EXPECTED (internals.mediaUsageState(video).hasVideo == 'true') OK
+EXPECTED (internals.mediaUsageState(video).hasAudio == 'true') OK
+END OF TEST
+

Added: branches/safari-612.1.15.1-branch/LayoutTests/media/media-source/media-source-has-audio-video.html (0 => 277795)


--- branches/safari-612.1.15.1-branch/LayoutTests/media/media-source/media-source-has-audio-video.html	                        (rev 0)
+++ branches/safari-612.1.15.1-branch/LayoutTests/media/media-source/media-source-has-audio-video.html	2021-05-20 17:32:35 UTC (rev 277795)
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>media-source-has-audio-video</title>
+    <script src=""
+    <script src=""
+    <script>
+    window.addEventListener('load', event => {
+        findMediaElement();
+
+        window.sourceBuffer = new MediaSource();
+
+        loader = new MediaSourceLoader('content/test-fragmented-manifest.json');
+        loader._onload_ = mediaDataLoaded;
+        loader._onerror_ = mediaDataLoadingFailed;
+    });
+
+    function mediaDataLoadingFailed() {
+        failTest('Media data loading failed');
+    }
+
+    async function mediaDataLoaded() {
+        window.mediaSource = new MediaSource();
+        run('video.src = ""
+        waitFor(video, 'error').then(failTest);
+        await waitFor(mediaSource, 'sourceopen');
+
+        run('mediaSource.duration = loader.duration()');
+        run('sourceBuffer = mediaSource.addSourceBuffer(loader.type())');
+        run('sourceBuffer.appendBuffer(loader.initSegment())');
+        await waitFor(sourceBuffer, 'update');
+
+        await testExpectedEventually('internals.mediaUsageState(video).hasVideo', true);
+        await testExpectedEventually('internals.mediaUsageState(video).hasAudio', true);
+        endTest();
+    }
+
+    </script>
+</head>
+<body>
+    <video></video>
+</body>
+</html>

Modified: branches/safari-612.1.15.1-branch/Source/WebCore/ChangeLog (277794 => 277795)


--- branches/safari-612.1.15.1-branch/Source/WebCore/ChangeLog	2021-05-20 17:32:31 UTC (rev 277794)
+++ branches/safari-612.1.15.1-branch/Source/WebCore/ChangeLog	2021-05-20 17:32:35 UTC (rev 277795)
@@ -1,3 +1,67 @@
+2021-05-20  Russell Epstein  <repst...@apple.com>
+
+        Cherry-pick r277726. rdar://problem/78260457
+
+    [Mac] MSE-based video pauses when put in background; PiP context menu disabled
+    https://bugs.webkit.org/show_bug.cgi?id=225958
+    <rdar://78130303>
+    
+    Reviewed by Eric Carlson.
+    
+    Source/WebCore:
+    
+    Test: media/media-source/media-source-has-audio-video.html
+    
+    In r277116, in order to reduce the CPU usage incurred when pushing state changes from
+    the GPU process to the WebContent process, state changes to `hasAudio` and `hasVideo`
+    were now only updated when the MediaPlayer indicated that its `characteristicsChanged()`.
+    However, in SourceBufferPrivateAVFObjC, this call was performed too early, before the
+    SourceBuffer in the WebContent process had informed SourceBufferPrivate of newly added
+    audio and video tracks. Thus the cached values of `hasAudio` and `hasVideo` inside the
+    WebContent process were never updated.
+    
+    Call `characteristicsChanged()` from the callback handler of `didReceiveInitializationSegment()`,
+    which will be called only after the WebContent process completes its handling of the
+    new initialization segment, which includes telling the SourceBufferPrivate in the GPU
+    process about newly added audio and video tracks.
+    
+    * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
+    (WebCore::SourceBufferPrivateAVFObjC::didParseInitializationData):
+    
+    LayoutTests:
+    
+    * media/media-source/media-source-has-audio-video-expected.txt: Added.
+    * media/media-source/media-source-has-audio-video.html: Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277726 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-05-19  Jer Noble  <jer.no...@apple.com>
+
+            [Mac] MSE-based video pauses when put in background; PiP context menu disabled
+            https://bugs.webkit.org/show_bug.cgi?id=225958
+            <rdar://78130303>
+
+            Reviewed by Eric Carlson.
+
+            Test: media/media-source/media-source-has-audio-video.html
+
+            In r277116, in order to reduce the CPU usage incurred when pushing state changes from
+            the GPU process to the WebContent process, state changes to `hasAudio` and `hasVideo`
+            were now only updated when the MediaPlayer indicated that its `characteristicsChanged()`.
+            However, in SourceBufferPrivateAVFObjC, this call was performed too early, before the
+            SourceBuffer in the WebContent process had informed SourceBufferPrivate of newly added
+            audio and video tracks. Thus the cached values of `hasAudio` and `hasVideo` inside the
+            WebContent process were never updated.
+
+            Call `characteristicsChanged()` from the callback handler of `didReceiveInitializationSegment()`,
+            which will be called only after the WebContent process completes its handling of the
+            new initialization segment, which includes telling the SourceBufferPrivate in the GPU
+            process about newly added audio and video tracks.
+
+            * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
+            (WebCore::SourceBufferPrivateAVFObjC::didParseInitializationData):
+
 2021-05-19  Alan Coon  <alanc...@apple.com>
 
         Cherry-pick r277665. rdar://problem/78224090

Modified: branches/safari-612.1.15.1-branch/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm (277794 => 277795)


--- branches/safari-612.1.15.1-branch/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm	2021-05-20 17:32:31 UTC (rev 277794)
+++ branches/safari-612.1.15.1-branch/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm	2021-05-20 17:32:35 UTC (rev 277795)
@@ -409,6 +409,9 @@
         if (!weakThis)
             return;
 
+        if (auto player = this->player())
+            player->characteristicsChanged();
+
         if  (m_mediaSamples.isEmpty()) {
             m_initializationSegmentIsHandled = true;
             ALWAYS_LOG(LOGIDENTIFIER, "initialization segment is handled");
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to