flutter / flutter-intellij

Flutter Plugin for IntelliJ
https://flutter.dev/using-ide
BSD 3-Clause "New" or "Revised" License
1.95k stars 311 forks source link

Cannot debug local package with breakpoints in Android Studio #6550

Closed NickNevzorov closed 1 year ago

NickNevzorov commented 1 year ago

Whenever I run the debug, the breakpoints in packages turn from red circles to gray slashed circles...

Breakpoints in the projects working, but in local packages not. Android studio and plugins updates do last version

bp

S:\projects_flutter\wincalc\webshop> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.3.10, on Microsoft Windows [Version 10.0.22621.963], locale ru-UA)
[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.4.1)
[√] Android Studio (version 2021.3)
[√] Connected device (3 available)
[√] HTTP Host Availability

• No issues found!
blasko commented 1 year ago

Seeing the same thing with the latest plugin release.

stevemessick commented 1 year ago

To clarify, this problem appeared in v71 but was working in v70?

NickNevzorov commented 1 year ago

To clarify, this problem appeared in v71 but was working in v70?

v70 is not compatable with lates version of IDE

blasko commented 1 year ago

I had it working on v71.2.6 (IntelliJ Ultimate) this morning. Once I upgraded to v71.3.6, package/library breakpoints were not being hit.

NickNevzorov commented 1 year ago

I had it working on v71.2.6 (IntelliJ Ultimate) this morning. Once I upgraded to v71.3.6, package/library breakpoints were not being hit.

In Android Studio breakpoints working only with 64.1.4

stevemessick commented 1 year ago

@NickNevzorov @blasko can you try something? Create a new run config, identical to the old one, and see if running using that changes anything.

NickNevzorov commented 1 year ago

@NickNevzorov @blasko can you try something? Create a new run config, identical to the old one, and see if running using that changes anything.

I have a big flutter projects + two local packages (libraries). If I debug with flutter plugin 65+ breakpoints in local pachages are not active. When I delete flutter package and install 64.1.4 version from disk all working fine

NickNevzorov commented 1 year ago

To clarify, this problem appeared in v71 but was working in v70?

No, I trying all plugins from 64 to last version. Working only in 64

stevemessick commented 1 year ago

Still waiting for the result of debugging with a new run config.

NickNevzorov commented 1 year ago

Still waiting for the result of debugging with a new run config.

Not working with 71.2.3

image

stevemessick commented 1 year ago

Thanks for checking. Too bad the fix wasn't that simple.

stevemessick commented 1 year ago

@helin24 Is this something you are familiar with?

helin24 commented 1 year ago

This should work, but it sounds like breakpoint mapping failed. @NickNevzorov could you send me your logs after you have this problem? These are at Help > Show log in finder > idea.log is the file to send. If you have proprietary info in there you don't want exposed please send to my email (helinx@google.com).

NickNevzorov commented 1 year ago

This should work, but it sounds like breakpoint mapping failed. @NickNevzorov could you send me your logs after you have this problem? These are at Help > Show log in finder > idea.log is the file to send. If you have proprietary info in there you don't want exposed please send to my email (helinx@google.com).

  1. I update plugin to 71.2.3
  2. restart IDE
  3. Run project in debug mode, breakpoint in local package is disabled
  4. Close IDE
  5. Upload file

Tnx idea.zip

stevemessick commented 1 year ago

Thanks @helin24 and @NickNevzorov :)

helin24 commented 1 year ago

@NickNevzorov thanks for the log, I can see that the package URI lookups failed. When you say "local package", does this mean you have in your pubspec file a local path rather than the name of a package? And does breakpoint setting work for non-local packages?

NickNevzorov commented 1 year ago

@NickNevzorov thanks for the log, I can see that the package URI lookups failed. When you say "local package", does this mean you have in your pubspec file a local path rather than the name of a package? And does breakpoint setting work for non-local packages?

I have my own library. package draw. In pubspec is:

  draw:
    path: s:/projects_flutter/wincalc/draw/

In program module:

import 'package:draw/main.dart';

Breakpoints does not work.

If I trying setup breakpoint in standart package (for example "import 'package:url_launcher/url_launcher.dart';") it works!

helin24 commented 1 year ago

I see the issue is that I'm not sending the correct Windows local path to our VM service to change into a package URI to set breakpoints. I'll look into fixing this soon!

stevemessick commented 1 year ago

Thanks @helin24 !

helin24 commented 1 year ago

Argh I spoke too soon! Looking more closely at the logs, I can see that some of the paths were found correctly and some weren't, and so I'm not sure if it's an issue with Windows generally.

For example, I see that file:///S:/projects_flutter/wincalc/webshop/lib/src/calc_engine/komPred.dart was resolved correctly (so hopefully you were able to set breakpoints there), but file:///S:/projects_flutter/wincalc/draw/lib/src/winBuilder/winBuilder.dart was not.

Is the former not a local package? @NickNevzorov

NickNevzorov commented 1 year ago

Argh I spoke too soon! Looking more closely at the logs, I can see that some of the paths were found correctly and some weren't, and so I'm not sure if it's an issue with Windows generally.

For example, I see that file:///S:/projects_flutter/wincalc/webshop/lib/src/calc_engine/komPred.dart was resolved correctly (so hopefully you were able to set breakpoints there), but file:///S:/projects_flutter/wincalc/draw/lib/src/winBuilder/winBuilder.dart was not.

Is the former not a local package? @NickNevzorov

No, webshop - its final project. Draw - is a part of graphic engine:

webshop: image

draw (library, standalone project for easier debugging): image

folders structure: image

helin24 commented 1 year ago

Hmmm I'm not able to reproduce this problem in my own Windows environment. @NickNevzorov are you able to share your project with me? Or a smaller version of this project that shows the same issue?

NickNevzorov commented 1 year ago

Hmmm I'm not able to reproduce this problem in my own Windows environment. @NickNevzorov are you able to share your project with me ? Or a smaller version of this project that shows the same issue?

6_flutter.zip

What I do:

  1. Create c:\6_flutter
  2. Create two projects, project_1 and project_2
  3. In project_1 test function testDebug
  4. Include project_1 to project_2
  5. Call testDebug from project_2

p1

p2

helin24 commented 1 year ago

@NickNevzorov thanks for the example, unfortunately I'm able to run it on Windows and stop on breakpoints in both project_1 and project_2 following your instructions. I see your project is running, so this is probably silly to check, but you can definitely see output in the console if you add print('something') in your testDebug method, right?

I'm looking into how we can check what paths the VM service registers for your case.

NickNevzorov commented 1 year ago

print('something')

  1. Yes, print working. image

  2. If I press step in (F7) on project_1.testDebug(), I can debug step by step and see local variables

Simply create two projects and include first project to second, breakpoints in first projects did not working if calling method from second project

helin24 commented 1 year ago

@NickNevzorov sorry about the delay; I'm just returning from vacation. Do you have VS Code set up for your project? If so, it would be good to test if you can set breakpoints properly there. We are using a different way of mapping files between VS Code and IntelliJ.

NickNevzorov commented 1 year ago

@NickNevzorov sorry about the delay; I'm just returning from vacation. Do you have VS Code set up for your project? If so, it would be good to test if you can set breakpoints properly there. We are using a different way of mapping files between VS Code and IntelliJ.

In VSCode also not working

helin24 commented 1 year ago

@NickNevzorov

  1. Do you always use the S: drive? Is there a difference if you use the C: drive for the mini project you supplied?
  2. I may be able to compare your dill file to see if the path imported is something unexpected. You could find this in project_2/.dart_tool/flutter_build/<BUILD_HASH>/app.dill after running your project.
NickNevzorov commented 1 year ago

@NickNevzorov

  1. Do you always use the S: drive? Is there a difference if you use the C: drive for the mini project you supplied?
  2. I may be able to compare your dill file to see if the path imported is something unexpected. You could find this in project_2/.dart_tool/flutter_build/<BUILD_HASH>/app.dill after running your project.
  1. S drive is veracrypt container, for working projects. Project_1 and 2 i created for demonstrate a problem in C drive
  2. I attach all projects folders, 521M - https://drive.google.com/file/d/1PG-6bQgvyC10AZV1O-7dex8R8kn9Vkr1/view?usp=sharing

P.S. Now if I need debug a local package i downgrade flutter plugin to flutter-intellij-64.1.4, and upgrade to last version after

helin24 commented 1 year ago

@NickNevzorov Thanks for the info and the log - we looked through this and unfortunately there's still too much noise in there to make sense of why the breakpoints would be failing (sorry about that). Would it be possible for you to try out a Dart CLI application (not Flutter) and reproduce this problem? https://dart.dev/tutorials/server/cmdline

NickNevzorov commented 1 year ago

@NickNevzorov Thanks for the info and the log - we looked through this and unfortunately there's still too much noise in there to make sense of why the breakpoints would be failing (sorry about that). Would it be possible for you to try out a Dart CLI application (not Flutter) and reproduce this problem? https://dart.dev/tutorials/server/cmdline

In dart console app breakpoints working fine.

May I create for you virtual windows mashine with two project ? For VirtualBox

helin24 commented 1 year ago

@NickNevzorov sure, that could be helpful!

NickNevzorov commented 1 year ago

@helin24 please try http://gofile.me/6Z5SR/PvBhJDtvg

vhd disk for virtual box windows 10.

Debug

p.s. Please try to download soon. I am from Ukraine, we are now at war with Russia, the terrorist state is hitting our civil infrastructure, there are constant interruptions in electricity. We repulsed the last missile attack quite successfully, but electricity is often cut off on weekdays, it will be difficult for me to keep the server on on weekdays

helin24 commented 1 year ago

@NickNevzorov so sorry to hear about the difficulties you're experiencing (and sorry I didn't see your message until Monday). It seems to be downloading, albeit very slowly (9 hours left...). If this doesn't work I'll try to get it this coming weekend.

helin24 commented 1 year ago

@NickNevzorov download eventually succeeded, but I'm probably doing something wrong during my setup of Virtualbox. Posting here in case you have tips.

Screenshot 2023-02-14 at 3 49 44 PM Screenshot 2023-02-14 at 3 50 02 PM Screenshot 2023-02-14 at 3 50 18 PM Screenshot 2023-02-14 at 3 50 31 PM Screenshot 2023-02-14 at 3 53 03 PM

No log file, weirdly. Let me know if I'm missing something obvious. I'll also try this out on a Windows machine since I'm currently trying it from a Mac host.

NickNevzorov commented 1 year ago

@helin24 my settings:

image

image

image

If it doesn't work, then I'll make a backup of my virtual pc

helin24 commented 1 year ago

This problem is due to the VM service (on some windows machines) having a mapping for paths with a lowercase c:/ but not an uppercase C:/.

This is going to be fixed with https://dart-review.git.corp.google.com/c/sdk/+/288821 (cc @bkonyi), but @NickNevzorov and @blasko, I'm not sure if your projects are going to be able to use a more updated Dart version. I think I can provide you with a patched plugin that handles this special case if you'd prefer that.

NickNevzorov commented 1 year ago

@helin24 if the bug is fixed in the new version it will be enough.

Now if I need debugging local package, I just simple downgrade the plugin, and then update back

helin24 commented 1 year ago

Actually @NickNevzorov is this fixed if you just use a capitalized C:\ in your path when requiring a package? I was thinking this path was coming from reading from disk and didn't realize this is explicitly specified in the pubspec file.

NickNevzorov commented 1 year ago

@helin24 yes, it Works!

Right syntax:

project_1: path: C:\6_flutter\project_1