Commit 839a0eb5 authored by phoglund's avatar phoglund Committed by Commit bot

Re-enable local video test with better logging and higher tolerance.

The test appears to get stuck on waiting for black frames. This patch
adds some logging so we perhaps can learn more where in the image we
find the nonblack pixels. Also trying to increase tolerance for
rounding errors somewhat to see if that helps.

BUG=477498

Review URL: https://codereview.chromium.org/1108803002

Cr-Commit-Position: refs/heads/master@{#329616}
parent 81834cca
...@@ -144,9 +144,15 @@ IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcBrowserTest, ...@@ -144,9 +144,15 @@ IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcBrowserTest,
} }
// Flaky on TSAN v2. http://crbug.com/408006 // Flaky on TSAN v2. http://crbug.com/408006
// Flaky everywhere: http://crbug.com/477498 #if defined(THREAD_SANITIZER)
#define MAYBE_CanSetupVideoCallAndDisableLocalVideo \
DISABLED_CanSetupVideoCallAndDisableLocalVideo
#else
#define MAYBE_CanSetupVideoCallAndDisableLocalVideo \
CanSetupVideoCallAndDisableLocalVideo
#endif
IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcBrowserTest, IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcBrowserTest,
DISABLED_CanSetupVideoCallAndDisableLocalVideo) { MAYBE_CanSetupVideoCallAndDisableLocalVideo) {
const std::string javascript = const std::string javascript =
"callAndDisableLocalVideo({video: true});"; "callAndDisableLocalVideo({video: true});";
MakeTypicalPeerConnectionCall(javascript); MakeTypicalPeerConnectionCall(javascript);
......
...@@ -66,9 +66,14 @@ function detectVideo(videoElementName, predicate, callback) { ...@@ -66,9 +66,14 @@ function detectVideo(videoElementName, predicate, callback) {
var width = VIDEO_TAG_WIDTH; var width = VIDEO_TAG_WIDTH;
var height = VIDEO_TAG_HEIGHT; var height = VIDEO_TAG_HEIGHT;
var videoElement = $(videoElementName); var videoElement = $(videoElementName);
var canvas = $(videoElementName + '-canvas');
var oldPixels = []; var oldPixels = [];
var startTimeMs = new Date().getTime();
var waitVideo = setInterval(function() { var waitVideo = setInterval(function() {
var canvas = $(videoElementName + '-canvas');
if (canvas == null) {
console.log('Waiting for ' + videoElementName + '-canvas' + ' to appear');
return;
}
var context = canvas.getContext('2d'); var context = canvas.getContext('2d');
context.drawImage(videoElement, 0, 0, width, height); context.drawImage(videoElement, 0, 0, width, height);
var pixels = context.getImageData(0, 0 , width, height / 3).data; var pixels = context.getImageData(0, 0 , width, height / 3).data;
...@@ -82,6 +87,12 @@ function detectVideo(videoElementName, predicate, callback) { ...@@ -82,6 +87,12 @@ function detectVideo(videoElementName, predicate, callback) {
callback(videoElement.videoWidth, videoElement.videoHeight); callback(videoElement.videoWidth, videoElement.videoHeight);
} }
oldPixels = pixels; oldPixels = pixels;
var elapsedTime = new Date().getTime() - startTimeMs;
if (elapsedTime > 3000) {
startTimeMs = new Date().getTime();
console.log('Still waiting for video to satisfy ' + predicate.toString());
}
}, 200); }, 200);
} }
...@@ -186,12 +197,19 @@ function isVideoPlaying(pixels, previousPixels) { ...@@ -186,12 +197,19 @@ function isVideoPlaying(pixels, previousPixels) {
return false; return false;
} }
// Pixels is an array where pixels[0] is the R value for the first pixel,
// pixels[1] is the G value, and so on.
function isVideoBlack(pixels) { function isVideoBlack(pixels) {
for (var i = 0; i < pixels.length; i++) { for (var i = 0; i < pixels.length; i++) {
// |pixels| is in RGBA. Ignore the alpha channel. if ((i + 1) % 4 == 0) {
// We allow it to be off by 1, to account for rounding errors in YUV // Ignore the alpha channel.
// conversion. continue;
if (pixels[i] != 0 && pixels[i] != 1 && (i + 1) % 4 != 0) { }
// A black pixel has 0 for R,G and B but allow a bit more here to account
// for rounding errors in libyuv.
if (pixels[i] > 3) {
console.log('Found nonblack pixel at ' + i + ', was ' + pixels[i]);
return false; return false;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment