question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Debugged Flutter 2 application dies when inspecting locals (hovering or 'Run and debug -> Variables' view)

See original GitHub issue

Describe the bug Whenever a Flutter 2 (2.0.1 to be exact) application is being debugged and a breakpoint is hit, hovering over a variable or expanding it in the ‘Run and debug -> Variables’ view causes the application to die. As a result, there is no way to efficiently debug a Flutter 2 app.

I noticed this with a custom app during the first session trying to debug an issue after Flutter upgrade. After downgrading to Flutter 1.22.6 and going to the latest commit where the app was still on that version, debugging worked as it always used to.

The issue can be reproduced with the simplest Flutter sample app created using this command:

flutter create flutter_counter_sample

The error I see in the console is:

Launching lib/main.dart on iPhone Xs in debug mode...
lib/main.dart:1
Xcode build done.                                            8.5s
Connecting to VM Service at ws://127.0.0.1:55869/saA4Pe9POFQ=/ws
Error handling 'checkPlatformOverride' custom request: method not available: ext.flutter.platformOverride
Error handling 'checkBrightnessOverride' custom request: method not available: ext.flutter.brightnessOverride
Error handling 'serviceExtension' custom request: method not available: ext.flutter.inspector.setPubRootDirectories
Error handling 'checkIsWidgetCreationTracked' custom request: method not available: ext.flutter.inspector.isWidgetCreationTracked
Lost connection to device.
Exited (sigterm)

No amount of flutter clean etc. helps.

To Reproduce Steps to reproduce the behavior:

  1. Create a sample app: flutter create flutter_counter_sample
  2. Open the app in VSCode and start with debugging on.
  3. Set a breakpoint in _MyHomePageState.build.
  4. When the app starts, click the + button. The debugger will stop at the breakpoint.
  5. Hover over the context local or expand it in the ‘Variables’ view.
  6. The application will crash.

Versions (please complete the following information):

  • VS Code version: 1.54.1
  • Dart extension version: 3.20.1
  • Dart/Flutter SDK version: Flutter 2.0.1 with Dart 2.12.0 (stable channel)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:34 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
aamcommented, Mar 10, 2021

@wujek-srujek We are trying to reproduce the failure locally, however meanwhile could you add print statement to the vmservice.dart per below diff, remove flutter_tools.dart.snapshot from flutter/bin/cache folder, run flutter doctor to rebuild that snapshot and retry reproducing the crash from the vscode capturing Dart: Capture Debugging Logs again hopefully with that additional printed data?

diff --git a/packages/flutter_tools/lib/src/vmservice.dart b/packages/flutter_tools/lib/src/vmservice.dart
index 5178606557..1452209ac4 100644
--- a/packages/flutter_tools/lib/src/vmservice.dart
+++ b/packages/flutter_tools/lib/src/vmservice.dart
@@ -239,6 +239,9 @@ vm_service.VmService setUpVmService(
       final String kernelBytesBase64 = await compileExpression(isolateId,
           expression, definitions, typeDefinitions, libraryUri, klass,
           isStatic);
+
+      print('compileExpression expression: $expression, $isolateId, $definitions, $typeDefinitions, $libraryUri, $klass, $isStatic -> $kernelBytesBase64');
+
       return <String, dynamic>{
         'type': 'Success',
         'result': <String, dynamic>{'kernelBytes': kernelBytesBase64},
0reactions
DanTupcommented, Mar 22, 2021

@wujek-srujek it’s probably best to follow up about that in the Flutter issue. I don’t think they pre-announce dates, although there’s a little info in the wiki here which suggests beta releases are approximately monthly (although I don’t know whether using a beta branch is viable for you).

I’ll close this as fixed upstream as there’s nothing to do in the VS Code extension - once upgraded to an SDK with the fix, it will automatically apply without requiring any changes here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using the debugger - DevTools
Within the Variables area, you can inspect individual objects by toggling them open to see their fields. Hovering over an object in the...
Read more >
After Upgrade To Flutter 2, Cannot Hover Over Variable In ...
inspecting locals hovering or 'Run and debug > Variables' view. Describe the bug Whenever a Flutter 2 2.0.1 to be exact application is...
Read more >
Debugging (The Boring Flutter Development Show, Ep. 41)
In this episode, Filip and Fitz are back again, this time looking at debugging. Learn some helpful ways to tackle bugs and some...
Read more >
February 2021 (version 1.54) - Visual Studio Code
We now show this color by default on all themes. Sash hover border color. Debugging. Breakpoints view improvements. New inline action for removing...
Read more >
Unable to debug flutter dart code in VS Code, Unverified ...
Doctor found issues in 2 categories. My launch.json File - { // Use IntelliSense to learn about possible attributes. // Hover to view...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found