flutter / devtools

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

Support inspecting widget tree of multi engine #6640

Open hyiso opened 11 months ago

hyiso commented 11 months ago

Currently, when using flutter attach, the widget tree in Flutter Inspector page only shows first engine's widget tree, we can't choose to see widget tree of other engine.

CoderDake commented 11 months ago

hi @hyiso what do you mean by other "engine"? If possible could you post some code here to help us reproduce what you are experiencing?

hyiso commented 11 months ago

In my case, there are two Flutter Engines exist at the same time.

The first Flutter Engine shows one Flutter page, and the second Flutter Engine shows another Flutter page

I want to use devtools' inspector page to inspect the widget tree of the second Flutter Engine, but the inspector page only shows the first Flutter Engine's widget tree

I have no idea how to select the second Flutter Engine to inspect

kenzieschmoll commented 11 months ago

DevTools can only connect to a single Flutter app at a time. If you are running a separate flutter app, this will have its own instance of DevTools to debug with.

How are you opening DevTools?

hyiso commented 11 months ago

These two engines are in one app, in add2app scenario

The DevTools inspector page is opened in browser from VS Code after running flutter attach

There is no other debug session that I can found to select

DanTup commented 11 months ago

I'm not very familiar with add2app. When we say "two engines" here, do we mean "two Dart VMs" or a single VM with multiple isolates?

If there are two VMs it seems like there should be two VM Service URIs and you could "attach" to each of them from VS Code to get two sessions, although it also feels odd to need two VMs in a single app for two views.

hyiso commented 11 months ago

These two engines are created via FlutterEngineGroup, I have not seen any option to select session from VS Code when running flutter attach and opening DevTools

There was only one VM service URI printed to console when entering Flutter page.

The reason why we need two engines is irrelevant here

nt4f04uNd commented 10 months ago

There is a similar scenario with ContentProvider in my Flutter plugin, which I described here https://github.com/nt4f04uNd/android_content_provider/issues/16#issuecomment-1843872890