-
Notifications
You must be signed in to change notification settings - Fork 327
Autocomplete is slow #3255
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
Comments
Thanks for the feedback. @scheglov: what details would be useful for us to quantify the performance @feinstein is experiencing? |
|
|
|
Sorry, I didn't understand.
|
We can try to log analysis activity in Analysis Server.
|
Ok, will do, thanks! |
I have to clean out these files every day or else im waiting literally 10 seconds for autocomplete to even show up. Idea locks up. I've have tons of disposable cores to do this work on, and plenty of memory to store all of those files on a ramdisk, why is this still a problem? |
I have Core i9 with 16 CPU and 32 Gb RAM. After every 2-3 hot reloads, I get this picture for 3-4 seconds. In any project. Both in big ones and in hello world. The problem appeared a couple of months ago. It seems sometimes after a hot reload the analyzer starts re-analyzing all files in a project.
|
I remember reading somebody stating that this was Windows only problem, but that claim should be verified. Happens to me and my friend, and we are both running Windows 10. At first I thought that this was a problem with my 25k lines project with many dependencies, but I was bummed to find out that the same exact thing happens in a fresh project. @AleksMx What operating system are you using? |
@scheglov, @bwilkerson: FYI and should we transfer this to the SDK repo? |
Three of us working on windows 11 (IntellIj IDEA Ultimate) have the same problem. A tried the above mentiond solutions (cache and dartServer folder removing) but didn't work. Also the context menu for the widget tree manipulations is dead for seconds a lot. |
Small update: in my case I found that pressing CTRL + ALT + L fixes the issue once. So every time I have issues with context menus or syntax highlighting I bash those keys and it works again. To provide to the investigation: I am on windows 10. |
This shortcut is for auto formatting, that's not something I would want to do all the time. I face this issue on a regular basis with all my computers, personal or work laptop, both with windows 10 |
I also experience this in Android Studio, Intel i9 12900 with 32GB of RAM. Really affects productivity. How can we help resolve this issue? |
This is terrible. A significant number of developers experience difficulties at work. And we have a reduced priority of solving the problem |
My error appears as follows. When I connect an Android smartphone via USB and run an application on it in debug mode. That is, during the saving of changes in the code, a hot reload occurs. At this point, sometimes this bug occurs, which blocks the work for 5 seconds. This is very annoying! I ran the following command: It can be seen from it that after saving there are no delays from the work of the dart server. The problem is somehow connected with hot reload. Change is happening quickly, but something is blocking the work. Let's think about how to catch the error. Otherwise, what are we all here for? |
/fyi @jwren @kenzieschmoll |
This is happening to me as well and has made code-complete almost unusable. What I have to do now is hit the "Alt" and then wait for 2-5 seconds, until the lightbulb shows up, then I can hit "Enter" to bring up code complete. |
Fyi @srawlins |
+1 for usability issues. A lot of our orgs developers experience very slow autocomplete with Flutter in our large codebase (70k+ LOC) |
I would love that the language server could be optimized to give intellij all it needs to bring all the tools Java have to Dart. All the times that I asked for something that exists for Java, to be ported for dart, the guys at intellij says they can't because the language server doesn't provide them with the information, os something similar. |
It really sucks cause I almost am being forced to switch to VSCode, even though I prefer Android Studio in a wide number of ways, ever since upgrading a few months ago everything just went to shit, and at least VSCode is fast. It does feel like VSCode gets a lot more attention because that is what the core Flutter team uses. I doubt this would still be an issue if any members of the Flutter team actually used AS on a regular basis as it really kills the programming flow. Maybe I will try some older versions and see if we can at least pin-point when everything went south. It does seem to be related to trying to do code-assist, while an existing error is present in the code, but haven't been able to narrow down and specific reproduction steps. |
I also have this behavior all the time, for years now. @srawlins I understand your points and think it's very valid. But at the same time it's what you said, if we improve the root (language server and analyze) it probably will fix all the rest. |
I wonder if this is caused by https://github.com/dart-lang/sdk/blob/27d417dc0937bb1a8f1ae6d12754a95adf488364/pkg/analysis_server/lib/src/legacy_analysis_server.dart#L348 See also the comment above that describes why we decided to implement it. But if it causes issues for many external users, we might want to avoid it. Or it could be unrelated... |
Thanks @esDotDev!
To confirm: you don't see the same issues with VSCode on the same code base? |
I'm not aware of any documentation, but from IntelliJ and Android Studio, open the Dart Analysis view, click on the gear icon, and select "View analyzer diagnostics".
10 seconds is a long time. It might be worth adding a flag to disable it so that users can try turning it off and let us know whether it helps. |
This is really helpful. Thank you! |
nw! If it's helpful, you can view this codebase in question here: https://github.com/gskinnerTeam/flutter-wonderous-app but from my experience, it's any codebase of any size |
Much appreciated @esDotDev! Does wonderous development get unusably slow (that is beyond the 2s lag in the video above)? I've got that reproduced locally but haven't seen anything worse after some casual edits. Does running the app and triggering reloads have any effect? (I haven't successfully run ios or android just yet myself but will try and debug tomorrow.) |
This is all super useful. Thanks! Do you happen to have any plugins installed that might kick things off on a save (for example https://plugins.jetbrains.com/plugin/13666-flutter-intl)? Do you have any save actions setup? |
@esDotDev: I'd be interested to see the communication between our language server and the IDE. There could be some clues there. If you wouldn't mind enabling logging and sending what you capture when see this lag, that'd be great. (Do note that this file will include full paths so you'll want to scan it to make sure there's nothing sensitive.) This post explains how to turn on instrumentation in IntelliJ: |
This is a long session, but right before I saved it, I lost code analysis on a file for 5 seconds+, I was just moving my cursor around and all of a sudden highlighting broke (maybe this was some background task finishing from a recent save?). I inserted a new line, and that seemed to prompt code formatting to pop back in properly: |
Captured some pretty good footage here, and some repro steps maybe? All I do here:
Going back and forth you can see it happen often, near the end, from 0:22 - 0:33 the project on the right is exhibiting the issue: dPTBdYEzMA.mp4Here's another much smaller log where it happened twice within a couple minutes of re-starting android studio. |
Yes, there are several problems described here, but the root is the same. Race condition on the IDE side, which leads to blocking - syntax highlighting or autocomplete (it doesn't matter). This is not a dartServer issue. |
This is very similar to the source of the problem. There is a feeling that sometimes saving a file leads to blocking of some process. But as I showed above, the work of dartServer is already done by this time. |
|
Thanks for the details. I am trying to reproduce, without success so far, so I have more questions :)
I've re-read the comments above (but its hard to get a cohesive stream), and I can't quite connect the proof that this is a problem in IntelliJ (or Android Studio?) or the Flutter plugin for IntelliJ. I think you've shown that the delays are tied to hot reload, but I'm not sure that this is a requirement in other commenter's reproduction cases. (But again, people are reporting many issues here.) For example in the initial (4-year-old) summary above, @feinstein does not mention hot reload. If you have good reproductions that are tied to hot reload, I recommend opening a new issue with reproduction steps. One common thread in some comments above does seem to tie the slowness at least to saving a file, which could trigger hot reload, certainly. But the issue could be tied to something else which is part of the saving process, like maybe "format on save", or a file watch event that comes into Dart Analysis Server as part of a save... |
When I first started this thread only the auto-complete was slow, but after all these years I am also seeing the hot reload issue, where the text colors get weird. @srawlins if you want we can jump into a Google Meet call and I can show you. |
Hi from JetBrains. We now know that the weird highlighting after save is related to CRLF line endings. Note that this is not connected with slow completion or whatever else discussed here. It's a separate isolated bug. I haven’t managed to reproduce it so far so I can't say for sure where the bug is. Let's track it in the Dart plugin issue tracker: https://youtrack.jetbrains.com/issue/WEB-56916. The workaround is to switch to LF line endings. The widget in the IDE status bar allows to do it easily per file (any OS). IDE also allows to change line separators for a specific folder of for the whole project (Find Action -> Line Separators). So now there's one less problem to track within this issue. |
Great! So now we can focus on performance? |
I have a good news! By advice @alexander-doroshko I changed line separators from CRLF to LF. Just chose an option in the bottom menu. Previously, after 4-5 hot reloads, syntax highlighting and autocomplete was blocked: Now everything works as it should: This explains why the issue only affects Windows users. |
I switched to LF yesterday across the entire project, and it seems to be running fast again. Will update if the issue re-appears. |
I confirm its works on my side too |
Worked for me. My team and I are suffering with this problem years. Following the instructions, I switched from CRLF to LF and it worked successfully. It appears that CRLF might cause performance problems with Dart. How to convert your project1 - Go to IntelliJ settings. File > Settings > Code Style.
5 - Commit this file.
7 - Click on the folders/files you want to convert. With them selected, click on File > File Properties > Line Separators > LF - Unix and macOS (\n). Done, the selected files/folders will be converted and new files will be create using LF. |
Thanks for this, while changing line ending fixes the issue, there is no way in the IDE to set the default for new files, so it was really annoying having to set this by hand in each project. Will give this a shot! |
after upgrading to latest version of flutter (v3.29.3) my android studio is too laggy. auto complete and syntax highlighting does not work properly. note that with previous version of flutter (v3.24.0) everything was ok. |
That sounds like it might be this issue: dart-lang/sdk#60335. |
Uh oh!
There was an error while loading. Please reload this page.
When I type any code in IntelliJ IDEA, it becomes marked with red squiggly lines, then some 2 seconds later it will generate some autocomplete options, it gets kinda annoying.
I understand the Dart support was made with a Dart Analysis Server, so at each new key I press, there will be some sort of client-server communication.
I also understand why this architecture was chosen, it's the best way to make something quickly and for every platform out there.
But maybe we should start thinking how to move forward from this so the performance and tweaking for IntelliJ could be improved.
Maybe the Dart Analysis Server could be embedded into the Dart plug-in, bypassing the client-server communications? I am not familiar with the whole architecture, just trying to figure out how to improve performance.
The text was updated successfully, but these errors were encountered: