Commit d877c645 authored by phoglund's avatar phoglund Committed by Commit bot

Massively speed up aspect ratio-detecting WebRTC tests.

This improves the execution speed by a factor 3x, and I think they're
just as correct. Essentially we are waiting until we see a good
aspect ratio, rather than the old behavior which was to wait 10x50 ms
and see if we have a good aspect ratio. This wasn't a problem on fast
machines, but it's a big problem on bots with GPU emulation where
canvas operations are expensive.

BUG=417756
R=perkj@chromium.org,mcasas@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#299073}
parent 92cf3145
......@@ -388,9 +388,8 @@
var maxLightGreenPixelsX = 0;
var maxLightGreenPixelsY = 0;
// TODO(phoglund): don't iterate 10 times - too slow on Windows.
var iterations = 0;
var maxIterations = 10;
var attempt = 0;
var maxAttempts = 10;
var detectorFunction = function() {
var width = videoElement.videoWidth;
......@@ -427,23 +426,27 @@
if (lightGreenPixelsY > maxLightGreenPixelsY)
maxLightGreenPixelsY = lightGreenPixelsY;
if (++iterations > maxIterations) {
clearInterval(detectorInterval);
// Allow maxLightGreenPixelsY = maxLightGreenPixelsX +-1 due to
// possible subpixel rendering on Mac and Android.
if (maxLightGreenPixelsY > maxLightGreenPixelsX + 1 ||
maxLightGreenPixelsY < maxLightGreenPixelsX -1 ||
maxLightGreenPixelsY == 0 ||
maxLightGreenPixelsX == width / 2 ||
maxLightGreenPixelsY == height / 2) {
// Allow maxLightGreenPixelsY = maxLightGreenPixelsX +-1 due to
// possible subpixel rendering on Mac and Android.
if (maxLightGreenPixelsY > maxLightGreenPixelsX + 1 ||
maxLightGreenPixelsY < maxLightGreenPixelsX -1 ||
maxLightGreenPixelsY == 0 ||
maxLightGreenPixelsX == width / 2 ||
maxLightGreenPixelsY == height / 2) {
if (++attempt > maxAttempts) {
clearInterval(detectorInterval);
failTest("Aspect ratio corrupted. X " + maxLightGreenPixelsX +
" Y " + maxLightGreenPixelsY);
" Y " + maxLightGreenPixelsY);
}
else {
// We have a bad aspect ratio now; give a chance to shape up.
return;
}
var result = "w=" + width + ":h=" + height;
console.log(result);
callback(result);
}
clearInterval(detectorInterval);
var result = "w=" + width + ":h=" + height;
callback(result);
}
var detectorInterval = setInterval(detectorFunction, 50);
}
......
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