Skip to content

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

Merged
auto-submit[bot] merged 7 commits into
flutter:masterfrom
bkonyi:issue-192934
Oct 16, 2026
Merged

auto-submit[bot] merged 7 commits into
flutter:masterfrom
bkonyi:issue-192934

Conversation

@bkonyi

@bkonyi bkonyi commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

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 #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.

…mpFocusTree and debugDumpLayerTree

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).

Safely guard device.vmService and view.uiIsolate?.id before invoking the respective
VM service methods.

Fixes flutter#192934
@bkonyi bkonyi added the CICD Run CI/CD label Sep 17, 2026
@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Sep 17, 2026
…entHandlers

Extract a shared _debugDumpTree helper to guard against null vmService and
uiIsolate across all six debugDump* methods (debugDumpApp, debugDumpRenderTree,
debugDumpLayerTree, debugDumpFocusTree, debugDumpSemanticsTreeInTraversalOrder,
and debugDumpSemanticsTreeInInverseHitTestOrder) and extend unit tests to cover
all six methods and terminal keys.
…semantics tree dumps

Keep the isRunningDebug check scoped specifically to debugDumpLayerTree and
debugDumpFocusTree so that debugDumpApp, debugDumpRenderTree,
debugDumpSemanticsTreeInTraversalOrder, and
debugDumpSemanticsTreeInInverseHitTestOrder remain available in profile mode.
…d tests

Add doc comment to debugDumpFocusTree, use expression bodies for single-expression
debugDump* delegators, and deduplicate debugDumpKeys and listViewsWithoutIsolate
in terminal_handler_test.dart.
Add a regression test verifying that debugDumpApp, debugDumpRenderTree,
debugDumpSemanticsTreeInTraversalOrder, and
debugDumpSemanticsTreeInInverseHitTestOrder succeed in profile mode while
debugDumpLayerTree and debugDumpFocusTree return false, remove redundant
processTerminalInput loops in null-check tests, and document _debugDumpTree.
@bkonyi
bkonyi marked this pull request as ready for review September 21, 2026 18:35

@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 shared helper method, _debugDumpTree, which safely handles null values for vmService and uiIsolate using pattern matching. Unit tests are added to verify that these methods do not crash when these properties are null, and to ensure they behave correctly in profile build mode. There are no review comments, and no further feedback is provided.

@flutter-dashboard

Copy link
Copy Markdown

Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #192940 at sha da097ae

@flutter-dashboard flutter-dashboard Bot added the will affect goldens Changes to golden files label Sep 21, 2026
@bkonyi
bkonyi requested a review from chingjun October 15, 2026 21:03
@bkonyi bkonyi added autosubmit Merge PR when tree becomes green via auto submit App t: cp-candidate A PR that should be considered for a cherry-pick upon landing. labels Oct 15, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 16, 2026
@auto-submit

auto-submit Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/192940, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 16, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Oct 16, 2026
Merged via the queue into flutter:master with commit da6ba5b Oct 16, 2026
22 of 23 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 16, 2026
@bkonyi bkonyi added the cp: beta cherry pick this pull request to beta release candidate branch label Oct 19, 2026
@bkonyi bkonyi added the cp: stable cherry pick this pull request to stable release candidate branch label Oct 19, 2026
suryaKommana2662 pushed a commit to suryaKommana2662/flutter that referenced this pull request Oct 29, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD cp: beta cherry pick this pull request to beta release candidate branch cp: stable cherry pick this pull request to stable release candidate branch t: cp-candidate A PR that should be considered for a cherry-pick upon landing. tool Affects the "flutter" command-line tool. See also t: labels. will affect goldens Changes to golden files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[tool_crash] _TypeError (Null check operator used on a null value) in ResidentHandlers.debugDumpFocusTree

2 participants