-
Notifications
You must be signed in to change notification settings - Fork 308
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
Attaching to running flutter process doesn't highlight source paused on #3808
Comments
This is a known limitation right now. When we connect to the Flutter app we only get URIs like As a workaround, if you have a launch configuration (in .vscode/launch.json{
"version": "0.2.0",
"configurations": [
{
"name": "attach",
"request": "attach", // Attach instead of launching
"type": "dart",
"cwd": "src", // Folder of the app
"vmServiceUri": "${command:dart.promptForVmService}" // Prompt for the VM Service URI
},
]
} I'll keep this issue open to ensure this is not required when we switch to the new DAPs. |
Unfortunately the suggested workaround doesn't work in my case. It prints the following on its debug console:
The configuration works if I leave out "cwd", but however I specify the cwd (relative, absolute...) it prints the above. |
Could you try running the Dart: capture Debugging Logs command before doing this, then reproduce the issue and provide the log? You could also try setting this instead: "packages": ".dart_tool/package_config.json" although I suspect it may do the same thing. |
I've opened #3809 specifically for the new issue you're seeing - let's continue that there, and keep this one open for ensuring the original issue is resolved with the new DAP. |
I'll post this here, too, because it allows me to use the debugger as intended. Using this configuration as suggested by DanTup works for me:
|
Ah, glad that works. I'm not sure why changing the working directory doesn't, but we can troubleshoot that in #3809. Ofc I'll also make sure in the new SDK DAPs neither of these workarounds are required before closing this. |
I'm experiencing a similar issue with breakpoints not triggered in VS Code Remote Extensions and port forwarding. The following is just for background/context information, I'm fairly sure the issue is confined to package/file:// resolution issues which I've detailed at the bottom of this comment.
(it may be relevant that the Dart extension is installed both locally and remotely). What works:
What doesn't work:
Note that the breakpoints are definitely successfully set:
However, I can also see that the scriptUri reference uses
So I assume this is just the same issue with source references not being correctly resolved from file to package. App structure seems to be irrelevant (the same issues are experienced running a sample app or the example subfolder of a sample plugin). Setting the It sounds like this is being worked on in the new debug adapters, so filing more for posterity than anything but if you have any immediate suggestions, I'm all ears. flutter doctor
|
@nmfisher are you attaching or just running from VS Code? If running, then I suspect this is a different issue. For the breakpoints that don't work, do you mean that VS Code pauses without jumping to the location, or that it does not break at all? Setting breakpoints by If you can provide detailed instructions for me to reproduce this (including the port forwarding you're setting up etc.) I can do some debugging, though if it's not attach then it's worth opening a new issue for it, as it's probably something different. Out of curiosity - why are you using the remote Linux machine but connecting ADB back to the Windows machine? (it's always useful for me to understand more about the less common workflows so in case they're not as well supported as they could/should be!). |
Thanks for the quick response @DanTup. I tried both Right now it's just so I can run the Android emulator (or connect an actual device) to my laptop while I'm out and about, while keeping the working codebase and running the actual Flutter compiler on a more powerful Linux machine. Admittedly it's a bit of an unconventional setup, but it is similar to the use case where Flutter is run via WSL and the emulator is run on the underlying Windows host (which seems to be a lot more common, judging from GitHub issues). I'll try and put together a reproduction repository/image. |
I've been tearing my hair out today trying to understand why everything worked fine in a Docker image I put together, but still not in the original Linux environment that was very similar. That's until I realized that in my original environment, VS Code Remote SSH was actually opening the Flutter project folder at a symbolic link, not the actual filesystem location. I created a sample project on Linux to check, and it seems that indeed, breakpoints do not work if folders are opened via symbolic link. So forget about port forwarding/Remote SSH, I'm pretty sure the underlying problem can be replicated as follows (all on Linux):
I confirm that opening the remote SSH folder at the actual filesystem location, not the symbolic link, resolves my issue and everything is working as intended. |
Thanks for the debugging! I can't repro on macOS - I'm unable to open a symlink folder in VS Code.. no matter if I use I'll have a go with Docker and see if I can repro on Linux - in case I can't with Ubuntu, what distro are you using? |
Since this is different to the original issue here, let's continue this at #3896. |
I've confirmed this issue is resolved when using the new SDK DAPs. If you're using Flutter 3.0 or newer you can switch to these now with a flag in your VS Code settings:
However, there are a few known issues when running on Web/Chrome devices with that version so I won't be starting to enable this by default until the next (non-hotfix) Flutter release that includes a few fixes for that. I'll keep this issue open until closer to when that ships to include in release notes of a closer release. |
I've re-tested this on the current Flutter beta (v3.3.0-0.5.pre) with the latest Dart extension and The new SDK DAPs will be gradually become default over the coming months (though you can still opt-in with that flag) when you're using a new enough SDK. |
not really helping, it somehow just stopping process at start |
@Nikzed can you open a new issue with a detailed description of the issue you're seeing, and if possible a code sample/project that reproduces it? Thanks! |
Describe the bug
When starting a flutter project using
flutter run
outside of vscode and then attaching the debugger inside vscode by running>Debug: Attach to Flutter on Device
and pasting the URI provided by flutter, it is possible to set a breakpoint in a file and the debugger also stops the app, but it doesn't give any information about the current state and doesn't highlight the line that's paused on. The problem only occurs if in vscode the flutter project is nested in subfolder. As setting the breakpoint and breaking on it works correctly, but from then on it's pretty useless, it's hard to figure out what's wrong.To Reproduce
Steps to reproduce the behavior:
mkdir -p flutter-test/src; code flutter-test; cd flutter-test/src; flutter create .
)flutter run
)Expected behavior
Either setting the breakpoint should fail with a meaningful error message or locating the source should work not only for setting the breakpoints but also for resolving the debugged code.
Screenshots
Versions (please complete the following information):
Commit: 899d46d82c4c95423fb7e10e68eba52050e30ba3
Date: 2022-01-19T16:00:00.869Z
Electron: 13.6.7
Chromium: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.40-electron.0
OS: Linux x64 5.16.2-arch1-1
The text was updated successfully, but these errors were encountered: