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

Make InspectorService supporting issuing most of its requests over the Flutter Daemon instead of observatory. #1980

Merged
merged 2 commits into from
Mar 22, 2018

Conversation

jacob314
Copy link
Contributor

@jacob314 jacob314 commented Mar 22, 2018

This avoids problematic cases where the observatory protocol allowed
requests to issue at surprising times such as right in the middle of
a flutter method call.
It is expected this fixes many hard or impossible to reproduce inspector
bugs.

To simplify the code I have also changed the semantics so that
the supportedServiceMethods set is computed before an InspectorService
is considered ready. This reduces the number of future.thenCompose
calls within the InspectorService code dealing with functionality only
exposed by the latest version.

flutter daemon instead of using the observatory protocol for requests
that do not need to use the observatory.

This avoids problematic cases where the observatory protocol allowed
requests to issue at surprising times such as right in the middle of
a flutter method call.
It is expected this fixes many hard or impossible to reproduce inspector
bugs.

To simplify the code I have also changed the semantics so that
the supportedServiceMethods set is computed before an InspectorService
is considered ready. This reduces the number of future.thenCompose
calls within the InspectorService code dealing with functionality only
exposed by the latest version.
@jacob314 jacob314 requested review from pq and devoncarew March 22, 2018 17:43
@jacob314
Copy link
Contributor Author

Good news is the service level logic was well isolated to InspectorService so this change doesn't impact the UI code in InspectorPanel. I've verified the plugin works both with and without the new daemon service. Generally performance is similar with both transport protocols but robustness appears to be improved with the daemon protocol.

@jacob314 jacob314 changed the title Make InspectorService supporting issuing most of its requests over the Make InspectorService supporting issuing most of its requests over the Flutter Daemon instead of observatory. Mar 22, 2018
whenCompleteUiThread(InspectorService.create(app.getFlutterDebugProcess(), app.getVmService()),
(InspectorService inspectorService, Throwable throwable) -> {
if (throwable != null) {
LOG.error(throwable);
Copy link
Member

Choose a reason for hiding this comment

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

I think we want warn here, so we don't show a dialog to the user.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -82,6 +82,7 @@
private final InspectorService.FlutterTreeType treeType;
@NotNull
private final FlutterApp flutterApp;
private final InspectorService inspectorService;
Copy link
Member

Choose a reason for hiding this comment

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

@NotNull, to match the constructor param.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -192,7 +195,7 @@ public void onAppChanged() {

@Nullable
Copy link
Member

Choose a reason for hiding this comment

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

This should now be @NotNull I believe.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@NotNull private final Set<String> supportedServiceMethods;

// TODO(jacobr): remove this field as soon as
// `ext.flutter.debugCallWidgetInspectorService` has been in two revs of the
Copy link
Member

Choose a reason for hiding this comment

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

This is a flutter framework service extension?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

discussed offline. Switched to
ext.flutter.inspector.methodName
and cleaned up how we were passing parameters.
Parameters are now passed as either
{'arg': arg, 'objectGroup': objectGroup}
{'objectGroup': objectGroup}
or
{'arg0': arg0, 'arg1': arg1, 'arg2': arg2, ...}
for the one vararg like case.

if (arg == null || arg.getId() == null) {
return getInspectorLibrary().eval("WidgetInspectorService.instance." + methodName + "(null, \"" + groupName + "\")", null);
}
return getInspectorLibrary()
.eval("WidgetInspectorService.instance." + methodName + "(\"" + arg.getId() + "\", \"" + groupName + "\")", null);
}

CompletableFuture<InstanceRef> invokeServiceMethodOnRef(String methodName, InstanceRef arg) {
/**
* This API requires using the observatory service a the input parameter is an
Copy link
Member

Choose a reason for hiding this comment

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

some grammar nits here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

rewrote this comment.

@jacob314 jacob314 merged commit f649044 into flutter:master Mar 22, 2018
@devoncarew
Copy link
Member

Jacob, does this address the two crashers on https://github.com/flutter/flutter-intellij/milestone/34?

@jacob314
Copy link
Contributor Author

I've updated the two bugs. The first should be fixed and the second should be mitigated to the point where it can be pushed to M24.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants