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

Widget inspector should operate on main isolate, not selected isolate #6434

Merged
merged 9 commits into from Sep 25, 2023
Expand Up @@ -42,6 +42,7 @@ abstract class InspectorServiceBase extends DisposableController
inspectorLibraryUri,
serviceConnection.serviceManager.service!,
serviceManager: serviceConnection.serviceManager,
forceMainIsolate: true, // widget inspector only operates on main
) {
_lastMainIsolate =
serviceConnection.serviceManager.isolateManager.mainIsolate.value;
Expand Down
Expand Up @@ -22,7 +22,7 @@ DevTools extension for your pub package, see the getting started guide for

## Inspector updates

TODO: Remove this section if there are not any general updates.
* Fixed bug where inspector service calls were done on the selected isolate, instead of the main isolate - [#6434](https://github.com/flutter/devtools/pull/6434)

## Performance updates

Expand Down
Expand Up @@ -41,11 +41,16 @@ class EvalOnDartLibrary extends DisposableController
ValueListenable<IsolateRef?>? isolate,
this.disableBreakpoints = true,
this.oneRequestAtATime = false,
this.forceMainIsolate = false,
CoderDake marked this conversation as resolved.
Show resolved Hide resolved
}) : _clientId = Random().nextInt(1000000000) {
_libraryRef = Completer<LibraryRef>();

// For evals in tests, we will pass the isolateId into the constructor.
isolate ??= serviceManager.isolateManager.selectedIsolate;
if (forceMainIsolate) {
isolate ??= serviceManager.isolateManager.mainIsolate;
} else {
isolate ??= serviceManager.isolateManager.selectedIsolate;
}
addAutoDisposeListener(isolate, () => _init(isolate!.value));
_init(isolate.value);
}
Expand All @@ -61,6 +66,9 @@ class EvalOnDartLibrary extends DisposableController
/// Whether to disable breakpoints triggered while evaluating expressions.
final bool disableBreakpoints;

/// Forces the use of the mainIsolate, rather than the selected isolate.
final bool forceMainIsolate;

/// An ID unique to this instance, so that [asyncEval] keeps working even if
/// the devtool is opened on multiple tabs at the same time.
final int _clientId;
Expand Down