Skip to content
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

serviceInfoFile doesn't seem to work for custom flutter embedders #3353

Closed
knopp opened this issue May 18, 2021 · 3 comments
Closed

serviceInfoFile doesn't seem to work for custom flutter embedders #3353

knopp opened this issue May 18, 2021 · 3 comments
Labels
in debugger Relates to the debug adapter or process of launching a debug session in flutter Relates to running Flutter apps is enhancement
Milestone

Comments

@knopp
Copy link

knopp commented May 18, 2021

My flutter application writes a service info file, but when I specify it in the launcher configuration Dart-Code doesn't poll for it.

vmServiceUri with prompt works as expected, but it's not ideal to have to copy and paste the URI on every launch.

  • Dart extension version: dart 3.22.0
  • Dart/Flutter SDK version: current master
@knopp knopp added the is bug label May 18, 2021
@knopp knopp changed the title serviceInfoFile doesn't seem to work for flutter serviceInfoFile doesn't seem to work for custom flutter embedders May 18, 2021
@knopp
Copy link
Author

knopp commented May 18, 2021

The application is not built through the flutter tool so I can't run it using flutter run. flutter attach works, but I need to specify vmServiceUri on every launch.

(down the line it would also be nice to have option for Dart-Code to launch a custom executable with --write-service-info), but for now at least serviceInfoFile working would be a big quality of life improvement.

@DanTup DanTup added this to the v3.23.0 milestone May 19, 2021
@DanTup DanTup added in debugger Relates to the debug adapter or process of launching a debug session in flutter Relates to running Flutter apps is enhancement and removed is bug labels May 19, 2021
@DanTup
Copy link
Member

DanTup commented May 19, 2021

down the line it would also be nice to have option for Dart-Code to launch a custom executable with --write-service-info

You might be able to do this with a preLaunchTask (eg. cause the debug config to run a background task that spawns the app before it tries to debug) or a compound config (one that runs a Dart script that sets up the file and spawns your process) - I don't know how messy that would be though.

There is also some support for overriding the Flutter/Dart binaries, but it's aimed at some specific Bazel workspace setups so not something official supported for this, but may be another option to improve things until/unless something better is available:

config.activateDevToolsEagerly = !!flutterConfig.devtoolsActivateScript;
config.dartSdkHomeLinux = makeFullPath(flutterConfig.dartSdkHome?.linux);
config.dartSdkHomeMac = makeFullPath(flutterConfig.dartSdkHome?.macos);
// This one replaces the args "global activate devtools"
config.devtoolsActivateScript = makeScript(flutterConfig.devtoolsActivateScript, 3);
// This one replaces the args "global run devtools"
config.devtoolsRunScript = makeScript(flutterConfig.devtoolsRunScript, 3);
config.flutterDaemonScript = makeScript(flutterConfig.daemonScript);
config.flutterDoctorScript = makeScript(flutterConfig.doctorScript);
config.flutterRunScript = makeScript(flutterConfig.runScript);
config.flutterSdkHome = makeFullPath(flutterConfig.sdkHome);
config.flutterTestScript = makeScript(flutterConfig.testScript);
config.flutterVersionFile = makeFullPath(flutterConfig.versionFile);

As for the original request - looking at FlutterDebugSession, attachRequest calls launchRequest which calls into DartDebugSession.launchRequest so I don't think it should be complicated to fix this - I suspect there are just some bad assumptions somewhere.

@DanTup DanTup closed this as completed in b1e60ae May 19, 2021
@DanTup
Copy link
Member

DanTup commented May 19, 2021

Although this works in my testing with simple Flutter, it's not working for @knopp:

[1:28:22 PM] [FlutterRun] [Info] [Flutter: Attach to Process] Spawning flutter with args ["attach","--machine","-d","macos","--debug-uri","ws://127.0.0.1:60238/40DHMrlkLa0=/ws","--devtools-server-address","http://127.0.0.1:9100/","-v"]

[ +104 ms] Exception attempting to connect to the VM Service: WebSocketException: Connection to 'http://127.0.0.1:60238/40DHMrlkLa0=/ws/ws#' was not upgraded to websocket

The /ws/ws looks suspicious - though it's interesting I'm not seeing that (I did see the URL mangled in a different way though, it ended up with .,/ws on the end - but it still worked). Perhaps something changed in Flutter (I'm on master).

@DanTup DanTup reopened this May 19, 2021
@DanTup DanTup closed this as completed in 4151a7e May 19, 2021
DanTup added a commit to DanTup/flutter that referenced this issue Jun 8, 2023
When building the new SDK DAPs, this functionality was missed from the Flutter adapter (but added to the Dart CLI adapter).

As well as passing a VM Service URI directly, we support passing a file that can be polled for it.

This uses the same mechanism we use to obtain the VM Service URI from a Dart debug session (we run "dart --write-service-info=foo.json my_file.dart" and then poll that file) and is useful for users that have their own mechanism for launching an app (for example using custom Flutter embedders - see Dart-Code/Dart-Code#3353) to provide a VM Service URI once the app is up and running.

Fixes Dart-Code/Dart-Code#4577.
auto-submit bot pushed a commit to flutter/flutter that referenced this issue Jun 16, 2023
…8503)

When building the new SDK DAPs, this functionality was missed from the Flutter adapter (but added to the Dart CLI adapter).

As well as passing a VM Service URI directly, we support passing a file that can be polled for it.

This uses the same mechanism we use to obtain the VM Service URI from a Dart debug session (we run `dart --write-service-info=foo.json my_file.dart` and then poll that file which the VM will write) and is useful for users that have their own mechanism for launching an app (for example using custom Flutter embedders - see Dart-Code/Dart-Code#3353) to provide a VM Service URI once the app is up and running.

Fixes Dart-Code/Dart-Code#4577.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in debugger Relates to the debug adapter or process of launching a debug session in flutter Relates to running Flutter apps is enhancement
Projects
None yet
Development

No branches or pull requests

2 participants