Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Inspector V2] Change selected node heuristic after navigation event triggering a tree refresh #8645

Merged
merged 2 commits into from
Dec 20, 2024

Conversation

elliette
Copy link
Member

Work towards #1423

Currently, when live reloading of the widget tree is enabled, the widget tree is reloaded when:

  1. We detect a hot-reload
  2. We detect a Flutter navigation event

For both, we try to determine the node to select in the reloaded tree by walking up from the selected node to its nearest unchanged ancestor, then walking down to find a node matching its name. This makes sense for hot-reloads, but for navigation events entire branches of the tree have changed.

This PR changes the heuristic after navigation events to simply select the closest unchanged ancestor.

@@ -462,6 +462,7 @@ class InspectorController extends DisposableController
}
if ((_receivedFlutterNavigationEvent || _receivedIsolateReloadEvent) &&
extensionEventKind == 'Flutter.Frame') {
_refreshingAfterNavigationEvent = _receivedFlutterNavigationEvent;
Copy link
Member

Choose a reason for hiding this comment

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

could there be a race where this is set again (after receiving another event here) before we reach the if statement you added below?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it could. I don't think it's likely and the consequence would just be we would then walk down the tree to find the closest matching, so it's not the worst outcome. However, I've added a TODO (below). I initially was passing the value for "refreshingAfterNavigationEvent" down the call chain, but realized that would involve changing the interface to onForceRefresh for the InspectorServiceClient which I didn't want to do:

@elliette elliette merged commit ba8a14f into flutter:master Dec 20, 2024
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants