Skip to content

[stable] [flutter_tools] Guard against null vmService and uiIsolate in debugDumpFocusTree and debugDumpLayerTree - #194740

Merged
auto-submit[bot] merged 1 commit into
flutter:flutter-3.47-candidate.0from
flutteractionsbot:cp-stable-da6ba5b2fa1556de255741c52bc3584f63f17598
Oct 21, 2026
Merged

auto-submit[bot] merged 1 commit into
flutter:flutter-3.47-candidate.0from
flutteractionsbot:cp-stable-da6ba5b2fa1556de255741c52bc3584f63f17598

Conversation

@flutteractionsbot

@flutteractionsbot flutteractionsbot commented Oct 19, 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:

#192934

Impact Description:

In flutter run debug sessions, triggering debugDumpFocusTree (f) or debugDumpLayerTree (t) when a FlutterDevice's VM service connection or a FlutterView's attached uiIsolate is null (such as during isolate initialization or teardown) causes an unhandled _TypeError: Null check operator used on a null value crash in flutter_tools. This was observed as a top crasher in Flutter 3.47.3 crash telemetry (28 crashes in the first 7 days post-release).

Changelog Description:

[flutter/192934] When dumping the focus tree or layer tree from flutter run on any platform before the UI isolate finishes initializing or after teardown, flutter_tools crashed with a null check operator exception.

Workaround:

Wait until the app and UI isolate have fully initialized before invoking f (debugDumpFocusTree) or t (debugDumpLayerTree) in the flutter run terminal.

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 flutter test packages/flutter_tools/test/general.shard/terminal_handler_test.dart.
  2. Verify that debugDumpFocusTree and debugDumpLayerTree return gracefully without throwing when vmService or uiIsolate is null.

…mpFocusTree and debugDumpLayerTree (flutter#192940)

## Description

In `ResidentHandlers.debugDumpFocusTree` and
`ResidentHandlers.debugDumpLayerTree`, force unwrapping
`device.vmService` and `view.uiIsolate.id` caused a null check operator
exception when the VM service was null or when a `FlutterView` had no
attached UI isolate (e.g., during initialization or teardown).

This change safely guards `device.vmService` and `view.uiIsolate?.id`
before invoking the respective VM service methods.

## Related Issue

Fixes flutter#192934

## Tests

Adds unit tests in
`packages/flutter_tools/test/general.shard/terminal_handler_test.dart`
verifying that `debugDumpFocusTree` and `debugDumpLayerTree` do not
crash when `vmService` or `uiIsolate` is null.
@flutteractionsbot flutteractionsbot added the cp: review Cherry-picks in the review queue label Oct 19, 2026
@flutteractionsbot

Copy link
Copy Markdown
Contributor Author

@bkonyi please fill out the PR description above, afterwards the release team will review this request.

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Oct 19, 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.

@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Oct 19, 2026

@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 refactors the debugDump methods in ResidentHandlers to use a unified helper method, reducing code duplication and introducing safer null checks for the VM service and UI isolate. Additionally, unit tests have been added to verify that these methods handle null services and isolates without crashing, and that they correctly filter debug-only trees in profile mode. There are no review comments, and I have no further feedback to provide.

@bkonyi bkonyi changed the title [CP-stable][flutter_tools] Guard against null vmService and uiIsolate in debugDumpFocusTree and debugDumpLayerTree [stable] [flutter_tools] Guard against null vmService and uiIsolate in debugDumpFocusTree and debugDumpLayerTree Oct 19, 2026
@walley892 walley892 added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 21, 2026
@auto-submit
auto-submit Bot merged commit abe8675 into flutter:flutter-3.47-candidate.0 Oct 21, 2026
12 checks passed
@flutteractionsbot
flutteractionsbot deleted the cp-stable-da6ba5b2fa1556de255741c52bc3584f63f17598 branch October 21, 2026 23:13
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 tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants