Skip to content

[stable] [flutter_tools] Handle RPCError in ScreenshotCommand.runSkia - #196796

Merged
auto-submit[bot] merged 1 commit into
flutter:flutter-3.50-candidate.0from
bkonyi:cherry-pick-196132-to-stable
Nov 18, 2026
Merged

auto-submit[bot] merged 1 commit into
flutter:flutter-3.50-candidate.0from
bkonyi:cherry-pick-196132-to-stable

Conversation

@bkonyi

@bkonyi bkonyi commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

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_tools crasher). Running flutter screenshot --type=skia against an Impeller-enabled application causes the VM service _flutter.screenshotSkp request to reject with RPCError (-32000): Cannot capture SKP screenshot with Impeller enabled. Because ScreenshotCommand.runSkia did not catch RPCError, flutter_tools crashes with an unhandled exception instead of exiting cleanly with a ToolExit message. Does not impact shipping production applications.

Conflict Resolution (stable): Cherry-pick of #196132 onto flutter-3.50-candidate.0 resolved conflicts and 3.50 API differences by:

  • Removing dev/bots/tool_test_durations.json (modify/delete conflict; added on master after 3.50 branched).
  • Keeping 3.50's VMServiceConnector signature (without FlutterVersion? flutterVersion) in packages/flutter_tools/lib/src/commands/screenshot.dart and packages/flutter_tools/test/commands.shard/hermetic/screenshot_command_test.dart.
  • Adapting packages/flutter_tools/test/integration.shard/screenshot_test.dart to 3.50's Artifacts.getLocalEngine named parameters and Cache.test constructor (rootOverride: without flutterRoot:).

Changelog Description:

[flutter/196119] When running flutter screenshot --type=skia against an application with Impeller enabled on platforms supporting Impeller, flutter_tools crashes with an unhandled RPCError (-32000).

Workaround:

Run the application with --no-enable-impeller when capturing a Skia picture (--type=skia), or capture a device/rasterizer screenshot (--type=device or --type=rasterizer) instead.

Risk:

What is the risk level of this cherry-pick?

  • Low
  • Medium
  • High

Test Coverage:

Are you confident that your fix is well-tested by automated tests?

  • Yes
  • No

Validation Steps:

  1. Run the automated unit and integration tests in packages/flutter_tools:
    • dart test test/commands.shard/hermetic/screenshot_command_test.dart
    • dart test test/integration.shard/screenshot_test.dart
  2. Launch a Flutter app with Impeller enabled, run flutter screenshot --type=skia --vm-service-url=<uri>, and verify flutter_tools exits cleanly with The Skia picture request failed: Cannot capture SKP screenshot with Impeller enabled. instead of crashing with an unhandled RPCError.

…#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
@bkonyi bkonyi added the CICD Run CI/CD label Nov 17, 2026
@flutter-dashboard

Copy link
Copy Markdown

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.

@bkonyi bkonyi added the cp: review Cherry-picks in the review queue label Nov 17, 2026
@bkonyi
bkonyi marked this pull request as ready for review November 17, 2026 18:05

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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,
      },

@justinmc justinmc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@justinmc justinmc added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 18, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 18, 2026
@auto-submit

auto-submit Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

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.

@justinmc

Copy link
Copy Markdown
Contributor

Failures were timeouts, I've rerun them.

@justinmc justinmc added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 18, 2026
@auto-submit
auto-submit Bot merged commit 82c0d5e into flutter:flutter-3.50-candidate.0 Nov 18, 2026
6 checks passed
@victorsanni victorsanni mentioned this pull request Nov 18, 2026
11 tasks done
auto-submit Bot pushed a commit that referenced this pull request Nov 19, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD cp: review Cherry-picks in the review queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants