-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://bugs.webkit.org/show_bug.cgi?id=259298 rdar://112239644 Reviewed by Eric Carlson. YouTube, when pre-rolling an advertisement before a 360 video, will start with an element that's displayed normally, but will hide the video with display:none when switching to canvas-based rendering for 360 videos. But at this point, the MediaPlayerPrivate's layer has already been created and sized, and nothing will force it to switch back to a decompression session (which is the only way for frames to be extracted during playback). When a video element's renderer is detached, queue a task to notify the media player that the accelerated rendering state has changed. Similarly, do so when changing the fullscreen mode. In MediaPlayerPrivateMediaSourceAVFObjC, use this signal to tear down the AVSBDL when it is no longer needed. * LayoutTests/media/media-source/media-source-paint-after-display-none-expected.txt: Added. * LayoutTests/media/media-source/media-source-paint-after-display-none.html: Added. * Source/WebCore/html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::didDetachRenderers): (WebCore::HTMLMediaElement::setFullscreenMode): * Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::shouldEnsureLayer const): Canonical link: https://commits.webkit.org/266162@main
- Loading branch information
Showing
6 changed files
with
137 additions
and
1 deletion.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
LayoutTests/media/media-source/media-source-paint-after-display-none-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
EVENT(sourceopen) | ||
EVENT(canplay) | ||
EXPECTED (canvas.getContext("2d").getImageData(1, 1, 1, 1).data[0] > '128') OK | ||
EXPECTED (canvas.getContext("2d").getImageData(1, 1, 1, 1).data[1] < '128') OK | ||
RUN(video.style.display = "none") | ||
EVENT(canplay) | ||
EVENT(playing) | ||
EXPECTED (canvas.getContext("2d").getImageData(1, 1, 1, 1).data[0] < '128') OK | ||
EXPECTED (canvas.getContext("2d").getImageData(1, 1, 1, 1).data[1] > '128') OK | ||
END OF TEST | ||
|
99 changes: 99 additions & 0 deletions
99
LayoutTests/media/media-source/media-source-paint-after-display-none.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>media-source-stalled-holds-sleep-assertion</title> | ||
<script src="media-source-loader.js"></script> | ||
<script src="../video-test.js"></script> | ||
<script> | ||
|
||
var canvas; | ||
var loader; | ||
var source; | ||
var sourceBuffer; | ||
|
||
function loaderPromise(loader) { | ||
return new Promise((resolve, reject) => { | ||
loader.onload = resolve; | ||
loader.onerror = reject; | ||
}); | ||
} | ||
|
||
function requestVideoFramePromise(video) { | ||
return new Promise(resolve => { | ||
video.requestVideoFrameCallback(info => { | ||
resolve(info); | ||
}); | ||
}); | ||
} | ||
|
||
async function runTest() { | ||
findMediaElement(); | ||
|
||
var response = await fetch('content/test-red-3s-480x360.mp4'); | ||
let redMedia = await response.arrayBuffer(); | ||
|
||
response = await fetch('content/test-green-6s-320x240.mp4'); | ||
let greenMedia = await response.arrayBuffer(); | ||
|
||
source = new MediaSource(); | ||
video.src = URL.createObjectURL(source); | ||
await waitFor(source, 'sourceopen'); | ||
|
||
sourceBuffer = source.addSourceBuffer('video/mp4'); | ||
sourceBuffer.appendBuffer(redMedia); | ||
await Promise.all([ | ||
waitFor(sourceBuffer, 'update', true), | ||
waitFor(video, 'canplay') | ||
]); | ||
|
||
let createCanvas = () => { | ||
canvas = document.createElement('canvas'); | ||
canvas.width = video.videoWidth / 2; | ||
canvas.height = video.videoHeight / 2; | ||
canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height); | ||
return canvas; | ||
} | ||
|
||
canvas = createCanvas(); | ||
await runUntil( | ||
() => canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height), | ||
() => canvas.getContext("2d").getImageData(1, 1, 1, 1).data[0] != 0, | ||
5000); | ||
|
||
testExpected('canvas.getContext("2d").getImageData(1, 1, 1, 1).data[0]', '128', '>'); | ||
testExpected('canvas.getContext("2d").getImageData(1, 1, 1, 1).data[1]', '128', '<'); | ||
|
||
run('video.style.display = "none"'); | ||
sourceBuffer.remove(0, video.duration); | ||
await waitFor(sourceBuffer, 'update', true); | ||
|
||
sourceBuffer.appendBuffer(greenMedia); | ||
await Promise.all([ | ||
waitFor(sourceBuffer, 'update', true), | ||
waitFor(video, 'canplay') | ||
]); | ||
|
||
|
||
video.play(); | ||
await waitFor(video, 'playing'); | ||
|
||
canvas = createCanvas(); | ||
await runUntil( | ||
() => canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height), | ||
() => canvas.getContext("2d").getImageData(1, 1, 1, 1).data[1] != 0, | ||
5000); | ||
|
||
testExpected('canvas.getContext("2d").getImageData(1, 1, 1, 1).data[0]', '128', '<'); | ||
testExpected('canvas.getContext("2d").getImageData(1, 1, 1, 1).data[1]', '128', '>'); | ||
} | ||
|
||
window.addEventListener('load', event => { | ||
runTest().then(endTest).catch(failTest); | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
<video muted playsinline></video> | ||
<div id="canvases"></canvas> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters