-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
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:
flutter/dev/devicelab/lib/framework/utils.dart
Lines 591 to 624 in d7867ca
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
flutter/dev/devicelab/lib/framework/host_agent.dart
Lines 22 to 33 in d7867ca
| /// 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; | |
| } |
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.