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 @@ ...@@ -388,9 +388,8 @@
var maxLightGreenPixelsX = 0; var maxLightGreenPixelsX = 0;
var maxLightGreenPixelsY = 0; var maxLightGreenPixelsY = 0;
// TODO(phoglund): don't iterate 10 times - too slow on Windows. var attempt = 0;
var iterations = 0; var maxAttempts = 10;
var maxIterations = 10;
var detectorFunction = function() { var detectorFunction = function() {
var width = videoElement.videoWidth; var width = videoElement.videoWidth;
...@@ -427,23 +426,27 @@ ...@@ -427,23 +426,27 @@
if (lightGreenPixelsY > maxLightGreenPixelsY) if (lightGreenPixelsY > maxLightGreenPixelsY)
maxLightGreenPixelsY = lightGreenPixelsY; maxLightGreenPixelsY = lightGreenPixelsY;
if (++iterations > maxIterations) { // Allow maxLightGreenPixelsY = maxLightGreenPixelsX +-1 due to
clearInterval(detectorInterval); // possible subpixel rendering on Mac and Android.
// Allow maxLightGreenPixelsY = maxLightGreenPixelsX +-1 due to if (maxLightGreenPixelsY > maxLightGreenPixelsX + 1 ||
// possible subpixel rendering on Mac and Android. maxLightGreenPixelsY < maxLightGreenPixelsX -1 ||
if (maxLightGreenPixelsY > maxLightGreenPixelsX + 1 || maxLightGreenPixelsY == 0 ||
maxLightGreenPixelsY < maxLightGreenPixelsX -1 || maxLightGreenPixelsX == width / 2 ||
maxLightGreenPixelsY == 0 || maxLightGreenPixelsY == height / 2) {
maxLightGreenPixelsX == width / 2 || if (++attempt > maxAttempts) {
maxLightGreenPixelsY == height / 2) { clearInterval(detectorInterval);
failTest("Aspect ratio corrupted. X " + maxLightGreenPixelsX + 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); 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