Open kovalyovi opened 3 years ago
When this issue occurs what happens if you have dart devtools open to the inspector? Does the selection change in the widget tree or not?
Danny did you change anything related to how VSCode handles dart:developer inspect api?
@jacob314 nothing has changed recently, but a while ago I made calling inpsect()
on something that wasn't handled by the inspector (eg. we didn't get a widget summary for) print the variable to the output (to allow calling inspect()
in user code to inspect variables):
https://github.com/Dart-Code/Dart-Code/pull/2560
For this to occur, it suggests that getSelectedSummaryWidget
is either returning a null
result
, or that creationLocation
is not set:
I did some testing and couldn't repro this, though I did note that if you click the [root]
node in the inspector this happens (it has a null
result).
Do you know of anything that could prevent getSelectedSummaryWidget
from returning a result?
When this issue occurs what happens if you have dart devtools open to the inspector? Does the selection change in the widget tree or not?
If I understood you right when the Dart Devtools inspector is open and I click on a widget, it selects that widget in the widget tree but it does not select the widget in the code (doesn't open the file to the widget position).
I found out that this happens when I have multiple emulators running at the same time (I need it for correct positioning of widgets). I open both emulators from VS Code, select one of them (let's say number 2) as the 'default' for VS Code, run F5 to start the debug session, then use a different CLI to start the same application on a different emulator. To reproduce, I just have to switch the 'default' emulator in VS Code while the debug session is running. After that, it starts outputting the 'inspected variable' into the console until I remove the application from the device.
@jacob314 Another update: right now after it starts outputting <inspected variable>
upon a click on a widget instead of navigating to the code in the code window, it doesn't get fixed by uninstalling the application from the device. I tried clearing VS Code cache, uninstalling the application, running flutter clean but nothing seems to be working...
I open both emulators from VS Code, select one of them (let's say number 2) as the 'default' for VS Code, run F5 to start the debug session, then use a different CLI to start the same application on a different emulator.
@jacob314 could building the app a second time be overwriting anything that might affect this? As far as VS Code is concerned here, there's only one app (the one launched from VS Code). The file system (/build folder) is the only thing I can think that would be shared/stateful (although I don't know whether that should impact the inspector at all).
Any update on that guys?
Today I started facing the same exactly issue on VS Code. Selecting a widget on "Select Widget Mode" just outputs on debug console
@esentis are you seeing this even without running the app on two devices/simulators at the same time? Do you have steps to reproduce?
@DanTup Yes, I'm running it in just one instance (emulator). Unfortunatelly I don't have any steps to reproduce, since it started occuring suddenly in a project that I'm working on for months, and it's mildly annoying. The issue is present only on this specific project. I'm sorry for not being more helpful...
Guys are there any updates about this issue? It still persists on my project.
@jacob314 any thoughts on how to track this down? I believe the VS Code behaviour of showing the inspected variable is somewhat unrelated. This only occurs when there's no widget summary. If I remove that, then inspecting will just do nothing at all. The problem is that response to getSelectedSummaryWidget
is null
or with no location.
@kovalyovi capturing a log may be useful:
This should capture the VM service traffic (which should include the response to getSelectedSummaryWidget
) which might include some clues.
I'm not sure why getSelectedSummaryWidget
would be causing a problem. Having a repo would be very helpful. Longer term we should file a bug on package:flutter to switch to just using an API to directly specify the source location to navigate to. Can you file a package:flutter bug to track that?
After the latest VS update the bug seems to be gone for me. I don't know if it was associated with it though :/
I don't think there are any changes in this area in the VS Code extension, although Flutter 2.0 was around the same time which contained significantly more.
@kovalyovi do you still only see this when running multiple instances of flutter run
?
@jacob314
Longer term we should file a bug on package:flutter to switch to just using an API to directly specify the source location to navigate to. Can you file a package:flutter bug to track that?
Happy to file an issue - although I'm not sure I entirely understand the request. Do you mean instead of firing the inspect
event, there should be another event (or the same one) that includes the location directly (fired by the Inspector code in Flutter) avoiding the need to call ext.flutter.inspector.getSelectedSummaryWidget
at all?
@DanTup
@jacob314 any thoughts on how to track this down? I believe the VS Code behaviour of showing the inspected variable is somewhat unrelated. This only occurs when there's no widget summary. If I remove that, then inspecting will just do nothing at all. The problem is that response to
getSelectedSummaryWidget
isnull
or with no location.@kovalyovi capturing a log may be useful:
- Get the project ready to reproduce
- Run the Dart: Capture Debugging Logs command from the VS Code command palette
- Inspect the widget to reproduce the issue
- Click Cancel on the logging notification to open the log file
This should capture the VM service traffic (which should include the response to
getSelectedSummaryWidget
) which might include some clues.
I apologize but reproducing is simply impossible. My project is 40k+ lines of code and it's private for the customer, so I can't provide reproducible code.
@kovalyovi do you still only see this when running multiple instances of flutter run?
No, I have it when only one emulator is running. I already forgot what it is to use Dart DevTools since it's giving so many problems that I can't use it effectively, so I use ctrl+shift+F
in VS Code to find the widgets I need to modify. I wish there was a fix for that. It selects the widgets on the phone and in the DevTools but doesn't highlight it in VS Code (which I need more than anything else).
@DanTup
Hi,
I got same problem on my project. emulator working fine, only happen with real Android device (my Samsung A9 pro Android 8.0) got message <inspected variable>
when use inspector instead of open file in VS code.
So I tried comment each block code in my main.dart
and found it because of this line:
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
Just comment above line then it working normal on my real device.
Find more detail on what that line do, I found maybe because isolate or something make ext.flutter.inspector.getSelectedSummaryWidget
return null
Final result is if comment line below then it work
c:\src\flutter-2.10\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-11.2.4\android\src\main\java\io\flutter\plugins\firebase\messaging\FlutterFirebaseMessagingBackgroundExecutor.java:183
executor.executeDartCallback(dartCallback);
I have repo here https://github.com/noncheat/flutter_helloworld
You can try debug it on real Android device and see.
Hope it helpful.
@jacob314 I can repro this using @quyenvsp's instructions above. I don't think it's VS Code related, but I'm not sure where the problem is.
When I run the app without the call to FirebaseMessaging.onBackgroundMessage
, we get the inspect event fine and call getSelectedSummaryWidget
and get a reasonable response:
[FlutterRun] [Info] [flutter_helloworld] ==> [{"id":"1","method":"app.callServiceExtension","params":{"appId":"a856a8fd-efba-45a4-b6b0-db7b1ff8c127","methodName":"ext.flutter.inspector.getSelectedSummaryWidget","params":{"previousSelectionId":null,"objectGroup":"my-group"}}}]
[FlutterRun] [Info] [flutter_helloworld] <== [{"id":"1","result":{"result":{"description":"Text","type":"_ElementDiagnosticableTreeNode","style":"dense","hasChildren":true,"allowWrap":false,"objectId":"inspector-1034","valueId":"inspector-21","locationId":10,"creationLocation":{"file":"file:///Users/danny/Dev/TestStuff/flutter_helloworld/lib/main.dart","line":100,"column":16,"name":"Text"},"createdByLocalProject":true,"children":[{"description":"RichText","type":"_ElementDiagnosticableTreeNode","style":"dense","allowWrap":false,"objectId":"inspector-1035","valueId":"inspector-47","locationId":13,"creationLocation":{"file":"file:///Users/danny/Dev/Google/flutter/packages/flutter/lib/src/widgets/text.dart","line":527,"column":21,"name":"RichText"},"children":[],"widgetRuntimeType":"RichText","stateful":false}],"widgetRuntimeType":"Text","stateful":false},"type":"_extensionType","method":"ext.flutter.inspector.getSelectedSummaryWidget"}}]
However, when I add back FirebaseMessaging.onBackgroundMessage
then the response is null
:
[FlutterRun] [Info] [flutter_helloworld] ==> [{"id":"9","method":"app.callServiceExtension","params":{"appId":"f08cfbc4-5a20-42a0-8295-38931b9eccc1","methodName":"ext.flutter.inspector.getSelectedSummaryWidget","params":{"previousSelectionId":null,"objectGroup":"my-group"}}}]
[FlutterRun] [Info] [flutter_helloworld] <== [{"id":"9","result":{"result":null,"type":"_extensionType","method":"ext.flutter.inspector.getSelectedSummaryWidget"}}]
Any thoughts on whether this is likely an Inspector issue or a Firebase issue?
Even I am facing this issue. However for me, restarting the debug session seems to solve the issue. But it is really frustrating to keep restarting debug session again & again. Any updates on this?
Any update on this issue? I've been facing the same issue.
Any Updates ??
My understanding of the original issue is that when the Firebase initialisation was performed, the inspector would no longer navigate to the code in the editor, and would output "inspect()
call fails to find a selected widget, it will assume user code called inspect()
and print it to the debug console).
Testing this today using the new SDK debug adapters (which are being rolled out gradually), the navigation works even with the Firebase initialization. Whatever was causing the inspector navigation to fail previously appears to be fixed. You can opt-in to the new debug adapters early with the dart.previewSdkDaps
setting in VS Code.
So, I believe the outstanding issue (at least when using the new debug adapters) is that "inspect()
) for handling inspection (for compatibility with IntelliJ and the legacy VS Code debug adapter), and we can't tell the difference between an inspect()
from user-code or from the inspector.
The ideal fix for this would be to remove the inspect()
call here:
But doing that would either need to be conditional on knowing the client editor is handling the new ToolEvent
, or that we know all editors have been handling it for sufficient time that we're not concerned with older versions of the plugins.
@CoderDake do you know of any way we could provide some signal to the inspector that the client is able to handle ToolEvent and the inspect()
call could be skipped?
We should remove the call to inspect at L1584 and dispatch a custom event notifying the Flutter Inspector that the inspector selection has changed. I don't see anything blocking us from making that change. The inspector doesn't even need to know the object selected as it can query the inspector to determine that.
We should remove the call to inspect at L1584 and dispatch a custom event notifying the Flutter Inspector that the inspector selection has changed.
By "Inspector" here, do you mean IntelliJ? I assumed that IntelliJ was listening for that inspect()
call to navigate code as VS Code was? (Edit: didn't realise the inspector uses this for selection too... @CoderDake is this easy to change?)
I will update the legacy VS Code DAP to handle the new ToolEvent stream so that the rollout of the new DAPs isn't a factor in removing this. Done!
I've noticed that sometimes (doesn't depend on anything, based on my experience with it)
DevTools Widget Inspector
, when in theSelect Widget Mode
and when you click on a widget in Android Emulator, instead of highlighting the source code in the project it just outputs<inspected variable>
into VS CodeDEBUG CONSOLE
.Previously, it would be solved when I reload VS Code but now I reinstalled VS Code, reinstalled Flutter and Dart extensions, wiped the emulator data and nothing helps - Flutter DevTools just doesn't work. How to fix that?