-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Dart Analyzer very slow/stuck #55281
Comments
@DanTup , do you see this? Have there been more reports of this kind? |
/ cc @bwilkerson |
I've not seen any other reports like this. 100% CPU certainly does not look healthy if it's persisting for a long period after initial analysis. @JonasJW a few questions:
|
We were having the same issue and using the Removing it completely seems to have solved the issue for us, are you using it too, and can you try to remove it to confirm it comes from there if you are ? |
/cc @scheglov |
@DanTup Thanks for the response and sorry for the late reply. code --status output:
To be honest, I'm not quite sure what you mean by your question about symlinks or how I can find out. Yes, this issue seems to have started just recently without making any noticeable changes such as updating SDKs, installing extensions, etc. Here are further screenshots, I hope this is the server timing page you meant. If you have any recommendations what I can try to fix this issue, I'm happy to try that. As mentioned, I have already tried uninstalling Flutter/Dart, VSCode, etc. at the moment I don't know what else I could try. |
For us updating |
@JonasJW thanks - the page I meant was the one marked "Timing" on the left. Can you also confirm whether you're using any analyzer plugins? A few comments above suggest You should be able to check for symlinks by running |
@DanTup thanks for the clarification! I don't use When I run
Is that anything out of the ordinary? Here the screenshots of the "Timing" page: |
That one doesn't look like a problem, but are there any that point back up the tree (eg. creating cycles or including other large parts of the disk in the the path)? It may be useful to enable the analyzer instrumentation log (this file can get very large - be sure to turn it off afterwards) and reproduce the issue, and see if there is anything in the log file that looks out of place while this happens (for example exceptions, or paths you would not expect to be analyzed with this project open being analyzed). You mentioned this only happens on large projects - are any of them public projects that I could test with (or that sharing logs from would not include anything sensitive)? |
Hi @DanTup, I apologize for taking so long to respond. I still have this issue and it's really slowing down my development process.
Here are a few symlinks, some point up but it doesn't appear to me that they would create a cycle
In total there are over 550 symlinks. Does any of this sound problematic? I also tried the analyzer instrumentation logs but I can't really find anything that appears out of place. However, this document seems to log all kinds of stuff and I'm not sure how to analyze it or what to look for. Yes, unfortunately, this project is private and can't be shared. I could probably share the analyzer instrumentation logs privately with you, if that would help. I recently tested this project on a windows laptop and the issue occurs as well. (Thus, I think completely reinstalling my mac won't even help fix it). These issues don't appear on new Flutter projects. Maybe I could try to download a big public project and see if I have problems with other bigger projects as well? If not it must be something specific with my project but I'm clueless about where the issue could be. |
Nothing above looks like an issue to me - the issue would be if the link points further up the tree so that walking the tree could cause endless cycles.
The most useful thing would be knowing what's being logged during the periods where performance is bad. So if the bad performance is during startup, it would be the start of the logs (until the first
I can't accept anything confidential (instrumentation logs can contain contents of opened files and paths/errors for other files in the workspace), but if you're able to reproduce this on a copy of the project with anything confidential removed (and perhaps only a single test file open), you might be able to get a log that doesn't contain anything confidential you can share. Something I forgot to ask earlier - can you confirm whether you have this option ticked in the VS Code (User or Workspace) settings? |
Understood, I will go back to the logs and look for these progress events. If I have something to share I will follow up on it here. The |
FWIW, my recommendation would be to not use that setting (and I should update the text). Although it sounds better for large projects, it was really added for a fairly specific case (command line editors that would provide the current working directory - which may be the user home dir - as the workspace folder). While the server will start up faster for very large workspaces, opening and closing files from different projects will trigger re-creating the analysis roots which can trigger "initial" analysis for those projects. It's beneficial if you're opening a folder that contains 100 projects and maybe only opening files from a handful, but if you're jumping between a large portion of the projects in the workspace, it's probably worse overall. |
@JonasJW what is your current experience with analysis performance? Are you still experiencing this weird behavior? |
@mraleph yes, I'm still experiencing performance issues |
@JonasJW are you able to reproduce this issue with any public projects? It might be easier to narrow down with an instrumentation log, but that log will contain parts of source code from the open projects. If it only occurs with this one specific internal project, is it possible to make a copy of it and see if you can narrow down what causes it (for example if it's made up of many packages, can you remove some of them to narrow down if it's caused by a specific package/set of packages)? Do you also know if this issue occurs when typing in any file, or just some subset? This issue could be similar to #56307 which may be caused by the number of files that need to be reanalyzed as you modify a file (see #56307 (comment) and #56307 (comment)). |
Maybe a related issue |
It's the same to me. Dart is slow in VSCode, but when I switch to IntelliJ, it works fine. |
What is the solution at last? Turning off real time protection didn't solve anything for me. |
@BenevidesLecontes is it possible for you to try analyzer from dev channel to see if it improves memory usage? |
@mraleph I tried with the dev version and with latest pub version this is the result I think is worth to mentioning that we use flutter_lints package. Soon I change something on a shared package, the usage grows |
@BenevidesLecontes could you stay with dev channel for a bit and see if memory usage grows out of hand? Then can you open Analysis Server Diagnostic page (Dart Analysis -> Gear menu, see screenshot) and there click |
@mraleph, when you mention “analyzer from dev channel”, are you suggesting that I need to download the Dart dev version? If that’s the case, I downloaded |
@BenevidesLecontes I meant to keep using whatever version you were using to get the last screenshot (where you wrote "I tried with the dev version and with latest pub version this is the result"). I assumed you used flutter dev channel to get this? Otherwise I am not sure what "dev" refers to in that comment. |
@mraleph here is the report |
Experiencing this issue on projects with
|
@BenevidesLecontes the uploaded report is from dart 3.6 not the dev build which includes some fixes. It seems from your comment about "the new feature workspaces" that you are using pub workspaces - but from the uploaded report you are not. |
@mcmah309 are you using macros? If you do - could you try without macros? I also notice that you don't use workspaces either - might be a good idea to adopt them because you also have huge number of contexts. |
FWIW, that flag can make performance worse as well as better. It was originally intended for command-line editors that might provide a large workspace directory when only ever actually editing a single file. While it will make initial analysis faster (because when there are no open files we don't analyze anything), it can cause extra work as you open/close files. The first file you open in a project will cause the analysis roots to change (which is relatively expensive) and then closing the last file in a project does the same. If you're jumping between files across a lot of projects (as opposed to working in a very small number of projects in a large workspace), it will probably work out worse - generally I recommend not using it. |
Hi @jensjoha I did all the steps to move to workspaces, I have only one |
With regards to the workspace feature, could it be that you have opened the folders separately instead of just opening the folder that contains the workspace? I'm not familiar with IntelliJ, so I don't know what the correct names are there, but in VSCode, if I without the workspace feature opened the main folder (with, for my test case "project1" and "project2" folders inside it) I got 3 contexts: The main folder, project1 and project2. With the workspace feature enabled, opening the main folder gives me just 1 context, whereas opening the projects individually (i.e. a VSCode 'workspace' with two folders (project1 and project2)) I get 2 contexts. If that's the case, could you try to just open that (in lack of better words) "main folder"? As for the crashing, is it that it just doesn't launch? Again I'm not familiar with the IntelliJ UI, but I would assume you'd need a full path to the SDK (say something like |
@jensjoha I have the full path, I only I hid it to post here. About the workspace, I have this structure, I open the main folder containing all the packages, apps and so on. |
@BenevidesLecontes can you check if you have any $ cd path-to-app_3.0
$ find . -iname '.dart_tool'
...
$ find . -iname 'pubspec.yaml' -exec grep -L 'resolution:.*workspace' '{}' ';' Both |
@mraleph I removed all These commands: |
@BenevidesLecontes this looks correct. It is puzzling that you get so many contexts then. Could you open Analyzer Diagnostics page and see what it says about those contexts, e.g. when I create a test workspace I get 1 context with multiple packages inside: Can you look through contexts that you have? Is workspace recognized correctly (e.g. you should have at least one context listing all your packages)? If it is recognized correctly - try to look what other contexts do you have. |
@mraleph I blurred some paths but this is what i have. I have |
@BenevidesLecontes this seems just one of the context, and it only has 7 packages inside. How do other contexts look like? I think |
@mraleph removed the |
@BenevidesLecontes do you have any analysis server plugins enabled?
When that work was done, it could break plugins because plugins would no longer get the context roots they expected. To fix this, roots are still created for any folder where an If plugins are enabled, it would be useful to try removing them from all |
@DanTup I have this in my analysis_options.yaml
|
Lately, working with Flutter has been really tough and frustrating. Most of the time, the Dart analyzer freezes after a hot restart, and I can’t do anything. Code completion becomes extremely slow, and undefined errors occur frequently. I even reinstalled macOS to resolve this issue, but the situation remains the same. We need to find a solution to this problem because it’s almost impossible to work like this right now. Click to see the log``` #0 ElementImpl2.enclosingElement2 (package:analyzer/src/dart/element/element.dart:3106:38) #1 _ReferenceFinder.visitAssignmentExpression (package:analysis_server/src/services/correction/dart/import_add_show.dart:71:51) #2 AssignmentExpressionImpl.accept (package:analyzer/src/dart/ast/ast.dart:954:15) #3 ExpressionStatementImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:6366:17) #4 RecursiveAstVisitor.visitExpressionStatement (package:analyzer/dart/ast/visitor.dart:1099:10) #5 ExpressionStatementImpl.accept (package:analyzer/src/dart/ast/ast.dart:6362:50) #6 NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:13009:20) #7 BlockImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:2051:17) #8 RecursiveAstVisitor.visitBlock (package:analyzer/dart/ast/visitor.dart:883:10) #9 BlockImpl.accept (package:analyzer/src/dart/ast/ast.dart:2047:50) #10 IfStatementImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:9730:20) #11 RecursiveAstVisitor.visitIfStatement (package:analyzer/dart/ast/visitor.dart:1273:10) #12 IfStatementImpl.accept (package:analyzer/src/dart/ast/ast.dart:9724:50) #13 NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:13009:20) #14 BlockImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:2051:17) #15 RecursiveAstVisitor.visitBlock (package:analyzer/dart/ast/visitor.dart:883:10) #16 BlockImpl.accept (package:analyzer/src/dart/ast/ast.dart:2047:50) #17 BlockFunctionBodyImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:2007:12) #18 RecursiveAstVisitor.visitBlockFunctionBody (package:analyzer/dart/ast/visitor.dart:889:10) #19 BlockFunctionBodyImpl.accept (package:analyzer/src/dart/ast/ast.dart:1999:50) #20 FunctionExpressionImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:8624:11) #21 RecursiveAstVisitor.visitFunctionExpression (package:analyzer/dart/ast/visitor.dart:1213:10) #22 FunctionExpressionImpl.accept (package:analyzer/src/dart/ast/ast.dart:8613:50) #23 NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:13009:20) #24 ArgumentListImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:476:16) #25 RecursiveAstVisitor.visitArgumentList (package:analyzer/dart/ast/visitor.dart:823:10) #26 ArgumentListImpl.accept (package:analyzer/src/dart/ast/ast.dart:472:50) #27 InstanceCreationExpressionImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:10518:19) #28 RecursiveAstVisitor.visitInstanceCreationExpression (package:analyzer/dart/ast/visitor.dart:1309:10) #29 InstanceCreationExpressionImpl.accept (package:analyzer/src/dart/ast/ast.dart:10507:15) #30 VariableDeclarationImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:18577:19) #31 RecursiveAstVisitor.visitVariableDeclaration (package:analyzer/dart/ast/visitor.dart:1806:10) #32 VariableDeclarationImpl.accept (package:analyzer/src/dart/ast/ast.dart:18572:50) #33 NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:13009:20) #34 VariableDeclarationListImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:18701:16) #35 RecursiveAstVisitor.visitVariableDeclarationList (package:analyzer/dart/ast/visitor.dart:1812:10) #36 VariableDeclarationListImpl.accept (package:analyzer/src/dart/ast/ast.dart:18695:15) #37 FieldDeclarationImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:7042:16) #38 RecursiveAstVisitor.visitFieldDeclaration (package:analyzer/dart/ast/visitor.dart:1135:10) #39 FieldDeclarationImpl.accept (package:analyzer/src/dart/ast/ast.dart:7037:50) #40 NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:13009:20) #41 ClassDeclarationImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:2939:13) #42 RecursiveAstVisitor.visitClassDeclaration (package:analyzer/dart/ast/visitor.dart:937:10) #43 ClassDeclarationImpl.accept (package:analyzer/src/dart/ast/ast.dart:2929:50) #44 NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:13009:20) #45 CompilationUnitImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:3621:21) #46 RecursiveAstVisitor.visitCompilationUnit (package:analyzer/dart/ast/visitor.dart:961:10) #47 CompilationUnitImpl.accept (package:analyzer/src/dart/ast/ast.dart:3614:50) #48 ImportAddShow.compute (package:analysis_server/src/services/correction/dart/import_add_show.dart:48:10) #49 AssistProcessor._addFromProducers.compute (package:analysis_server/src/services/correction/assist_internal.dart:207:24) #50 AssistProcessor._addFromProducers (package:analysis_server/src/services/correction/assist_internal.dart:228:15) #51 AssistProcessor.compute (package:analysis_server/src/services/correction/assist_internal.dart:181:5) #52 DartCodeActionsProducer.getAssistActions (package:analysis_server/src/lsp/handlers/code_actions/dart.dart:133:21) #53 OperationPerformanceImpl.runAsync (package:analyzer/src/util/performance/operation_performance.dart:174:14) #54 CodeActionHandler.handle.. (package:analysis_server/src/lsp/handlers/handler_code_actions.dart:235:20) #55 ErrorOrRecord2Extension.mapResults (package:analysis_server/src/lsp/error_or.dart:125:12) #56 ErrorOr.mapResult (package:analysis_server/src/lsp/error_or.dart:94:11) #57 ServerStateMessageHandler.handleMessage (package:analysis_server/src/lsp/handlers/handlers.dart:452:11) #58 LspAnalysisServer._handleRequestMessage (package:analysis_server/src/lsp/lsp_analysis_server.dart:1068:18) #59 LspAnalysisServer.handleMessage.. (package:analysis_server/src/lsp/lsp_analysis_server.dart:509:15) #60 OperationPerformanceImpl.runAsync (package:analyzer/src/util/performance/operation_performance.dart:174:14) #61 LspAnalysisServer.handleMessage. (package:analysis_server/src/lsp/lsp_analysis_server.dart:491:11)
|
In my tests conducted on the beta channel and a new Flutter project, the app randomly freezes during a hot restart. After a long period, the error below occurs, and the restart process completes. This issue happens randomly—sometimes there’s no problem even after several restarts, while other times it happens on the first attempt.
[+4206 ms] Skipping target: gen_localizations
[ ] Skipping target: gen_dart_plugin_registrant
[ ] Skipping target: _composite
[ ] complete
[ +3 ms] Scanned through 644 files in 2ms
[ ] <- reset
[ ] Compiling dart to kernel with 0 updated files
[ ] Processing bundle.
[ ] <- recompile package:flutter_analyzer/main.dart c9a01cee-4e05-4db5-8f4c-d2c2778fe0f9
[ ] <- c9a01cee-4e05-4db5-8f4c-d2c2778fe0f9
[ +1 ms] Bundle processing done.
[ +36 ms] Updating files.
[ ] Pending asset builds completed. Writing dirty entries.
[+60373 ms] Error writing "main.dart.dill" to DevFS: HttpException: Request has been aborted
[ ] trying again in a few - 9 more attempts left
[ +993 ms] DevFS: Sync finished
[ ] Synced 53.6MB.
[ ] <- accept |
@hasimyerlikaya it sounds like your problems are related to running several processes at once. Or at least, we can't tell if there is one culprit, from your description. Can you confirm that you are having a problem with the Dart Analyzer, meaning things like your IDE's Problems panel is slow to refresh, code completion is slow (which you do show in your screenshot), syntax highlight gets stale, things like that? What is your IDE? It sounds like you might be running your app alongside your IDE in a simulator or an emulator. Can you confirm that? What if you code for a long session in your IDE without running the simulator or emulator? Does the Dart Analyzer perform better then?
This is not a problem with the Dart Analyzer. Please open a new issue if you wish to report a bug with the Dart VM or with hot restart. |
@srawlins Apologies for the incomplete information. I should have provided a more detailed explanation. Development Environment: Issues Encountered After Flutter 3.27 Update:1. Hot Restart Issue: 2. Slow Code Completion: Next Steps: Let me know if you need further details! |
Dart & Flutter has suddenly become unusable slow in VSCode. Intellisense won't load within 30+ seconds, syntax highlighting won't update, jumping to code definitions loads infinitely, etc.
This seems to be especially the case on bigger projects, on a newly created project it works fine. I tried switching to Android Studio which seems to behave similarly (maybe a little better).
I tried uninstalling all extensions, even completely removing VSCode with any data stored and reinstalling it. As soon as I install the Dart extension, it is unusable. I also tried setting the following settings:
I'm on macOS 14.4, VSCode Version 1.87.2 (Universal),
In the Activity Monitor, there is the
dart:analysis_server.dart.snapshot
process running with around 1 GB of used memory. I'm not sure if this is normal.Here is a screenshot from the Dart Analyzer (which I'm also having trouble opening)
dart info
output:General info
Project info
Process info
Any recommendations on how I could possible fix this would be very welcome!
The text was updated successfully, but these errors were encountered: