Repository navigation
[stable] [flutter_tools] Handle RPCError in ScreenshotCommand.runSkia - #196796
auto-submit[bot] merged 1 commit into
Conversation
…#196132) Previously, running `flutter screenshot --type=skia` against an application with Impeller enabled crashed with an unhandled `vm_service.RPCError` (`-32000`) because the engine rejects `_flutter.screenshotSkp` requests under Impeller and `ScreenshotCommand.runSkia` did not catch `RPCError`. Catch `vm_service.RPCError` in `ScreenshotCommand.runSkia` and exit cleanly via `throwToolExit` with the engine's error message. Previous output: ``` _flutter.screenshotSkp: (-32000) Cannot capture SKP screenshot with Impeller enabled. #0 new _OutstandingRequest (package:vm_service/src/vm_service.dart:280:34) #1 VmService._call.<anonymous closure> (package:vm_service/src/vm_service.dart:1962:25) #2 VmService._call (package:vm_service/src/vm_service.dart:1974:8) #3 VmService.callServiceExtension (package:vm_service/src/vm_service.dart:1905:14) #4 FlutterVmService._checkedCallServiceExtension (package:flutter_tools/src/vmservice.dart:835:28) #5 FlutterVmService.screenshotSkp (package:flutter_tools/src/vmservice.dart:1069:12) #6 ScreenshotCommand.runSkia (package:flutter_tools/src/commands/screenshot.dart:167:54) <asynchronous suspension> flutter#7 ScreenshotCommand.runCommand (package:flutter_tools/src/commands/screenshot.dart:123:19) <asynchronous suspension> flutter#8 FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:876:27) <asynchronous suspension> flutter#9 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:174:19) <asynchronous suspension> flutter#10 CommandRunner.runCommand (package:args/command_runner.dart:212:13) <asynchronous suspension> flutter#11 FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:689:9) <asynchronous suspension> flutter#12 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:174:19) <asynchronous suspension> flutter#13 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:619:5) <asynchronous suspension> flutter#14 FlutterCommandRunner.run (package:flutter_tools/src/runner/flutter_command_runner.dart:379:5) <asynchronous suspension> flutter#15 run.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:419:19) <asynchronous suspension> flutter#16 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:174:19) <asynchronous suspension> flutter#17 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:174:19) <asynchronous suspension> flutter#18 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:174:19) <asynchronous suspension> flutter#19 main (package:flutter_tools/executable.dart:133:3) <asynchronous suspension> Feature flags enabled: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, enable-record-use, enable-swift-package-manager, omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration, enable-riscv64, enable-hcpp ``` Current output: ``` The Skia picture request failed: Cannot capture SKP screenshot with Impeller enabled. ``` Fixes flutter#196119
|
This pull request was opened from and to a release candidate branch. This should only be done as part of the official Flutter release process. If you are attempting to make a regular contribution to the Flutter project, please close this PR and follow the instructions at Tree Hygiene for detailed instructions on contributing to Flutter. Reviewers: Use caution before merging pull requests to release branches. Ensure the proper procedure has been followed. |
There was a problem hiding this comment.
Code Review
This pull request updates the screenshot command to catch vm_service.RPCError during Skia picture requests and throw a ToolExit with a descriptive error message. It also introduces corresponding unit and integration tests to verify this behavior under different rendering configurations. Feedback on the changes suggests merging platform.environment into the custom environment map when spawning the screenshot process in the integration test to avoid potential execution failures on Windows due to missing essential environment variables.
| '--out=${outputFile.path}', | ||
| ], | ||
| workingDirectory: tempDir.path, | ||
| environment: <String, String>{'BOT': 'true', 'FLUTTER_ROOT': flutterRoot}, |
There was a problem hiding this comment.
When spawning a process with a custom environment map in Dart, the parent process's environment is completely replaced rather than merged. This can cause the child process to fail on some platforms (especially Windows) due to missing essential environment variables like PATH or SystemRoot. It is safer to merge platform.environment into the custom environment map.
environment: <String, String>{
...platform.environment,
'BOT': 'true',
'FLUTTER_ROOT': flutterRoot,
},|
autosubmit label was removed for flutter/flutter/196796, because - The status or check suite Presubmit has failed. Please fix the issues identified (or deflake) before re-applying this label. |
|
Failures were timeouts, I've rerun them. |
82c0d5e
into
flutter:flutter-3.50-candidate.0
Adds `CHANGELOG.md` entries for the 3.50.1 stable hotfix (#196756, #196721, #196127, #196035, #196418, #196800, #196796, #196895, #196383, #196923). Omits the infra-only #196760 and the `engine.version` sync #196932. Tracker: #196743 ### Edits to cherry-pick changelog descriptions - All entries use the cherry-pick PR's "Changelog Description" verbatim, except for backticks around code terms (#196756, #196418, #196895, #196923) and a comma and trailing period in the #196418 entry. - #196923 also cherry-picks #195006, so it has two entries, as listed in its "Changelog Description". If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.
This pull request is created by automatic cherry pick workflow
Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request.
Issue Link:
#196119
Impact Description:
Impacts development workflow (top
flutter_toolscrasher). Runningflutter screenshot --type=skiaagainst an Impeller-enabled application causes the VM service_flutter.screenshotSkprequest to reject withRPCError (-32000): Cannot capture SKP screenshot with Impeller enabled.BecauseScreenshotCommand.runSkiadid not catchRPCError,flutter_toolscrashes with an unhandled exception instead of exiting cleanly with aToolExitmessage. Does not impact shipping production applications.Conflict Resolution (
stable): Cherry-pick of #196132 ontoflutter-3.50-candidate.0resolved conflicts and3.50API differences by:dev/bots/tool_test_durations.json(modify/delete conflict; added onmasterafter3.50branched).3.50'sVMServiceConnectorsignature (withoutFlutterVersion? flutterVersion) inpackages/flutter_tools/lib/src/commands/screenshot.dartandpackages/flutter_tools/test/commands.shard/hermetic/screenshot_command_test.dart.packages/flutter_tools/test/integration.shard/screenshot_test.dartto3.50'sArtifacts.getLocalEnginenamed parameters andCache.testconstructor (rootOverride:withoutflutterRoot:).Changelog Description:
[flutter/196119] When running
flutter screenshot --type=skiaagainst an application with Impeller enabled on platforms supporting Impeller,flutter_toolscrashes with an unhandledRPCError(-32000).Workaround:
Run the application with
--no-enable-impellerwhen capturing a Skia picture (--type=skia), or capture a device/rasterizer screenshot (--type=deviceor--type=rasterizer) instead.Risk:
What is the risk level of this cherry-pick?
Test Coverage:
Are you confident that your fix is well-tested by automated tests?
Validation Steps:
packages/flutter_tools:dart test test/commands.shard/hermetic/screenshot_command_test.dartdart test test/integration.shard/screenshot_test.dartflutter screenshot --type=skia --vm-service-url=<uri>, and verifyflutter_toolsexits cleanly withThe Skia picture request failed: Cannot capture SKP screenshot with Impeller enabled.instead of crashing with an unhandledRPCError.