Commit 517b092b authored by Kenneth Russell's avatar Kenneth Russell Committed by Commit Bot

Fix and strengthen dual-GPU pixel tests.

Previously they were not checking whether they were running on the
expected GPU (low-power or high-performance). In fact, they were
accidentally misconfigured in test_suites.pyl, and were not exercising
the desired code paths on the bots.

Stop forcing the discrete GPU when running the pixel tests - allow
them to use the natural GPU configuration of the browser - and make
assertions about which GPU is active at various points during the
low-to-high-power and high-to-low-power tests.

Bug: 1047573
Change-Id: Icdb85c6fe2625ccce489f8bba4c053f5248e1e55
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2032190
Commit-Queue: Kenneth Russell <kbr@chromium.org>
Reviewed-by: default avatarJames Darpinian <jdarpinian@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738051}
parent e48e8274
......@@ -20,12 +20,17 @@ const fragmentShader = [
let gl;
function logOutput(s) {
if (window.domAutomationController)
window.domAutomationController.log(s);
else
console.log(s);
}
function sendResult(status, detail) {
console.log(detail);
logOutput(status + ' ' + detail);
if (window.domAutomationController) {
window.domAutomationController.send(status);
} else {
console.log(status);
}
}
......@@ -108,7 +113,8 @@ function setup(opt_attribs)
initGL(canvas, opt_attribs);
if (gl && setupGL(gl))
return true;
domAutomationController.send("FAILURE");
if (window.domAutomationController)
window.domAutomationController.send('FAILURE');
return false;
}
......@@ -127,3 +133,62 @@ function drawSomeFrames(callback)
window.requestAnimationFrame(drawSomeFramesHelper);
}
let _runningOnDualGPUSystem = false;
function setRunningOnDualGpuSystem() {
_runningOnDualGPUSystem = true;
}
function isRunningOnDualGpuSystem() {
return _runningOnDualGPUSystem;
}
function getUnmaskedVendor() {
let ext = gl.getExtension('WEBGL_debug_renderer_info');
return gl.getParameter(ext.UNMASKED_VENDOR_WEBGL);
}
function getSplitUnmaskedVendor() {
let vendor = getUnmaskedVendor().toLowerCase();
// Like:
// Intel Inc.
// ATI Technologies Inc.
// Renderer would be like:
// Intel(R) HD Graphics 630
// AMD Radeon Pro 560 OpenGL Engine
// Handle parentheses just in case.
return vendor.split(/[ ()]/);
}
function assertRunningOnLowPowerGpu() {
if (!isRunningOnDualGpuSystem())
return false;
let tokens = getSplitUnmaskedVendor();
if (tokens.includes('intel')) {
logOutput('System was correctly running on Intel integrated GPU');
return true;
}
sendResult(
'FAIL',
'System wasn\'t running on Intel integrated GPU: vendor = ' +
getUnmaskedVendor());
return false;
}
function assertRunningOnHighPerformanceGpu() {
if (!isRunningOnDualGpuSystem())
return false;
let tokens = getSplitUnmaskedVendor();
if (tokens.includes('ati') || tokens.includes('amd') ||
tokens.includes('nvidia')) {
logOutput(
'System was correctly running on discrete GPU: ' + getUnmaskedVendor());
return true;
}
sendResult(
'FAIL',
'System wasn\'t running on discrete GPU: vendor = ' +
getUnmaskedVendor());
return false;
}
......@@ -16,16 +16,27 @@ function ready() {
sendResult("READY", "Ready for second tab to be launched");
}
function initialize() {
function initialize(runningOnDualGPUMacBookPro) {
if (runningOnDualGPUMacBookPro)
setRunningOnDualGpuSystem();
if (setup())
drawSomeFrames(notifyHarness);
}
function notifyHarness() {
if (!assertRunningOnHighPerformanceGpu())
return;
sendResult("READY", "Ready for second tab to be closed");
}
function runToCompletion() {
if (!assertRunningOnLowPowerGpu()) {
// This test expects to be notified even on non-dual-GPU systems.
if (isRunningOnDualGpuSystem()) {
// Failure has been reported.
return;
}
}
drawSomeFrames(waitForFinish);
}
......
......@@ -12,18 +12,36 @@
<script src="pixel_webgl_fullscreen_quad.js"></script>
<script>
function main() {
function ready() {
sendResult("READY", "Ready for initialize() to be called");
}
function initialize(runningOnDualGPUMacBookPro) {
if (runningOnDualGPUMacBookPro)
setRunningOnDualGpuSystem();
if (setup())
drawSomeFrames(allocateHighPowerContext);
}
function allocateHighPowerContext() {
if (!assertRunningOnLowPowerGpu()) {
// This test expects to be notified even on non-dual-GPU systems.
if (!isRunningOnDualGpuSystem()) {
// Will override failure report on dual-GPU systems.
waitForFinish();
}
return;
}
c2.getContext("webgl", { powerPreference: "high-performance" });
// On macOS there is an approximately two second delay between activating the
// discrete GPU and applications receiving a notification of its activation.
// Avoid a race condition, and test flakiness, by waiting for twice as long as
// this delay.
setTimeout(() => { drawSomeFrames(waitForFinish) }, 4000);
setTimeout(() => {
if (!assertRunningOnHighPerformanceGpu())
return;
drawSomeFrames(waitForFinish);
}, 4000);
}
function waitForFinish()
......@@ -42,7 +60,7 @@ function waitForFinish()
}
</script>
</head>
<body onload="main()">
<body onload="ready()">
<canvas id="c" width="300" height="300" class="nomargin" style="position:absolute; top:0px; left:0px;"></canvas>
<canvas id="c2" width="1" height="1" class="nomargin"></canvas>
</div>
......
......@@ -12,19 +12,36 @@
<script src="pixel_webgl_fullscreen_quad.js"></script>
<script>
function main() {
function ready() {
sendResult("READY", "Ready for initialize() to be called");
}
function initialize(runningOnDualGPUMacBookPro) {
if (runningOnDualGPUMacBookPro)
setRunningOnDualGpuSystem();
if (setup({ alpha: false }))
drawSomeFrames(allocateHighPowerContext);
}
function allocateHighPowerContext() {
if (!assertRunningOnLowPowerGpu()) {
// This test expects to be notified even on non-dual-GPU systems.
if (!isRunningOnDualGpuSystem()) {
// Will override failure report on dual-GPU systems.
waitForFinish();
}
return;
}
c2.getContext("webgl", { powerPreference: "high-performance" });
// On macOS there is an approximately two second delay between activating the
// discrete GPU and applications receiving a notification of its activation.
// Avoid a race condition, and test flakiness, by waiting for twice as long as
// this delay.
setTimeout(() => { drawSomeFrames(waitForFinish) }, 4000);
setTimeout(() => {
if (!assertRunningOnHighPerformanceGpu())
return;
drawSomeFrames(waitForFinish);
}, 4000);
}
function waitForFinish()
......@@ -43,7 +60,7 @@ function waitForFinish()
}
</script>
</head>
<body onload="main()">
<body onload="ready()">
<canvas id="c" width="300" height="300" class="nomargin" style="position:absolute; top:0px; left:0px;"></canvas>
<canvas id="c2" width="1" height="1" class="nomargin"></canvas>
</div>
......
......@@ -21,6 +21,13 @@ test_harness_script = r"""
domAutomationController._readyForActions = false;
domAutomationController._succeeded = false;
domAutomationController._finished = false;
domAutomationController._originalLog = window.console.log;
domAutomationController._messages = '';
domAutomationController.log = function(msg) {
domAutomationController._messages += msg + "\n";
domAutomationController._originalLog.apply(window.console, [msg]);
}
domAutomationController.send = function(msg) {
domAutomationController._proceed = true;
......@@ -134,6 +141,9 @@ class PixelIntegrationTest(
tab, page,
build_id_args=build_id_args)
finally:
test_messages = self._TestHarnessMessages(tab)
if test_messages:
logging.info('Logging messages from the test:\n' + test_messages)
if do_page_action or page.restart_browser_after_test:
self._RestartBrowser(
'Must restart after page actions or if required by test')
......@@ -145,6 +155,9 @@ class PixelIntegrationTest(
tab.action_runner.WaitForJavaScriptCondition(
'domAutomationController._finished', timeout=300)
def _TestHarnessMessages(self, tab):
return tab.EvaluateJavaScript('domAutomationController._messages')
#
# Optional actions pages can take.
# These are specified as methods taking the tab and the page as
......@@ -175,7 +188,7 @@ class PixelIntegrationTest(
# Short-circuit this test.
logging.info('Short-circuiting test because not running on dual-GPU Mac '
'laptop')
tab.EvaluateJavaScript('initialize()')
tab.EvaluateJavaScript('initialize(false)')
tab.action_runner.WaitForJavaScriptCondition(
'domAutomationController._readyForActions', timeout=30)
tab.EvaluateJavaScript('runToCompletion()')
......@@ -195,7 +208,7 @@ class PixelIntegrationTest(
# Switch back to the main tab and quickly start its rendering, while the
# high-power GPU is still active.
tab.Activate()
tab.EvaluateJavaScript('initialize()')
tab.EvaluateJavaScript('initialize(true)')
tab.action_runner.WaitForJavaScriptCondition(
'domAutomationController._readyForActions', timeout=30)
# Close the high-performance tab.
......@@ -206,6 +219,13 @@ class PixelIntegrationTest(
# Run the page to completion.
tab.EvaluateJavaScript('runToCompletion()')
def _RunLowToHighPowerTest(self, tab, page):
is_dual_gpu = self._IsDualGPUMacLaptop()
tab.EvaluateJavaScript('initialize(' +
('true' if is_dual_gpu else 'false') + ')')
# The harness above will take care of waiting for the test to
# complete with either a success or failure.
@classmethod
def ExpectationsFiles(cls):
return [
......
......@@ -1253,7 +1253,7 @@ class PixelTestPages(object):
'color': [0, 255, 0],
}
],
restart_browser_after_test=True),
optional_action='RunLowToHighPowerTest'),
PixelTestPage(
'pixel_webgl_low_to_high_power_alpha_false.html',
......@@ -1268,7 +1268,7 @@ class PixelTestPages(object):
'color': [0, 255, 0],
}
],
restart_browser_after_test=True),
optional_action='RunLowToHighPowerTest'),
]
@staticmethod
......
......@@ -102,8 +102,7 @@ crbug.com/660461 [ mac ] Pixel_ScissorTestWithPreserveDrawingBuffer [ RetryOnFai
crbug.com/773293 [ android no-use-gl qualcomm-adreno-(tm)-330 ] Pixel_WebGL2_BlitFramebuffer_Result_Displayed [ Skip ]
crbug.com/773293 [ android qualcomm-adreno-(tm)-330 ] Pixel_WebGL2_ClearBufferfv_Result_Displayed [ Skip ]
crbug.com/774809 [ highsierra intel-0xa2e ] Pixel_WebGLGreenTriangle_NonChromiumImage_NoAA_NoAlpha [ Failure ]
crbug.com/774809 [ mojave intel-0xa2e ] Pixel_WebGLGreenTriangle_NonChromiumImage_NoAA_NoAlpha [ Failure ]
crbug.com/774809 [ mac intel ] Pixel_WebGLGreenTriangle_NonChromiumImage_NoAA_NoAlpha [ Failure ]
crbug.com/857578 [ highsierra intel-0xa2e ] Pixel_OffscreenCanvasTransferBeforeStyleResize [ RetryOnFailure ]
......
This diff is collapsed.
......@@ -208,7 +208,7 @@
"--browser=android-chromium",
"--passthrough",
"-v",
"--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --force_high_performance_gpu",
"--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc",
"--dont-restore-color-profile-after-test",
"--build-revision",
"${got_revision}",
......@@ -767,7 +767,7 @@
"--browser=debug",
"--passthrough",
"-v",
"--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --force_high_performance_gpu",
"--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc",
"--dont-restore-color-profile-after-test",
"--build-revision",
"${got_revision}",
......@@ -1321,7 +1321,7 @@
"--browser=release",
"--passthrough",
"-v",
"--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --force_high_performance_gpu",
"--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc",
"--dont-restore-color-profile-after-test",
"--build-revision",
"${got_revision}",
......@@ -1859,7 +1859,7 @@
"--browser=debug",
"--passthrough",
"-v",
"--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --force_high_performance_gpu",
"--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc",
"--dont-restore-color-profile-after-test",
"--build-revision",
"${got_revision}",
......@@ -2388,7 +2388,7 @@
"--browser=release",
"--passthrough",
"-v",
"--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --force_high_performance_gpu",
"--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc",
"--dont-restore-color-profile-after-test",
"--build-revision",
"${got_revision}",
......@@ -2944,7 +2944,7 @@
"--browser=debug",
"--passthrough",
"-v",
"--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --force_high_performance_gpu",
"--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc",
"--dont-restore-color-profile-after-test",
"--build-revision",
"${got_revision}",
......@@ -3511,7 +3511,7 @@
"--browser=release",
"--passthrough",
"-v",
"--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --force_high_performance_gpu",
"--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc",
"--dont-restore-color-profile-after-test",
"--build-revision",
"${got_revision}",
......@@ -4112,7 +4112,7 @@
"--browser=debug_x64",
"--passthrough",
"-v",
"--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --force_high_performance_gpu",
"--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc",
"--dont-restore-color-profile-after-test",
"--build-revision",
"${got_revision}",
......@@ -4857,7 +4857,7 @@
"--browser=release_x64",
"--passthrough",
"-v",
"--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --force_high_performance_gpu",
"--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc",
"--dont-restore-color-profile-after-test",
"--build-revision",
"${got_revision}",
......@@ -5698,7 +5698,7 @@
"--browser=release_x64",
"--passthrough",
"-v",
"--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --force_high_performance_gpu",
"--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc",
"--dont-restore-color-profile-after-test",
"--build-revision",
"${got_revision}",
......
......@@ -169,7 +169,7 @@
"--browser=android-chromium",
"--passthrough",
"-v",
"--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --force_high_performance_gpu",
"--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc",
"--dont-restore-color-profile-after-test",
"--build-revision",
"${got_cr_revision}",
......@@ -491,7 +491,7 @@
"--browser=release",
"--passthrough",
"-v",
"--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --force_high_performance_gpu",
"--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc",
"--dont-restore-color-profile-after-test",
"--build-revision",
"${got_cr_revision}",
......@@ -809,7 +809,7 @@
"--browser=release",
"--passthrough",
"-v",
"--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --force_high_performance_gpu",
"--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc",
"--dont-restore-color-profile-after-test",
"--build-revision",
"${got_cr_revision}",
......@@ -1122,7 +1122,7 @@
"--browser=release",
"--passthrough",
"-v",
"--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --force_high_performance_gpu",
"--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc",
"--dont-restore-color-profile-after-test",
"--build-revision",
"${got_cr_revision}",
......@@ -1772,7 +1772,7 @@
"--browser=release",
"--passthrough",
"-v",
"--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --force_high_performance_gpu",
"--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc",
"--dont-restore-color-profile-after-test",
"--build-revision",
"${got_cr_revision}",
......
......@@ -2308,8 +2308,6 @@
'${got_revision}',
'--test-machine-name',
'${buildername}',
# On dual-GPU devices we want the high-performance GPU to be active
'--extra-browser-args=--force_high_performance_gpu',
],
'precommit_args': [
# Gerrit issue ID
......
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