Title: [278113] branches/safari-612.1.15.4-branch
- Revision
- 278113
- Author
- repst...@apple.com
- Date
- 2021-05-26 11:48:45 -0700 (Wed, 26 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
Added: branches/safari-612.1.15.4-branch/LayoutTests/media/media-source/media-source-has-audio-video-expected.txt (0 => 278113)
--- branches/safari-612.1.15.4-branch/LayoutTests/media/media-source/media-source-has-audio-video-expected.txt (rev 0)
+++ branches/safari-612.1.15.4-branch/LayoutTests/media/media-source/media-source-has-audio-video-expected.txt 2021-05-26 18:48:45 UTC (rev 278113)
@@ -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.4-branch/LayoutTests/media/media-source/media-source-has-audio-video.html (0 => 278113)
--- branches/safari-612.1.15.4-branch/LayoutTests/media/media-source/media-source-has-audio-video.html (rev 0)
+++ branches/safari-612.1.15.4-branch/LayoutTests/media/media-source/media-source-has-audio-video.html 2021-05-26 18:48:45 UTC (rev 278113)
@@ -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.4-branch/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm (278112 => 278113)
--- branches/safari-612.1.15.4-branch/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm 2021-05-26 18:48:42 UTC (rev 278112)
+++ branches/safari-612.1.15.4-branch/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm 2021-05-26 18:48:45 UTC (rev 278113)
@@ -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