Dart-Code: Dart code stuck on "Analyzing", making every operation take too long
After upgrading to Dart Code 3.15 and VSCode to 1.50, Dart Code gets stuck on “Analyzing”, making every operation, from coded completion to saving files, take too long.
To Reproduce
- Use Dart Code 3.15 and VSCode 1.50
- Open any Flutter project
- Wait for the initial “Analyzing” process to finish
- Open any Dart file
- Edit the file, requesting code multiple times
- VSCode starts “Analyzing” after every code completion request, taking increasingly longer times every time it happens
Expected behavior After doing initial analysis, code completion should take from a few milliseconds up to a few seconds
Versions (please complete the following information):
- 1.50
- 3.15.0
- Flutter 1.22
Output from flutter doctor -v
❯ flutter doctor -v
[√] Flutter (Channel stable, 1.22.0, on Microsoft Windows [versão 10.0.19041.508], locale pt-BR)
• Flutter version 1.22.0 at D:\dcvia\Desenvolvimento\Android\flutter
• Framework revision d408d302e2 (10 days ago), 2020-09-29 11:49:17 -0700
• Engine revision 5babba6c4d
• Dart version 2.10.0
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3) • Android SDK at D:\dcvia\Desenvolvimento\Android\Sdk • Platform android-29, build-tools 29.0.3 • ANDROID_HOME = D:\dcvia\Desenvolvimento\Android\Sdk • Java binary at: C:\Users\dcvia\android-studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01) • All Android licenses accepted.
[√] Android Studio (version 4.0) • Android Studio at C:\Users\dcvia\android-studio • Flutter plugin version 49.0.2 • Dart plugin version 193.7547 • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] VS Code (version 1.50.0) • VS Code at C:\Users\dcvia\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.15.0
[√] Connected device (1 available) • SM G950F (mobile) • ce11182b72a0ba3a02 • android-arm64 • Android 9 (API 28)
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 15
- Comments: 21 (8 by maintainers)
I battled with this for a few hours. In case anyone else is battling with this, in the end I tracked the issue down to a half written line of code:
Future<List<>>
Thanks for the logs - I can definitely see a lot of slowness for some requests, though it’s not entirely clear why (the log also doesn’t seem to contain any analysis status notifications where I’d expect to see the appear/disappear).
Some things to try:
Enable the
dart.previewLsp
setting. This moves more of the work into the server and has some reasonable performance gains (especially when it comes to code completion). LSP will become the default in the near future.If you were running debug sessions when seeing these issues, try this beta build (v3.15.1 may be released later today, so if you’ve already been upgraded to v3.15.1 by the time you read this, no need to install the beta). There was a severe performance issue in v3.15.0 that would consume vast amounts of CPU when printing large strings (or large numbers of) while your app was running.
Run
code --status
when the CPU is high / stuck analyzing and provide the output here.If anyone can reproduce this reliably on a public project they can share, that may help me track down what’s going on.
Glad to hear! I’ll close this on the basis that the non-LSP version is going away over the coming releases.
This has always been the case, though the protocol that the VS Code extension uses to communicate with the Dart language server is changing slightly with this (it used to be a custom protocol designed for Dart, but LSP is a standard that many languages/editors use).
It’s fairly common for languages to have their own “language servers” that run separately from the editors. This allows sharing a lot of functionality (like code completion and analysis) between editors much more easily (and LSP aims to make this even easier).
Hope this helps!
@raphael-bmec-co thanks for tracking this down and posting! I was able to reproduce the same and have filed an SDK issue at https://github.com/dart-lang/sdk/issues/44477.