Skip to content

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

Closed

Description

@stas-lesiuk

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)

Activity

  1. DanTup commented on Jul 12, 2021

    @DanTup
    Member

    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!

  2. added
    awaiting infoRequires more information from the customer to progress
    on Jul 12, 2021
  3. 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)[/+] on Jul 12, 2021
  4. stas-lesiuk commented on Jul 14, 2021

    @stas-lesiuk
    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.

  5. DanTup commented on Jul 14, 2021

    @DanTup
    Member

    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.

  6. added
    in lsp/analysis serverSomething to be fixed in the Dart analysis server
    and removed
    awaiting infoRequires more information from the customer to progress
    on Jul 14, 2021
  7. added this to the v3.25.0 milestone on Jul 14, 2021
  8. DanTup commented on Jul 14, 2021

    @DanTup
    Member

    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).

  9. ViniciusSossela commented on Aug 3, 2021

    @ViniciusSossela

    @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
    
    
  10. DanTup commented on Aug 3, 2021

    @DanTup
    Member

    @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!

  11. walles commented on Jun 11, 2022

    @walles

    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...

  12. DanTup commented on Jun 11, 2022

    @DanTup
    Member

    @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!

  13. naveenkumarp369 commented on Aug 4, 2023

    @naveenkumarp369

    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 ?

  14. DanTup commented on Aug 7, 2023

    @DanTup
    Member

    @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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions