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 @@ -35,14 +35,16 @@ abstract class InspectorServiceBase extends DisposableController
required this.clientInspectorName,
required this.serviceExtensionPrefix,
required String inspectorLibraryUri,
ValueListenable<IsolateRef?>? evalIsolate,
}) : assert(serviceConnection.serviceManager.connectedAppInitialized),
assert(serviceConnection.serviceManager.service != null),
clients = {},
inspectorLibrary = EvalOnDartLibrary(
inspectorLibraryUri,
serviceConnection.serviceManager.service!,
serviceManager: serviceConnection.serviceManager,
) {
clients = {} {
inspectorLibrary = EvalOnDartLibrary(
inspectorLibraryUri,
serviceConnection.serviceManager.service!,
serviceManager: serviceConnection.serviceManager,
isolate: evalIsolate,
);
CoderDake marked this conversation as resolved.
Show resolved Hide resolved
_lastMainIsolate =
serviceConnection.serviceManager.isolateManager.mainIsolate.value;
addAutoDisposeListener(
Expand Down Expand Up @@ -71,7 +73,7 @@ abstract class InspectorServiceBase extends DisposableController
final String serviceExtensionPrefix;

final Set<InspectorServiceClient> clients;
final EvalOnDartLibrary inspectorLibrary;
late final EvalOnDartLibrary inspectorLibrary;
IsolateRef? _lastMainIsolate;

/// Reference to the isolate running the inspector that [InspectorServiceBase]
Expand Down Expand Up @@ -189,11 +191,12 @@ abstract class InspectorServiceBase extends DisposableController
/// Manages communication between inspector code running in the Flutter app and
/// the inspector.
class InspectorService extends InspectorServiceBase {
InspectorService()
InspectorService({ValueListenable<IsolateRef?>? evalIsolate})
CoderDake marked this conversation as resolved.
Show resolved Hide resolved
: super(
clientInspectorName: 'WidgetInspectorService',
serviceExtensionPrefix: inspectorExtensionPrefix,
inspectorLibraryUri: inspectorLibraryUri,
evalIsolate: evalIsolate,
CoderDake marked this conversation as resolved.
Show resolved Hide resolved
) {
// Note: We do not need to listen to event history here because the
// inspector uses a separate API to get the current inspector selection.
Expand Down
Expand Up @@ -52,7 +52,10 @@ class ExternalDevToolsEnvironmentParameters
@override
InspectorServiceBase? inspectorServiceProvider() =>
serviceConnection.serviceManager.connectedApp!.isFlutterAppNow == true
? InspectorService()
? InspectorService(
evalIsolate:
serviceConnection.serviceManager.isolateManager.mainIsolate,
)
: null;

@override
Expand Down
Expand Up @@ -24,7 +24,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