Skip to content

Commit

Permalink
NEW TEST(265708@main): [ wk2 ] fast/mediastream/video-srcObject-set-t…
Browse files Browse the repository at this point in the history
…wice.html is a flaky ImageOnlyFailure.

https://bugs.webkit.org/show_bug.cgi?id=261920
rdar://115868374

Reviewed by Jean-Yves Avenard.

The flakiness comes from the fact that the canvas capture video frame is not always properly rendered.
While we should fix this, we can make the test no longer flaky by relying on the existing take snapshot test.
This keeps the current coverage of the test which is to check that setting twice srcObject will still allow rendering video.

* LayoutTests/fast/mediastream/video-srcObject-set-twice-expected.html: Removed.
* LayoutTests/fast/mediastream/video-srcObject-set-twice-expected.txt: Added.
* LayoutTests/fast/mediastream/video-srcObject-set-twice.html:
* LayoutTests/platform/wk2/TestExpectations:

Canonical link: https://commits.webkit.org/268908@main
  • Loading branch information
youennf committed Oct 5, 2023
1 parent 6edb285 commit a8801ed
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 49 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@



PASS Validate second srcObject is being rendered

59 changes: 29 additions & 30 deletions LayoutTests/fast/mediastream/video-srcObject-set-twice.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<!-- webkit-test-runner [ dumpJSConsoleLogInStdErr=true ] -->
<!doctype html>
<html>
<head>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
</head>
<body>
<div>
<canvas id="canvas1" width=100 height=100></canvas>
<canvas id="canvas2" width=100 height=100></canvas>
Expand All @@ -7,9 +13,6 @@
<br>
<image id='image'></image>
<script>
if (window.testRunner)
testRunner.waitUntilDone();

function getPixel(x, y, canvas, data)
{
const position = 4 * (x * canvas.width + y);
Expand All @@ -22,6 +25,12 @@
return pixel.r === 0 && pixel.g === 128 && pixel.b === 0;
}

function isPixelAlmostGreen(x, y, canvas, data)
{
const pixel = getPixel(x, y, canvas, data);
return pixel.r <= 64 && pixel.g >= 100 && pixel.g <= 200 && pixel.b <= 64;
}

function isPixelWhite(x, y, canvas, data)
{
const pixel = getPixel(x, y, canvas, data);
Expand All @@ -30,7 +39,6 @@

async function validateSnapshot()
{
console.log("validateSnapshot-1 ");
if (!window.testRunner)
return true;
const dataURL = await new Promise(resolve => testRunner.takeViewPortSnapshot(resolve));
Expand All @@ -42,49 +50,40 @@
});
image.src = dataURL;
await loadPromise;
console.log("validateSnapshot0 ");

const canvas = document.createElement("canvas");
canvas.width = image.width;
canvas.height = image.height;
canvas.getContext('2d').drawImage(image, 0, 0);
const data = canvas.getContext('2d').getImageData(0, 0, canvas.width, canvas.height).data;

console.log("validateSnapshot1 ");

// We inspect the vertial line at pixel 50. We should get white, then green, then white, then green, then white.
// We inspect the vertial line at pixel 50. We should get white, then green, then white, then almost green (encoder might change a bit the color), then white.
const verticalLine = 50;
let i = 0;

console.log("validateSnapshot2 " + i);
if (!isPixelWhite(i, 50, canvas, data))
if (!isPixelWhite(i, verticalLine, canvas, data))
return false;
while (isPixelWhite(++i, 50, canvas, data)) { };
while (isPixelWhite(++i, verticalLine, canvas, data)) { };

console.log("validateSnapshot3 " + i);
if (!isPixelGreen(i, 50, canvas, data))
if (!isPixelGreen(i, verticalLine, canvas, data))
return false;
while (isPixelGreen(++i, 50, canvas, data)) { };
while (isPixelGreen(++i, verticalLine, canvas, data)) { };

console.log("validateSnapshot4 " + i);
if (!isPixelWhite(i, 50, canvas, data))
if (!isPixelWhite(i, verticalLine, canvas, data))
return false;
while (isPixelWhite(++i, 50, canvas, data)) { };
while (isPixelWhite(++i, verticalLine, canvas, data)) { };

console.log("validateSnapshot5 " + i);
if (!isPixelGreen(i, 50, canvas, data))
if (!isPixelAlmostGreen(i, verticalLine, canvas, data))
return false;
while (isPixelGreen(++i, 50, canvas, data)) { };
while (isPixelAlmostGreen(++i, verticalLine, canvas, data)) { };

console.log("validateSnapshot6 " + i);
if (!isPixelWhite(i, 50, canvas, data))
if (!isPixelWhite(i, verticalLine, canvas, data))
return false;

console.log("validateSnapshot7 " + i);
return true;
}

async function test()
{
promise_test(async () => {
const context1 = canvas1.getContext('2d');
setInterval(() => {
context1.fillStyle = "green";
Expand Down Expand Up @@ -114,9 +113,9 @@
} catch (e) {
}
}
assert_true(result);
image.parentNode.removeChild(image);
if (window.testRunner)
testRunner.notifyDone();
}
test();
}, "Validate second srcObject is being rendered")
</script>
</body>
</html>
2 changes: 0 additions & 2 deletions LayoutTests/platform/wk2/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -884,8 +884,6 @@ webkit.org/b/260834 imported/w3c/web-platform-tests/webcodecs/videoFrame-canvasI

webkit.org/b/260926 imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/form-submit-button-click.html [ Pass Failure ]

webkit.org/b/261920 fast/mediastream/video-srcObject-set-twice.html [ Pass ImageOnlyFailure ]

webkit.org/b/262088 [ Debug ] imported/w3c/web-platform-tests/fetch/private-network-access/iframe.tentative.https.window.html [ Pass Failure ]

webkit.org/b/262157 imported/w3c/web-platform-tests/css/css-contain/content-visibility/content-visibility-video.html [ Pass ImageOnlyFailure Crash ]
Expand Down

0 comments on commit a8801ed

Please sign in to comment.