Repository navigation
[flutter_tools] Add flutter capture command with screenshot/recording subcommands - #190953
GhagSagar23 wants to merge 8 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new capture command to the Flutter tool, enabling users to take screenshots (flutter capture image) and record screens (flutter capture video) across Android, iOS, iOS Simulators, and macOS devices, while deprecating the old screenshot command. Feedback on the changes highlights critical issues, including incorrect usage of ProcessSignal.kill (which should be process.kill), potential error masking during Android recording failures, and the need to gracefully handle Ctrl-C signals to ensure recording cleanup and file retrieval can complete. Additionally, suggestions were made to simplify redundant file existence checks and capture stderr on macOS recording failures to improve diagnostics.
0585423 to
963368c
Compare
4a3e1c1 to
5761726
Compare
|
Tests are failing: |
|
@vashworth All fixed and tests passing locally:
All devices_test.dart (36 tests) and macos_device_test.dart (19 tests) pass. |
|
@bkonyi Could you add the |
083c232 to
e1768e3
Compare
|
@bkonyi Could you add the |
bkonyi
left a comment
There was a problem hiding this comment.
Thanks for the fixes @GhagSagar23! The lib compile errors are fixed, but a few things are still outstanding:
capture_command_test.dartandsimulators_test.dartdon't compile against the latestmaster, which is whyTree_analyzeis failing (inline). Can you rundart analyzeand the touched tests after mergingmaster?- The Android
pkillanddaemon_test.dartcomments from the last round were resolved but aren't addressed yet (inline). Let's keep threads open until they're addressed. - Still pending: the simulator
--durationtest, manual Android and macOS verification, and updating the stale PR description.
|
Thanks for the thorough review @bkonyi! Pushed a rebase onto latest Compilation / CI fixes:
Android
Simulator
Other cleanup:
Test results:
|
|
Hi @bkonyi — all review comments from Nov 4 have been addressed and pushed. Could you add the |
|
looks like the code is not formatted with dart format which causes other tests to not run |
… subcommands Implements `flutter capture screenshot` and `flutter capture recording` as the unified interface for device screenshots and screen recording. - ScreenRecording handle with stop()/done for clean signal handling - Android: adb screenrecord with 180s clamp, exit code check, cleanup - iOS sim: simctl recordVideo with LineSplitter + 10s start timeout - iOS device: devicectl with --json-output outcome verification - macOS: screencapture -v with -V duration flag - Command-agnostic error messages for Xcode version checks - flutter screenshot kept as hidden alias Fixes flutter#190587
…rt, test refactors - ScreenRecording: abstract interface → concrete class with stoppedExitCodes and signalStop callback; removed 4 platform _*ScreenRecording classes - Android: pkill -2 screenrecord on all platforms (not just Windows) - screenshot.dart: reverted to upstream + hidden/const-aliases only - capture.dart: backward-compat comment, argParser cascade, removed misplaced macOS note from --duration help - daemon.dart: added screenRecording to _deviceToMap capabilities - devices.dart: narrowed catch to ProcessException - Tests: deduplicated capture screenshot (5 removed), collapsed exit-code and duration tests into for loops, added JSON error-path + ProcessException tests
Fixes compile errors where _fileSystem on IOSDevice and _processUtils on IOSCoreDeviceControl were undefined — destructure from toolContext/_toolContext matching existing codebase pattern.
Post-merge fix: upstream added analytics/appleContext/featureFlags/ templateRenderer as required params; add to our screenshot/recording tests + import fake_process_manager for hasNoRemainingExpectations.
…stale android test commands
|
Thanks @reidbaker — good catch. Rebased onto latest master, resolved the merge conflicts, and ran dart format across all changed files. The formatting issue in devices.dart is fixed. @bkonyi Could you add the CICD label when you get a chance? Ready for a full test run. |
|
Addressed all 4 comments from the latest review:
Also caught @bkonyi Could you add the CICD label when you get a chance? Thanks! |
|
Manual test results — macOS and Android physical device (Redmi 8A Dual, API 29): Recordings
|
|
Hi @GhagSagar23, it looks like your commit from Nov 7 wasn't pushed ( Also, FYI I already have #196132 up for review for #196119, so no need to include the |





Summary
Implements
flutter capture screenshotandflutter capture recordingas the new unified interface for device screenshots and screen recording (#190587).flutter capture screenshot— wraps per-device screenshot logic (same asflutter screenshot)flutter capture recording— wraps platform-native screen recording with--durationand--out/-oflagsflutter screenshot— kept as a hidden alias, points users toflutter capture screenshotPlatform support
adb screenrecordsimctl recordVideodevicectldevicectlscreencapture -xscreencapture -v-Vflag for duration; captures entire screenKey design decisions
ScreenRecordinghandle returned bystartScreenRecordingwithstop()anddonetoolContext.signals.addHandler(...)withCompleter<void>to keep the tool alive throughadb pull/cleanuptry/finallyensuresadb pullruns even on Ctrl-C, exit code checked before pulling--json-outputto verify outcomeflutter screenshotandflutter capture screenshot)Test plan
capture_command_test.dart— 19 tests (no device, unsupported device, screenshot/Skia success, duration validation,--out,-ddevice selection, SIGINT signal handling, double-SIGINT, empty file)screenshot_command_test.dart— 11 tests (Skia success/disconnected, file validation, device screenshot, multi-device)android_device_test.dart— screenshot + recording tests (success, 180s clamp, pull failure, cleanup, SIGINT/SIGTERM exit codes, Windows pkill fallback)simulators_test.dart— recording success and failuredevices_test.dart— iOS device screenshot/recording (Xcode 27+, devicectl errors, locked device)core_devices_test.dart— devicectl parameter forwarding (duration, json-output)macos_device_test.dart— screenshot/recording with/without duration, failureflutter screenshotstill worksFixes #190587