flutter / devtools

Performance tools for Flutter
https://flutter.dev/docs/development/tools/devtools/
BSD 3-Clause "New" or "Revised" License
1.58k stars 326 forks source link

Add support for jumping to source from URIs in Devtools #5819

Open CoderDake opened 1 year ago

CoderDake commented 1 year ago

Add support for jumping to source from URIs in Devtools

CoderDake commented 1 year ago

Talked to @bkonyi about if we have any existing ways of posting events to the connected app's streams. There currently isn't a way, so I'll need to add an rpc to postEvent in order to accomplish this.

kenzieschmoll commented 1 year ago

We can use the customs streams functionality that you worked on a few months back. You can post to the ToolEvent stream that VS code is listening for. See https://github.com/flutter/devtools/issues/4326#issuecomment-1546236691.

bkonyi commented 1 year ago

You can only post to the custom stream from the target application, not from a service client.

CoderDake commented 1 year ago

Linking some other related issues here:

CoderDake commented 1 year ago

https://dart-review.googlesource.com/c/sdk/+/304981 has been submitted to the dart sdk. So we now have the ability to postEvent to an app's VmService.

CoderDake commented 1 year ago

While integrating postEvent into Devtools I found that some of the urls don't navigate properly in VSCode.

I contacted @DanTup and he was able to determine that some mappings are having issues.

He has filed a bug here where we can hopefully dig into it a bit: https://github.com/flutter/flutter/issues/128880

CoderDake commented 1 year ago
CoderDake commented 1 year ago

It looks like the postMessage sent from DevTools doesn't include information about the isolate. I will have to investigate the dds_extension and dds to see if that is something missing from my implementation. Otherwise we may need to send along another param in the event

DanTup commented 1 year ago

I presume the isolate that's usually included is the one that called postEvent. Since you're calling it externally, you don't have a valid isolate in the target app.

I'm not sure where you can really get one from.. in the CPU profiler you just have some URI and no context of an isolate (it's possible the isolates that were running the code that showed up in the CPU profiler has since terminated so wouldn't be usable anyway).

@bkonyi can you think of any way around this? Would it be possible to have the VM able to handle lookupResolvedPackageUris without an isolate (for example by tracking some superset of mappings from all scripts loaded in any isolates, and just using the first/last if there are overlapping-but-different paths for a given package?)