Repository navigation
[flutter_tools] Guard against null vmService and uiIsolate in debugDumpFocusTree and debugDumpLayerTree - #192940
Conversation
…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
…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.
There was a problem hiding this comment.
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.
|
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 Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
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. |
…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.
Description
In
ResidentHandlers.debugDumpFocusTreeandResidentHandlers.debugDumpLayerTree, force unwrappingdevice.vmServiceandview.uiIsolate.idcaused a null check operator exception when the VM service was null or when aFlutterViewhad no attached UI isolate (e.g., during initialization or teardown).This change safely guards
device.vmServiceandview.uiIsolate?.idbefore invoking the respective VM service methods.Related Issue
Fixes #192934
Tests
Adds unit tests in
packages/flutter_tools/test/general.shard/terminal_handler_test.dartverifying thatdebugDumpFocusTreeanddebugDumpLayerTreedo not crash whenvmServiceoruiIsolateis null.