emacs-lsp / lsp-dart

lsp-mode :heart: dart
https://emacs-lsp.github.io/lsp-dart
GNU General Public License v3.0
202 stars 24 forks source link

Debug session process exited with status: killed #117

Closed zw963 closed 2 years ago

zw963 commented 3 years ago

Describe the bug

I am a new to dap, when i want to use dap-mode to debug a working flutter, i get following error.

Debug session process exited with status: killed

To Reproduce

Following is minimum config:

(require 'lsp-mode)
(require 'lsp-modeline)
(require 'lsp-headerline)
(require 'dap-mode)
(require 'dap-ui)
(require 'dap-mouse)
(require 'lsp-dart)
(require 'dart-mode)
(add-to-list 'auto-mode-alist '("\\.dart\\'" . dart-mode))

After use this config open a dart file in a flutter project.

run lsp success.

LSP :: Connected to [dart_analysis_server:22531/starting].
LSP :: Unable to autoconfigure company-mode.
LSP :: dart_analysis_server:22531 initialized successfully in folders: (/home/zw963/Dart/myapp/lib)
LSP :: Unable to autoconfigure company-mode.

run lsp-dart-dap-setup successful

LSP :: Starting to download https://github.com/Dart-Code/Dart-Code/releases/download/v3.25.1/dart-code-3.25.1.vsix to /home/zw963/.emacs.d/.extension/github/Dart-Code/Dart-Code/3.25.1/dart-code.zip...
End of buffer
Wrote /home/zw963/.emacs.d/.extension/github/Dart-Code/Dart-Code/3.25.1/dart-code.zip
LSP :: Finished downloading /home/zw963/.emacs.d/.extension/github/Dart-Code/Dart-Code/3.25.1/dart-code.zip...
LSP :: Decompressing /home/zw963/.emacs.d/.extension/github/Dart-Code/Dart-Code/3.25.1/dart-code.zip...
(Shell command succeeded with no output)
LSP :: Decompressed /home/zw963/.emacs.d/.extension/github/Dart-Code/Dart-Code/3.25.1/dart-code...
[LSP Dart] Dart debugger installed successfully!

Try debug on line 4

image

select Flutter::Debug as template

image

select a device to run.

Because both of device can run successful on my local laptop with flutter run -d linux, or flutter run -d web.

so, i just select one of them. linux

image

get following error message

Processing ... Debug session process exited with status: killed

Version

[Flutter SDK] /home/zw963/Dropbox/linux/utils/flutter/
[Flutter project] true
[Project entrypoint] /home/zw963/Dart/myapp/lib/main.dart
ericdallo commented 3 years ago

@zw963 Did you lsp-dart-dap-setup before as mentioned here?

zw963 commented 3 years ago

Yes, i do. as describe on above

LSP :: Starting to download https://github.com/Dart-Code/Dart-Code/releases/download/v3.25.1/dart-code-3.25.1.vsix to /home/zw963/.emacs.d/.extension/github/Dart-Code/Dart-Code/3.25.1/dart-code.zip...
End of buffer
Wrote /home/zw963/.emacs.d/.extension/github/Dart-Code/Dart-Code/3.25.1/dart-code.zip
LSP :: Finished downloading /home/zw963/.emacs.d/.extension/github/Dart-Code/Dart-Code/3.25.1/dart-code.zip...
LSP :: Decompressing /home/zw963/.emacs.d/.extension/github/Dart-Code/Dart-Code/3.25.1/dart-code.zip...
(Shell command succeeded with no output)
LSP :: Decompressed /home/zw963/.emacs.d/.extension/github/Dart-Code/Dart-Code/3.25.1/dart-code...
[LSP Dart] Dart debugger installed successfully!
zw963 commented 3 years ago

BTW, i am new to both dap-mode and dart, flutter, and never use dap-mode before, if we need create a emulator before start debug?

 ╰─ $ flutter emulators
No emulators available.

To create a new emulator, run 'flutter emulators --create [--name xyz]'.

You can find more information on managing emulators at the links below:
  https://developer.android.com/studio/run/managing-avds
  https://developer.android.com/studio/command-line/avdmanager
ericdallo commented 3 years ago

yes, you need to create it via flutter emulators, otherwise from your screenshots, you will only be able to launch on google chrome

zw963 commented 3 years ago

yes, you need to create it via flutter emulators, otherwise from your screenshots, you will only be able to launch on google chrome

Okay, i double check, it still not works with web - browser - chrome option, same error message as before:

Debug session process exited with status: killed

How can i offer more debug info?

Following is the only config when i do test. (i will run (lsp), (dap-debug) manually)

(require 'lsp-modeline)
(require 'lsp-headerline)
(require 'dap-mode)
(require 'dap-ui)
(require 'dap-mouse)
(require 'lsp-dart)
(require 'dart-mode)
(add-to-list 'auto-mode-alist '("\\.dart\\'" . dart-mode))
ericdallo commented 3 years ago

Probably there is some message on the dap output buffer or error buffer (I can't recall the name correctly), also, you need node on your PATH to run the debugger (this will not be necessary in the future I hope 🀞🏻 )

zw963 commented 3 years ago

Probably there is some message on the dap output buffer or error buffer (I can't recall the name correctly), also, you need node on your PATH to run the debugger (this will not be necessary in the future I hope 🀞🏻 )

Yes, thank you , i see that.

(node:41927) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use `node --trace-deprecation ...` to show where the warning was created)

Process Flutter :: Debug stderr finished

my node version

 ╰─ $ which node
/usr/sbin/node
 ╰─ $ node 
Welcome to Node.js v16.8.0.
Type ".help" for more information.
> 
ericdallo commented 3 years ago

I usually use node 10/12, not sure everything works with node 16, anyway, anything on dap-mode stderr or any buffer related?

zw963 commented 3 years ago

anything on dap-mode stderr or any buffer related?

I guess no, except above node info.

I usually use node 10/12, not sure everything works with node 16,

Okay, i will try install a older version tomorrow.

zw963 commented 3 years ago

I usually use node 10/12, not sure everything works with node 16, anyway, anything on dap-mode stderr or any buffer related?

Hi, there is no way to install very old node version on offical repo.

https://nodejs.org/en/download/

I test on Latest LTS Version: 14.17.5 (includes npm 6.14.14), still not work.

could you please test on that?

Please see this SO answer, maybe help on this.

Thank you.

zw963 commented 3 years ago

Hi, i report to flutter upstream, https://github.com/flutter/flutter/issues/89132

and they seem like confirm this is a issue, so i close issue for now.

ericdallo commented 3 years ago

good, thanks!

zw963 commented 2 years ago

@ericdallo , could you please help me make the last effort for make dap-debug working with dart ?

I need you help me on the CORRECT way to start a break point on a refresh new flutter application?

can we use this which i send you several minutes ago to start?

i want to ensure i do this correct way.

thank you.

zw963 commented 2 years ago

this command seem like works for me now on command line, because no error, a good start, right?

╰─ $ flutter run --machine --start-paused --target  lib/main.dart
[{"event":"daemon.connected","params":{"version":"0.6.1","pid":553347}}]
[{"event":"app.start","params":{"appId":"6197abdb-234a-46c7-bdfa-951402c8d009","deviceId":"3EP0219401000961","directory":"/home/zw963/Dart/test_flutter_performance","supportsRestart":true,"launchMode":"run"}}]
Launching lib/main.dart on LYA AL00 in debug mode...
[{"event":"app.progress","params":{"appId":"6197abdb-234a-46c7-bdfa-951402c8d009","id":"0","progressId":null,"message":"Running Gradle task 'assembleDebug'...","finished":false}}]
[{"event":"app.progress","params":{"appId":"6197abdb-234a-46c7-bdfa-951402c8d009","id":"0","progressId":null,"finished":true}}]
βœ“  Built build/app/outputs/flutter-apk/app-debug.apk.
[{"event":"app.debugPort","params":{"appId":"6197abdb-234a-46c7-bdfa-951402c8d009","port":41103,"wsUri":"ws://127.0.0.1:41103/N568iNCBXWM=/ws","baseUri":"file:///data/user/0/com.example.test_flutter_performance/code_cache/test_flutter_performanceEMSOBS/test_flutter_performance/"}}]
[{"event":"app.progress","params":{"appId":"6197abdb-234a-46c7-bdfa-951402c8d009","id":"1","progressId":null,"message":"Syncing files to device LYA AL00...","finished":false}}]
[{"event":"app.progress","params":{"appId":"6197abdb-234a-46c7-bdfa-951402c8d009","id":"1","progressId":null,"finished":true}}]
[{"event":"app.started","params":{"appId":"6197abdb-234a-46c7-bdfa-951402c8d009"}}]
I/AwareBitmapCacher(30276): init lrucache size: 2097152 pid=30276
W/InputMethodManager(30276): startInputReason = 8
E/RtgSchedManager(30276): endActivityTransaction: margin state not match
E/RtgSchedManager(30276): endActivityTransaction: margin state not match
E/RtgSchedManager(30276): endActivityTransaction: margin state not match
W/libEGL  (30276): EGLNativeWindowType 0x7513198010 disconnect failed
D/ZrHung.AppEyeUiProbe(30276): not watching, wait.
W/libEGL  (30276): EGLNativeWindowType 0x758edada10 disconnect failed
I/ActivityThread(30276): Handle window ActivityRecord{a32b9d0 token=android.os.BinderProxy@70c475d {com.example.test_flutter_performance/com.example.test_flutter_performance.MainActivity}} visibility: false
E/RtgSchedManager(30276): endActivityTransaction: margin state not match
D/DecorView(30276): showOrHideHighlightView: hasFocus=false; winMode=1; isMrgNull=true
D/RtgSched(30276): resetRtgSchedHandle failed enable:0
D/ActivityThread(30276): Won't deliver top position change in state=5
D/ZrHung.AppEyeUiProbe(30276): restart watching
D/mali_winsys(30276): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
D/mali_winsys(30276): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
D/DecorView(30276): showOrHideHighlightView: hasFocus=true; winMode=1; isMrgNull=true
W/InputMethodManager(30276): startInputReason = 1
zw963 commented 2 years ago

i will use following minimum config for test.

emacs is emacs 28 master newest.

(require 'dart-mode)
(require 'lsp-mode)
(require 'lsp-dart)
(require 'lsp-ui)
(require 'lsp-modeline)
(require 'lsp-headerline)
(require 'lsp-treemacs)
(require 'dap-mode)
(require 'dap-ui)
(require 'dap-mouse)
(require 'flycheck)
(require 'company)

(setq lsp-dart-flutter-widget-guides nil)
(add-hook 'dart-mode-hook 'lsp)
(add-to-list 'auto-mode-alist '("\\.dart\\'" . dart-mode))
ericdallo commented 2 years ago

@zw963 Alright, what I do is:

Is this what you want?

zw963 commented 2 years ago

@zw963 Alright, what I do is:

* run `lsp-dart-dap-setup`, this will download dap debugger.

* add a breakpoint on the desired line with `dap-breakpoint-add`

* run `dap-debug` and select the device when it prompt

Is this what you want?

Yes, this was what i have done, anyway, i will do it again.

run lsp-dart-dap-setup, this will download dap debugger.

[LSP Dart] Dart debugger installed successfully!

add a breakpoint on the desired line with dap-breakpoint-add

image

run dap-debug and select the device when it prompt (i use HuaWei really device)

image

zw963 commented 2 years ago

my phone is black background color in app. (not same as when run flutter run, it should be a click with number can be increcing.

ericdallo commented 2 years ago

that's weird, lsp-dart just trigger the debugger from https://github.com/Dart-Code/Dart-Code/, running node extension/out/dist/debug.js flutter I plan to add soon support for the debugger that is built-in on dart-sdk, but this probably wil only work for future flutter releases

zw963 commented 2 years ago

let us try a again use xiao mi emulator.

Debug template, select Flutter :: Run.

device select Xiaomi 7

image

image

need wait, right?

ericdallo commented 2 years ago

@zw963 are you using flutter_sample project? the first screen is indeed white, you need to scroll to left/right (I should probably add a text on the first screen hehe)

zw963 commented 2 years ago

okay, let me use flutter_sample, wait a minutes.

ericdallo commented 2 years ago

oh, not really, the first screen already has context other than blank

Let's see what happens on flutter_sample

zw963 commented 2 years ago

use flutter_sample, exist following warning:

This app is using a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to migrate this app to the V2 embedding.
Take a look at the docs for migrating an app: https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects
FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not resolve com.android.tools.build:builder:3.2.1.
     Required by:
         project : > com.android.tools.build:gradle:3.2.1
      > Could not resolve com.android.tools.build:builder:3.2.1.
         > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/builder/3.2.1/builder-3.2.1.pom'.
            > Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/builder/3.2.1/builder-3.2.1.pom'.
               > Remote host terminated the handshake

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 29s
Running Gradle task 'assembleDebug'...                             30.1s
[!] Gradle threw an error while downloading artifacts from the network. Retrying to download...
[!] Your app isn't using AndroidX.

Still running, don't know if can success.

ericdallo commented 2 years ago

the warnings are becuse it's a outdated project, I need to update to latest flutter or create a new sample

zw963 commented 2 years ago

It seem like still building, it spent longer time than new project.

image

zw963 commented 2 years ago

that's weird, lsp-dart just trigger the debugger from https://github.com/Dart-Code/Dart-Code/, running node extension/out/dist/debug.js flutter I plan to add soon support for the debugger that is built-in on dart-sdk, but this probably wil only work for future flutter releases

So, the plugin what we used to debug was not same as VS Code used to, right?

ericdallo commented 2 years ago

it's the same vscode uses, but version different, you can try bump via variable lsp-dart-dap-extension-version, but I doubt it's related with your issue

zw963 commented 2 years ago

Oops, sorry, i guess because china firewall issue, cause build so long time, i will break, build again. wait 1 minute

zw963 commented 2 years ago

java.lang.Exception: Unknown or invalid session 1 at org.jetbrains.kotlin.daemon.common.CompileService$CallResult$Error.get(CompileService.kt:60) at org.jetbrains.kotlin.daemon.common.CompileService$CallResult$Error.get(CompileService.kt:59) at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.compileWithDaemon(GradleKotlinCompilerRunner.kt:221) at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.compileWithDaemonOrFallback(GradleKotlinCompilerRunner.kt:166) at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.compileWithDaemonOrFallback(GradleKotlinCompilerRunner.kt:63) at org.jetbrains.kotlin.compilerRunner.KotlinCompilerRunner.runCompiler(KotlinCompilerRunner.kt:133) at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.runJvmCompiler(GradleKotlinCompilerRunner.kt:119) at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler$kotlin_gradle_plugin(Tasks.kt:393) at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler$kotlin_gradle_plugin(Tasks.kt:297) at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.execute(Tasks.kt:259) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73) at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:50) at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39) at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:131) at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300) at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292) at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174) at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90) at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:120) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:99) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:77) at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51) at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59) at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54) at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59) at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101) at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44) at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:91) at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62) at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59) at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54) at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34) at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.run(EventFiringTaskExecuter.java:51) at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300) at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292) at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174) at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90) at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31) at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:46) at org.gradle.execution.taskgraph.LocalTaskInfoExecutor.execute(LocalTaskInfoExecutor.java:42) at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:277) at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:262) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:135) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:130) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.execute(DefaultTaskPlanExecutor.java:200) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.executeWithWork(DefaultTaskPlanExecutor.java:191) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.run(DefaultTaskPlanExecutor.java:130) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) at java.base/java.lang.Thread.run(Thread.java:834) warning: the '-d' option with a directory destination is ignored because '-Xbuild-file' is specified /home/zw963/.gradle/caches/transforms-1/files-1.1/annotation-experimental-1.1.0.aar/e13abb68f9b0cace54ac30133889f76a/jars/classes.jar!/META-INF/annotation-experimental_release.kotlin_module: error: module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.4.2, expected version is 1.1.11.

FAILURE: Build failed with an exception.

BUILD FAILED in 15s Running Gradle task 'assembleDebug'... 16.4s Exception: Gradle task assembleDebug failed with exit code 1

ericdallo commented 2 years ago

yeah, sounds like flutter_sample is outdated somehow, maybe we need to use that zip project you sent before to test

zw963 commented 2 years ago

yeah, sounds like flutter_sample is outdated somehow, maybe we need to use that zip project you sent before to test

okay, i need to restart my OS, don't know why, flutter run is blocked, very slow.

zw963 commented 2 years ago

so, for prove this test_flutter_performance is work, this is screenshot.

image [Uploading test_flutter_performance.zip…]()

zw963 commented 2 years ago

i just run flutter run on command line, now, i try run it in my emacs editor use (lsp-dart-run).

It not work as expected. when i select "xiaomi" device from emacs.

Spawning /home/zw963/flutter/bin/flutter with args ["run","--machine","--start-paused","--target","lib/main.dart"]..  in /home/zw963/Dart/test_flutter_performance/    PID: 8371Launching lib/main.dart on Xiaomi Redmi Note 7 in debug mode...
βœ“  Built build/app/outputs/flutter-apk/app-debug.apk.
zw963 commented 2 years ago

Can we start from a more simple point, in fact, i never run (lsp-dart-run) success in my emacs, but, i can run flutter-run successful in my emacs, how can i make lsp-dart-run work?

ericdallo commented 2 years ago

For the record, your project zip works pretty well to me debugging: image

Can we start from a more simple point, in fact, i never run (lsp-dart-run) success in my emacs, but, i can run flutter-run successful in my emacs, how can i make lsp-dart-run work?

Alright, lsp-dart-run just use the debugger but with a flag to run as normal mode and not debug mode, so probably fixing one will fix the other

zw963 commented 2 years ago

Whatever run (lsp-dart-run), or dap-debug, all same not work, a white background is on my emulator.

Spawning /home/zw963/flutter/bin/flutter with args ["run","--machine","--start-paused","--target","lib/main.dart"]..  in /home/zw963/Dart/test_flutter_performance/    PID: 12688Launching lib/main.dart on Xiaomi Redmi Note 7 in debug mode...
βœ“  Built build/app/outputs/flutter-apk/app-debug.apk.

image

zw963 commented 2 years ago

Maybe command line have more details:

 ╰─ $ flutter run --machine --start-paused --target lib/main.dart -d 192.168.56.104:5555
[{"event":"daemon.connected","params":{"version":"0.6.1","pid":13703}}]
[{"event":"app.start","params":{"appId":"b706db93-ed00-42a0-91b9-28e5c366323e","deviceId":"192.168.56.104:5555","directory":"/home/zw963/Dart/test_flutter_performance","supportsRestart":true,"launchMode":"run"}}]
Launching lib/main.dart on Xiaomi Redmi Note 7 in debug mode...
[{"event":"app.progress","params":{"appId":"b706db93-ed00-42a0-91b9-28e5c366323e","id":"0","progressId":null,"message":"Running Gradle task 'assembleDebug'...","finished":false}}]
[{"event":"app.progress","params":{"appId":"b706db93-ed00-42a0-91b9-28e5c366323e","id":"0","progressId":null,"finished":true}}]
βœ“  Built build/app/outputs/flutter-apk/app-debug.apk.
[{"event":"app.debugPort","params":{"appId":"b706db93-ed00-42a0-91b9-28e5c366323e","port":44227,"wsUri":"ws://127.0.0.1:44227/V9MqggfilY4=/ws","baseUri":"file:///data/user/0/com.example.test_flutter_performance/code_cache/test_flutter_performanceLMLLKG/test_flutter_performance/"}}]
[{"event":"app.progress","params":{"appId":"b706db93-ed00-42a0-91b9-28e5c366323e","id":"1","progressId":null,"message":"Syncing files to device Xiaomi Redmi Note 7...","finished":false}}]
[{"event":"app.progress","params":{"appId":"b706db93-ed00-42a0-91b9-28e5c366323e","id":"1","progressId":null,"finished":true}}]
[{"event":"app.started","params":{"appId":"b706db93-ed00-42a0-91b9-28e5c366323e"}}]
ericdallo commented 2 years ago

Whatever run (lsp-dart-run), or dap-debug, all same not work, a white background is on my emulator.

That's odd, maybe some network/firewall issue? could you try with network disabled?

Also, what is printed to that lsp-dart-flutter-daemon output?

zw963 commented 2 years ago

Whatever run (lsp-dart-run), or dap-debug, all same not work, a white background is on my emulator.

That's odd, maybe some network/firewall issue? could you try with network disabled?

Also, what is printed to that lsp-dart-flutter-daemon output?

This one??

[{"event":"daemon.connected","params":{"version":"0.6.1","pid":8145}}]
[{"event":"daemon.logMessage","params":{"level":"status","message":"Starting device daemon..."}}]
[{"id":97601}]
[{"event":"device.added","params":{"id":"chrome","name":"Chrome","platform":"web-javascript","emulator":false,"category":"web","platformType":"web","ephemeral":false,"emulatorId":null}}]
[{"event":"device.added","params":{"id":"192.168.56.104:5555","name":"Xiaomi Redmi Note 7","platform":"android-x86","emulator":false,"category":"mobile","platformType":"android","ephemeral":true,"emulatorId":null}}]
[{"id":68772,"result":[]}]
[{"event":"daemon.logMessage","params":{"level":"error","message":"Error 1 retrieving device properties for Xiaomi Redmi Note 7:"}}]
[{"event":"daemon.logMessage","params":{"level":"error","message":"adb: device offline\n"}}]
[{"event":"device.removed","params":{"id":"192.168.56.104:5555","name":"Xiaomi Redmi Note 7","platform":"android-arm","emulator":false,"category":"mobile","platformType":"android","ephemeral":true,"emulatorId":null}}]
[{"event":"device.added","params":{"id":"192.168.56.104:5555","name":"Xiaomi Redmi Note 7","platform":"android-x86","emulator":false,"category":"mobile","platformType":"android","ephemeral":true,"emulatorId":null}}]
ericdallo commented 2 years ago

yes, this is probably the error/issue:

[{"event":"daemon.logMessage","params":{"level":"error","message":"Error 1 retrieving device properties for Xiaomi Redmi Note 7:"}}]
[{"event":"daemon.logMessage","params":{"level":"error","message":"adb: device offline\n"}}]
zw963 commented 2 years ago

i restart my emacs again, then run (lsp-dart-run), get following log

[{"event":"daemon.connected","params":{"version":"0.6.1","pid":16194}}]
[{"event":"daemon.logMessage","params":{"level":"status","message":"Starting device daemon..."}}]
[{"id":70864}]
[{"event":"device.added","params":{"id":"chrome","name":"Chrome","platform":"web-javascript","emulator":false,"category":"web","platformType":"web","ephemeral":false,"emulatorId":null}}]
[{"event":"device.added","params":{"id":"192.168.56.104:5555","name":"Xiaomi Redmi Note 7","platform":"android-x86","emulator":false,"category":"mobile","platformType":"android","ephemeral":true,"emulatorId":null}}]
ericdallo commented 2 years ago

my guess: emacs spawns the node command to run the debugger, for some reason the debugger command is having issues with adb or something like that, maybe it's a bug on the debugger, not on lsp-dart or emacs.

i restart my emacs again, then run (lsp-dart-run), get following log

Then the lsp-dart-run worked?

zw963 commented 2 years ago

following is my flutter devices output:

 ╰─ $ 130  flutter devices
2 connected devices:

Xiaomi Redmi Note 7 (mobile) β€’ 192.168.56.104:5555 β€’ android-x86    β€’ Android 9 (API 28)
Chrome (web)                 β€’ chrome              β€’ web-javascript β€’ Google Chrome 96.0.4664.45

BTW: if i enable flutter.el, and run flutter-run, it works, can reload, restart.

Then the lsp-dart-run worked?

No, same,editor can disable previous running app instance, but, new instance still white background.

zw963 commented 2 years ago

my guess: emacs spawns the node command to run the debugger, for some reason the debugger command is having issues with adb or something like that, maybe it's a bug on the debugger, not on lsp-dart or emacs.

if adb exists issue, if fluttel.el will not work too?

ericdallo commented 2 years ago

flutter.el runs flutter under the hood, which is the same of running on your terminal. lsp-dart uses always the debugger for both debug and run the code which uses the same code and interface of dap-mode, my guess is still that your issue is with the debugger, not lsp-dart or emacs

ericdallo commented 2 years ago

does the debug work with vscode? maybe test that will help find the root cause

zw963 commented 2 years ago

image

zw963 commented 2 years ago

does the debug work with vscode? maybe test that will help find the root cause

Sure, it works

ericdallo commented 2 years ago

so maybe vscode is passing some flag or doing something lsp-dart is not, we need to debug Dart-Code/Dart-Code code and confirm that