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

Running "Fix All" command takes a long time (~13s) #3469

Closed
stas-lesiuk opened this issue Jul 11, 2021 · 10 comments
Closed

Running "Fix All" command takes a long time (~13s) #3469

stas-lesiuk opened this issue Jul 11, 2021 · 10 comments
Labels
in lsp/analysis server Something to be fixed in the Dart analysis server is performance
Milestone

Comments

@stas-lesiuk
Copy link

After some potential modifications (I was not working on project for some time), VSCode started taking too long time when I save dart file. These "potential modifications" may be some libs update in pubspec.yaml (after pull other teammate's changes), or maybe flutter version update.

Anyway, it either takes too long or doesn't finish at all, so I have to cancel it and only then Hot Reload updates app (I'm using physical device connected by USB).

Also it seems that dart files auto formatting is gone - I have to indent my files manually.
Dart-Code-Log-2021-06-00 22-22-49.txt

The message says "Saving 'filename.dart'. Applying code action 'Fix All'" and it shows on every file save.

Here's the screenshot of a message:
Screenshot 2021-07-11 at 22 26 33

The log file is attached as well.

Versions:

  • VS Code version: Version: 1.58.0 (Universal)
  • Dart extension version: v3.24.2
  • Dart/Flutter SDK version:
    Dart SDK version: 2.14.0-298.0.dev (dev)

Flutter 2.4.0-1.0.pre.173 • channel master • https://github.com/flutter/flutter.git
Framework • revision 33517505b5 (2 days ago) • 2021-07-09 23:46:03 -0400
Engine • revision 36271dc62b
Tools • Dart 2.14.0 (build 2.14.0-298.0.dev)

@DanTup
Copy link
Member

DanTup commented Jul 12, 2021

The message says "Saving 'filename.dart'. Applying code action 'Fix All'" and it shows on every file save.

It's not the problem, but do you have this enabled in your settings? (if not, I wouldn't expect it to run Fix All on-save).

"editor.codeActionsOnSave": {
	"source.fixAll": true,
},

Can you also confirm if this only happens in a specific project, or all of them?

I can see in the logs that the call to fixAll took 13 seconds which does seem quite slow:

[10:22:51 PM] [Analyzer] [Info] ==> {"jsonrpc":"2.0","id":41,"method":"workspace/executeCommand","params":{"command":"edit.fixAll","arguments":["/Users/myusername/mobile-app/lib/pages/home page/my_project_home_page.dart"]}}
[10:23:04 PM] [Analyzer] [Info] <== {"id":41,"jsonrpc":"2.0","result":null}

If you can share an exact project/file that it takes this long on and I can reproduce it here, I can look at why it's taking so long. Thanks!

@DanTup DanTup added the awaiting info Requires more information from the customer to progress label Jul 12, 2021
@DanTup DanTup changed the title Performance issue in VSCode on dart flutter project save and no formatting on save Running "Fix All" command takes a long time (~13s) Jul 12, 2021
@stas-lesiuk
Copy link
Author

Hi, I just checked my .vscode/settings.json and it has just 3 lines, which are:

{
    "editor.codeActionsOnSave": {"source.fixAll": true}
}

Moreover, I investigated that it was added 2 weeks ago by other team member, while I was inactive in this project. If I remove this - file saves pretty fast. Manual formatting works as well. Is there a chance I have source folder configured wrong, so it takes too many files into account?

I also checked if this issue occurs on other project, and it does not, however the second project is significantly smaller (1/3 of current project size I guess).

Also I checked if issue occurs on other PC I use to work and it does not, so it seems to be attached strictly to this workspace on my MacBook.

@DanTup
Copy link
Member

DanTup commented Jul 14, 2021

Thanks - I tested this with some larger projects and also saw similar timings - such as 10 seconds for flutter_gallery/lib/studies/shrine/expanding_bottom_sheet.dart. I'm not certain what the expectations are here, the code we're is usually run across a whole project (eg. as part of dart/flutter fix) so it might not really be optimised for single-file use (or I may not be using it optimally).

For now I would recommend not running this command on-save and instead manually invoking it with the Fix All command in VS Code.

@DanTup DanTup added is performance in lsp/analysis server Something to be fixed in the Dart analysis server and removed awaiting info Requires more information from the customer to progress is bug labels Jul 14, 2021
@DanTup DanTup added this to the v3.25.0 milestone Jul 14, 2021
dart-bot pushed a commit to dart-lang/sdk that referenced this issue Jul 14, 2021
…P fix-all request

Fixes Dart-Code/Dart-Code#3469.

Change-Id: I28812eda6b3f2263c0a341309719e8adeb1a143e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206784
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
@DanTup
Copy link
Member

DanTup commented Jul 14, 2021

This is fixed by dart-lang/sdk@de918b2. It now reuses the existing analysis contexts which should make things fast (whereas before the files were being resolved in a new context - which was fine for the command line tool which wouldn't have any existing contexts, but wasteful here).

The fix is in the SDK, so it'll show up in a future Dart/Flutter SDK (if you're using Flutter master, I would expect it'd show up within a few days).

@ViniciusSossela
Copy link

@DanTup I am trying to launch the Fix All command, but it doesn't show on the command palette. Am I missing something?

Screen Shot 2021-08-03 at 10 11 21

Screen Shot 2021-08-03 at 10 13 45

Flutter 2.2.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision f4abaa0735 (5 weeks ago) • 2021-07-01 12:46:11 -0700
Engine • revision 241c87ad80
Tools • Dart 2.13.4

@DanTup
Copy link
Member

DanTup commented Aug 3, 2021

@ViniciusSossela as noted above, this involved changes in the SDK so will only show up when using an SDK that includes those changes. This does not currently include the stable channels of Dart/Flutter, though it is available on some of the other channels. It'll show up in stable after a future SDK release. Hope this makes sense!

@walles
Copy link

walles commented Jun 11, 2022

It'll show up in stable after a future SDK release.

@DanTup do you know when this could happen? I still don't see any "Fix All" on my command palette...

@DanTup
Copy link
Member

DanTup commented Jun 11, 2022

@walles this issue is about the performance of the command, not whether it appears. If you're not seeing the command, please file a new issue and include your versions of VS Code, the Dart extension and the Dart/Flutter SDK shown in the bottom-right status bar. Thanks!

@naveenkumarp369
Copy link

PS D:\app-repo-store\ODAPP_July2023_fixImageCapture\AICL-ODCollection-App> dart fix --apply
Computing fixes in aicl-odcollection-app...

I waited for more than an hour , its stuck in same . What can i do ?

@DanTup
Copy link
Member

DanTup commented Aug 7, 2023

@naveenkumarp369 this issue was specific to VS Code / the LSP server. Since your issue is happening from the terminal it will be something different.

Please file an issue at https://github.com/dart-lang/sdk/issues and include information about your project that might help understand the issue (for example how large / how many files is it, how many issues are reported by dart/flutter analyze that could be being fixed, and which version of the SDKs you are using). Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in lsp/analysis server Something to be fixed in the Dart analysis server is performance
Projects
None yet
Development

No branches or pull requests

5 participants