Skip to content

Conversation

jiahaog
Copy link
Member

@jiahaog jiahaog commented Mar 4, 2021

Genaralizes waitForExtension from resident_devtools_handler.dart and move it to vmservice.dart.

This will allow the same logic to be reused in other places (#76200) where waiting for an extension to be registered is needed.

Slight changes in behavior to make it more general purpose:

  • Use _flutter.listViews instead to find the Flutter isolate
  • Don't wait for Flutter.FrameworkInitialization, which might happen before the vmservice is connected and we won't get the message. Let me know if this isn't ok
  • Instead listen on the stream of registered extension methods while querying extension methods of the isolate
  • Handles the case where the service disappears for a particular device and then skips subsequent service extension calls to the device in resident_devtools_handler.dart

@flutter-dashboard flutter-dashboard bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Mar 4, 2021
@google-cla google-cla bot added the cla: yes label Mar 4, 2021
@jiahaog jiahaog force-pushed the service-ext branch 2 times, most recently from 2f54c5b to 9832835 Compare March 4, 2021 08:56
]);
return isolateRef;
} finally {
await service.streamCancel(vm_service.EventStreams.kIsolate);
Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know if this is needed - it seems like it's a common pattern here to not cancel streams e.g.

await service.streamListen(vm_service.EventStreams.kIsolate);

I can follow up and add more streamCancels elsewhere if that is desired though

@jiahaog jiahaog marked this pull request as ready for review March 5, 2021 02:38
@jiahaog jiahaog requested a review from jonahwilliams March 5, 2021 02:38
// Do nothing, since the tool is already subscribed.
}

try {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer if this was structured similar to the original code, in a more clearly imperative manner

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, please take a look again 🙂

Copy link
Contributor

Choose a reason for hiding this comment

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

you need to handle the case where isolates is empty. While you are at it, I would consider what happens if there is more than one uiIsolate.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was under the impression that getFlutterViews keeps polling until the isolates are found. Is that not the case here?

Also regarding handling more than one isolate, would it be acceptable to run the querying logic (L813-814) over each uiIsolate found?

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe it will return an empty list if the vm service disconnects.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, I don't fully understand enough of the VM service to know what to do when it disconnects. Is this a recoverable error where we want to reconnect and make the same call again, or should we fail with an exception?

Copy link
Contributor

Choose a reason for hiding this comment

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

In this case, the tool will already trigger a shutdown - but that may be done separate from this call. You could either throw an error that all callsites would need to catch, or return some sort of sentinel

Copy link
Member Author

Choose a reason for hiding this comment

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

As discussed over chat, made it throw an exception here, and updated resident_devtools_handler.dart to ignore the current FlutterDevice when this happens

@jiahaog jiahaog requested a review from jonahwilliams March 8, 2021 06:28
@jiahaog jiahaog force-pushed the service-ext branch 2 times, most recently from 613e0cc to 97c292e Compare March 10, 2021 02:29
Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

LGTM!

@jiahaog jiahaog merged commit 9fdda01 into flutter:master Mar 10, 2021
@jiahaog jiahaog deleted the service-ext branch March 10, 2021 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants