Commit 3857b3d3 authored by Trent Apted's avatar Trent Apted Committed by Chromium LUCI CQ

Deflake MediaAppIntegrationTest.HandleRawFiles.

File loading and app initialization are interleaved. Because
the test Exif file is small, the codepath taken when file loading
"wins" is taken in about 10% of test runs. RAW files need a delegate
to extract an image preview, and this wasn't being set on this codepath
until app initialization. This could cause the test to attempt to load
the RAW file as a JPEG, resulting in a "decode" error.

To fix, ensure a delegate is set along with the file list to load during
app initialization when that codepath is taken.

Bug: 1152318
Cq-Include-Trybots: luci.chrome.try:linux-chromeos-chrome
Change-Id: I12b37c3f6b6228c621fdb36f975200c74da5d227
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2562921Reviewed-by: default avatarBugs Nash <bugsnash@chromium.org>
Commit-Queue: Trent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#832600}
parent 72bff60a
...@@ -214,14 +214,7 @@ IN_PROC_BROWSER_TEST_P(MediaAppIntegrationTest, LoadsPdf) { ...@@ -214,14 +214,7 @@ IN_PROC_BROWSER_TEST_P(MediaAppIntegrationTest, LoadsPdf) {
} }
// Test that the MediaApp can load RAW files passed on launch params. // Test that the MediaApp can load RAW files passed on launch params.
// Disabled on ChromeOS because it fails randomly on linux-chromeos-chrome. IN_PROC_BROWSER_TEST_P(MediaAppIntegrationTest, HandleRawFiles) {
// See: https://crbug.com/1152318
#if BUILDFLAG(IS_CHROMEOS_ASH)
#define MAYBE_HandleRawFiles DISABLED_HandleRawFiles
#else
#define MAYBE_HandleRawFiles HandleRawFiles
#endif
IN_PROC_BROWSER_TEST_P(MediaAppIntegrationTest, MAYBE_HandleRawFiles) {
WaitForTestSystemAppInstall(); WaitForTestSystemAppInstall();
content::WebContents* web_ui; content::WebContents* web_ui;
......
...@@ -198,6 +198,9 @@ mediaApp.ClientApi.prototype.setDelegate = function(delegate) {}; ...@@ -198,6 +198,9 @@ mediaApp.ClientApi.prototype.setDelegate = function(delegate) {};
/** /**
* Launch data that can be read by the app when it first loads. * Launch data that can be read by the app when it first loads.
* @type {{files: mediaApp.AbstractFileList}} * @type {{
* delegate: (mediaApp.ClientApiDelegate | undefined),
* files: mediaApp.AbstractFileList
* }}
*/ */
window.customLaunchData; window.customLaunchData;
...@@ -22,9 +22,13 @@ function loadPiex() { ...@@ -22,9 +22,13 @@ function loadPiex() {
}); });
await loadJs('piex/piex.js.wasm'); await loadJs('piex/piex.js.wasm');
await loadJs('piex_module_scripts.js'); await loadJs('piex_module_scripts.js');
await new Promise(resolve => { if (!PiexModule.calledRun) {
PiexModule['onRuntimeInitialized'] = resolve; // In rare cases in tests (<1%), the runtime is already initialized.
}); // Waiting again for onRuntimeInitialized would hang indefinitely.
await new Promise(resolve => {
PiexModule['onRuntimeInitialized'] = resolve;
});
}
} }
if (!_piexLoadPromise) { if (!_piexLoadPromise) {
_piexLoadPromise = startLoad(); _piexLoadPromise = startLoad();
......
...@@ -270,7 +270,7 @@ async function loadFiles(fileList) { ...@@ -270,7 +270,7 @@ async function loadFiles(fileList) {
await app.loadFiles(fileList); await app.loadFiles(fileList);
} else { } else {
// Note we don't await in this case, which may affect b/152729704. // Note we don't await in this case, which may affect b/152729704.
window.customLaunchData = {files: fileList}; window.customLaunchData.files = fileList;
} }
} }
...@@ -313,6 +313,7 @@ window.addEventListener('DOMContentLoaded', () => { ...@@ -313,6 +313,7 @@ window.addEventListener('DOMContentLoaded', () => {
// Ensure that if no files are loaded into the media app there is a default // Ensure that if no files are loaded into the media app there is a default
// empty file list available. // empty file list available.
window.customLaunchData = { window.customLaunchData = {
delegate: DELEGATE,
files: new ReceivedFileList({files: [], currentFileIndex: -1}) files: new ReceivedFileList({files: [], currentFileIndex: -1})
}; };
......
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