Skip to content

Save screenshots from Android scenario_app in FLUTTER_LOGS_DIR #143586

@matanlurey

Description

@matanlurey

This would significantly help with debugging, because we've seen issues where Skia Gold doesn't always get uploaded artifacts, and also because some emulator versions (cough v28) have been difficult to get working locally but appear to work fine on CI.

@vashworth mentioned to me on Discord:

We do this in the framework - we'll take a screenshot of the device if the test fails:

Future<void> _flutterScreenshot({ String? workingDirectory }) async {
try {
final Directory? dumpDirectory = hostAgent.dumpDirectory;
if (dumpDirectory == null) {
return;
}
// On command failure try uploading screenshot of failing command.
final String screenshotPath = path.join(
dumpDirectory.path,
'device-screenshot-${DateTime.now().toLocal().toIso8601String()}.png',
);
final String deviceId = (await devices.workingDevice).deviceId;
print('Taking screenshot of working device $deviceId at $screenshotPath');
final List<String> args = _flutterCommandArgs(
'screenshot',
<String>[
'--out',
screenshotPath,
'-d', deviceId,
],
);
final ProcessResult screenshot = await _processManager.run(
<String>[path.join(flutterDirectory.path, 'bin', 'flutter'), ...args],
workingDirectory: workingDirectory ?? cwd,
);
if (screenshot.exitCode != 0) {
print('Failed to take screenshot. Continuing.');
}
} catch (exception) {
print('Failed to take screenshot. Continuing.\n$exception');
}
}

See

/// Creates a directory to dump file artifacts.
Directory? get dumpDirectory {
if (_dumpDirectory == null) {
// Set in LUCI recipe.
final String? directoryPath = _platform.environment['FLUTTER_LOGS_DIR'];
if (directoryPath != null) {
_dumpDirectory = _fileSystem.directory(directoryPath)..createSync(recursive: true);
print('Found FLUTTER_LOGS_DIR dump directory ${_dumpDirectory?.path}');
}
}
return _dumpDirectory;
}
as well.

I did ask the infra team if there is any inherent problem (i.e. space/capacity). If it ends up being yes, perhaps we could only do it on failure, or some other conditional flag for debugging.

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work liste: scenario-appThe `testing/scenario_app` fixture in the engineplatform-androidAndroid applications specificallyteam-engineOwned by Engine team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions