flutter / devtools

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

Can't attach to debugger on Dart VM running frontend_server #2938

Open jonahwilliams opened 3 years ago

jonahwilliams commented 3 years ago

I'm not sure the exact scenario required to trigger this, but attempting to connect to the VM Service of a frontend_server snapshot was sufficient to reproduce it. Debugging from the Observatory works.

To get the Observatory to print out:

diff --git a/packages/flutter_tools/lib/src/compile.dart b/packages/flutter_tools/lib/src/compile.dart
index 76ba6793b8..bc681ee8c9 100644
--- a/packages/flutter_tools/lib/src/compile.dart
+++ b/packages/flutter_tools/lib/src/compile.dart
@@ -696,11 +696,13 @@ class DefaultResidentCompiler implements ResidentCompiler {
     );
     final List<String> command = <String>[
       _artifacts.getHostArtifact(HostArtifact.engineDartBinary).path,
+      '--observe',
       '--disable-dart-dev',
       frontendServer,
       '--sdk-root',
       sdkRoot,
       '--incremental',
+      '--verbose',
       if (testCompilation)
         '--no-print-incremental-dependencies',
       '--target=$targetModel',

To trigger the crash I'm trying to debug (requires running a flutter web app)

diff --git a/packages/flutter_tools/lib/src/resident_runner.dart b/packages/flutter_tools/lib/src/resident_runner.dart
index 0342a56138..786db092cd 100644
--- a/packages/flutter_tools/lib/src/resident_runner.dart
+++ b/packages/flutter_tools/lib/src/resident_runner.dart
@@ -116,6 +116,7 @@ class FlutterDevice {
       } else {
         assert(false);
       }
+      extraFrontEndOptions.add('--enable-experiment=alternative-invalidation-strategy');

       generator = ResidentCompiler(
         globals.artifacts.getHostArtifact(HostArtifact.flutterWebSdk).path,

Note that it says it is paused in the debugger, but there is no debugger pane and hitting step doesn't seem to do anything.

Dart DevTools - Google Chrome 4_25_2021 10_52_52 AM

jonahwilliams commented 3 years ago

Now that I say that, the observatory seems to be having problems too. I wonder if this is an issue trying to debug app jit snapshots?

image