Skip to content

Dart DevTools automatically resumes when opening the tool #56873

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jensjoha opened this issue Oct 9, 2024 · 3 comments
Closed

Dart DevTools automatically resumes when opening the tool #56873

jensjoha opened this issue Oct 9, 2024 · 3 comments
Assignees
Labels
area-dart-cli Use area-dart-cli for issues related to the 'dart' command like tool. dart-cli-devtools Issues related to the 'dart devtools' tool

Comments

@jensjoha
Copy link
Contributor

jensjoha commented Oct 9, 2024

Say I have this file t.dart:

import "dart:developer";

void main() {
  int i = 42;
  debugger();
  print(i);
}

and I run it like this:

out/ReleaseX64/dart --enable-vm-service t.dart

I'll be told something like

The Dart VM service is listening on http://127.0.0.1:8181/QHkuXd4SI-g=/
The Dart DevTools debugger and profiler is available at: http://127.0.0.1:8181/QHkuXd4SI-g=/devtools/?uri=ws://127.0.0.1:8181/QHkuXd4SI-g=/ws

Going to either address will take me to a webpage that after a while says "Disconnected":

image

At the same time the script will have finished in the terminal:

$ out/ReleaseX64/dart --enable-vm-service t.dart
The Dart VM service is listening on http://127.0.0.1:8181/QHkuXd4SI-g=/
The Dart DevTools debugger and profiler is available at: http://127.0.0.1:8181/QHkuXd4SI-g=/devtools/?uri=ws://127.0.0.1:8181/QHkuXd4SI-g=/ws
42
$ echo $?
0

It seems that it has automatically resumed without me asking it to. Indeed adding another debugger() call and it doesn't happen:

import "dart:developer";

void main() {
  int i = 42;
  print("Will wait");
  debugger();

  print("Will wait again");
  debugger();

  print(i);
}

after opening the tool the output in the terminal is now

$ out/ReleaseX64/dart --enable-vm-service t.dart
Will wait
The Dart VM service is listening on http://127.0.0.1:8181/6pwtMho6irY=/
The Dart DevTools debugger and profiler is available at: http://127.0.0.1:8181/6pwtMho6irY=/devtools/?uri=ws://127.0.0.1:8181/6pwtMho6irY=/ws
Will wait again

Is this the intended behavior, and if it is, why? If not can we have it fixed?

This started to happen with adfbcc7

@lrhn lrhn added area-dart-cli Use area-dart-cli for issues related to the 'dart' command like tool. dart-cli-devtools Issues related to the 'dart devtools' tool labels Oct 9, 2024
@kenzieschmoll
Copy link
Contributor

It appears that the resume is getting triggered from BreakpointManager.initialize, which adds a listener that triggers the resume from the following code:
https://github.com/flutter/devtools/blob/master/packages/devtools_app/lib/src/screens/debugger/breakpoint_manager.dart/#L91

This code was added here: flutter/devtools@4075790#diff-cc4c2ac3c39b16e7a815dcb3b0350365926c2bd4794193d2aae89a9883406a13.

@elliette it's been a while since this code was added, but do you remember if this case was considered when adding this logic? The case where an isolate is paused before connecting to DevTools?

@elliette
Copy link
Contributor

elliette commented Oct 17, 2024

Ah yes, the case where an isolate is paused before connecting to DevTools was considered, but only via using the flag --pause-isolates-on-start. I did not consider the debugger() function case.

DDS checks whether the user had set --pause-isolates-on-start to determine whether or not to wait for a user-initiated resume to resume the isolate: 9382e58

I confirmed that if you run the app with:

out/ReleaseX64/dart --enable-vm-service --pause-isolates-on-start t.dart

Then open DevTools, and from DevTools "resume" the initial pause on start, you will then hit the breakpoint set by the debugger() function.

However, we should either document that this is necessary now to use debugger() functions, or figure out a way to handle this case.

@elliette
Copy link
Contributor

elliette commented May 2, 2025

Confirmed that this was fixed by flutter/devtools#8991

Image

@elliette elliette closed this as completed May 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-dart-cli Use area-dart-cli for issues related to the 'dart' command like tool. dart-cli-devtools Issues related to the 'dart devtools' tool
Projects
None yet
Development

No branches or pull requests

4 participants