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

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)

About this issue

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

Most upvoted comments

@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},