flutter / flutter-intellij

Flutter Plugin for IntelliJ
https://flutter.dev/using-ide
BSD 3-Clause "New" or "Revised" License
1.97k stars 316 forks source link

Multiple running apps not detected when inspector opens #6784

Open stevemessick opened 1 year ago

stevemessick commented 1 year ago

If you open the inspector then start multiple apps they all show up in the embedded inspector view. But if you start multiple apps then open the inspector you only see the currently active app. There appears to be no way to add another without restarting it.

cc @AlexV525

AlexV525 commented 1 year ago

When we talk about "open the inspector", you mean open the inspector tab in the editor, right?

AlexV525 commented 1 year ago

If I get it right:

  1. Open the project A and run it on the Device 1, wait until it runs.
  2. Open the project B and run it on the Device 1, wait until it runs.
  3. Open inspector tabs both with A and B, they all connected to the project B on Device 1?
stevemessick commented 1 year ago

When we talk about "open the inspector", you mean open the inspector tab in the editor, right?

Yes.

I actually was testing the same app on two different devices.

  1. Open an app and run it on device 1.
  2. Connect device 2, and run the same app on it.
  3. Open the inspector and see device 2 but not device 1.
AlexV525 commented 1 year ago

Just finished some investigations. Each time a new FlutterApp gets run, a new listener will be attached to the top, which overrides the previous one. Thus only the last inspector will be displayed. https://github.com/flutter/flutter-intellij/blob/16749f9cbf498621e5a64410ea78a8264f2a50dc/flutter-idea/src/io/flutter/view/FlutterView.java#L525-L529 https://github.com/flutter/flutter-intellij/blob/16749f9cbf498621e5a64410ea78a8264f2a50dc/flutter-idea/src/io/flutter/view/FlutterView.java#L752-L754

It requires a significant change from a single FlutterApp to a collection of FlutterApps. However, I just tried to update it and there are some race-condition issues that need to be resolved.

cc @helin24 if you're interested and more familiar with the suggested changes.