Repository navigation
[stable] [flutter_tools] Guard against null vmService and uiIsolate in debugDumpFocusTree and debugDumpLayerTree - #194740
Conversation
…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.
|
@bkonyi please fill out the PR description above, afterwards the release team will review this request. |
|
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 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.
abe8675
into
flutter:flutter-3.47-candidate.0
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 rundebug sessions, triggeringdebugDumpFocusTree(f) ordebugDumpLayerTree(t) when aFlutterDevice's VM service connection or aFlutterView's attacheduiIsolateis null (such as during isolate initialization or teardown) causes an unhandled_TypeError: Null check operator used on a null valuecrash influtter_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 runon any platform before the UI isolate finishes initializing or after teardown,flutter_toolscrashed with a null check operator exception.Workaround:
Wait until the app and UI isolate have fully initialized before invoking
f(debugDumpFocusTree) ort(debugDumpLayerTree) in theflutter runterminal.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:
flutter test packages/flutter_tools/test/general.shard/terminal_handler_test.dart.debugDumpFocusTreeanddebugDumpLayerTreereturn gracefully without throwing whenvmServiceoruiIsolateis null.