Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Potential analyzer regression in 3.7 / Flutter 3.29 release #60335

Open
mraleph opened this issue Mar 17, 2025 · 35 comments
Open

Potential analyzer regression in 3.7 / Flutter 3.29 release #60335

mraleph opened this issue Mar 17, 2025 · 35 comments
Assignees
Labels
area-dart-model For issues related to conformance to the language spec in the parser, compilers or the CLI analyzer. model-performance Performance/memory issues in analyzer/cfe P1 A high priority bug; for example, a single project is unusable or has many test failures type-performance Issue relates to performance or code size

Comments

@mraleph
Copy link
Member

mraleph commented Mar 17, 2025

We have reports about potential regression in Flutter 3.29 / Dart 3.7 release which causes long analysis times.

If you are experiencing those please follow the instructions provided here to collect some information and post it here.

It would be especially helpful if you also collect a similar report using the previous version of Flutter / Dart which did not exhibit performance issues.

@a-siva a-siva added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Mar 18, 2025
@pq pq added type-performance Issue relates to performance or code size P1 A high priority bug; for example, a single project is unusable or has many test failures labels Mar 18, 2025
@johnniwinther johnniwinther added model-performance Performance/memory issues in analyzer/cfe area-dart-model For issues related to conformance to the language spec in the parser, compilers or the CLI analyzer. and removed area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. labels Mar 19, 2025
@VivienStreit
Copy link

VivienStreit commented Mar 19, 2025

With performance issues (Flutter 3.29.1, Dart 3.7.0)

[√] Flutter (Channel stable, 3.29.1, on Microsoft Windows [Version 10.0.22631.5039], locale en-CH)
[√] Windows Version (11 Pro 64-bit, 23H2, 2009)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Build Tools 2022 17.5.1)
[√] Android Studio (version 2024.1)
[√] VS Code (version 1.98.2)
[√] Connected device (3 available)
[√] Network resources

Initial Analysis Driver Timings

(name: <scheduler>, count: 0, elapsed: 0:00:00.000000, elapsedSelf: -0:00:12.965628)
  (name: analyzeFile, count: 403, elapsed: 0:00:12.963896, elapsedSelf: 0:00:12.915702)
    (name: libraryContext, count: 403, elapsed: 0:00:00.048194, elapsedSelf: 0:00:00.044308)
      (name: libraryCycle, count: 403, elapsed: 0:00:00.003886, elapsedSelf: 0:00:00.003886)
  (name: getUnitElement, count: 1, elapsed: 0:00:00.001732, elapsedSelf: 0:00:00.001438)
    (name: libraryContext, count: 1, elapsed: 0:00:00.000294, elapsedSelf: 0:00:00.000291)
      (name: libraryCycle, count: 1, elapsed: 0:00:00.000003, elapsedSelf: 0:00:00.000003)

Action in IDE

Multiple cycles of the following steps (in Android Studio):

  1. Addition of redundant line breaks
  2. File save (with format on save option enabled)

Some formatting operations are almost instantaneous (i.e. line break removed), but most of them just never happen...

Please, note that this is just an example of the slowness that is happening; most of the Dart tool chain seems to be very slow (like code highlighting, auto completion, auto import, etc..)

Analysis Driver Timings

(name: <scheduler>, count: 0, elapsed: 0:00:00.000000, elapsedSelf: -0:00:04.232686)
  (name: getUnitElement, count: 54, elapsed: 0:00:00.005762, elapsedSelf: 0:00:00.002318)
    (name: libraryContext, count: 54, elapsed: 0:00:00.003444, elapsedSelf: 0:00:00.003316)
      (name: libraryCycle, count: 54, elapsed: 0:00:00.000128, elapsedSelf: 0:00:00.000128)
  (name: analyzeFile, count: 51, elapsed: 0:00:04.226924, elapsedSelf: 0:00:03.820578)
    (name: libraryContext, count: 51, elapsed: 0:00:00.406346, elapsedSelf: 0:00:00.353137)(bytesGet: 7311003, cycleCount: 51, libraryCount: 1020, libraryLoadCount: 1020)
      (name: libraryCycle, count: 51, elapsed: 0:00:00.053209, elapsedSelf: 0:00:00.053209)

Report

dart_analyzer_diagnostics_report.json


Without perf issue (Flutter 3.27.2, Dart 3.6.1)

[!] Flutter (Channel [user-branch], 3.27.2, on Microsoft Windows [Version 10.0.22631.5039], locale en-CH)
    ! Flutter version 3.27.2 on channel [user-branch] at C:\src\flutter
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/setup.
    ! Upstream repository unknown source is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error.
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Build Tools 2022 17.5.1)
[√] Android Studio (version 2024.1)
[√] VS Code (version 1.98.2)
[√] Connected device (3 available)
[√] Network resources

Initial Analysis Driver Timings

(name: <scheduler>, count: 0, elapsed: 0:00:00.000000, elapsedSelf: -0:01:20.370275)
  (name: analyzeFile, count: 1, elapsed: 0:01:20.370275, elapsedSelf: 0:00:00.556503)
    (name: libraryContext, count: 1, elapsed: 0:01:19.813772, elapsedSelf: 0:00:09.978011)(bytesGet: 12089412, cycleCount: 973, libraryCount: 1603, libraryLoadCount: 1603)
      (name: libraryCycle, count: 1, elapsed: 0:01:09.835761, elapsedSelf: 0:00:01.189510)
        (name: fileState.refresh, count: 1766, elapsed: 0:01:08.646251, elapsedSelf: 0:00:32.796800)
          (name: getUnlinkedUnit, count: 1766, elapsed: 0:00:35.849451, elapsedSelf: 0:00:35.849451)

Action in IDE

Multiple cycles of the following steps (in Android Studio):

  1. Addition of redundant line breaks
  2. File save (with format on save option enabled)

Auto formatting almost instantaneous

Analysis Driver Timings

(name: <scheduler>, count: 0, elapsed: 0:00:00.000000, elapsedSelf: -0:00:02.672191)
  (name: analyzeFile, count: 25, elapsed: 0:00:02.672191, elapsedSelf: 0:00:02.628278)
    (name: libraryContext, count: 25, elapsed: 0:00:00.043913, elapsedSelf: 0:00:00.020618)(bytesGet: 3081425, cycleCount: 25, libraryCount: 500, libraryLoadCount: 500)
      (name: libraryCycle, count: 25, elapsed: 0:00:00.023295, elapsedSelf: 0:00:00.023295)

Report

dart_analyzer_diagnostics_report.json


PS: With Flutter 3.29.1 and Dart 3.7.0, I occasionally encounter situations where the Dart Analyzer Diagnostics won't open, while syntax highlighting and formatting in the IDE become completely unresponsive. Hope this additional information might be helpful.

@mraleph
Copy link
Member Author

mraleph commented Mar 20, 2025

cc @jensjoha

@VivienStreit
Copy link

Hello @mraleph,

I wanted to check if my previous report was helpful. Please let me know if there's anything else I can do to assist!

@sgrekhov
Copy link
Contributor

sgrekhov commented Mar 27, 2025

Hope this helps. I ran into the same issue and fixed it by removing the analysis_options.yaml file (with the content below) from one of the folders in my project — specifically, from the https://github.com/dart-lang/co19/tree/master/LanguageFeatures/Augmentation-libraries.

analyzer:
  enable-experiment:
    - augmentations
    - macros

As far as I remember, these experimental flags were introduced shortly before Dart 3.7.0. Do other people experiencing this issue have analysis_options.yaml files with any experimental flags in their projects?

Dart SDK version: 3.8.0-205.0.dev (dev) (Tue Mar 18 21:02:26 2025 -0700) on "windows_x64"

IntelliJ IDEA 2024.1.4 (Community Edition)
Build #IC-241.18034.62, built on June 20, 2024
Runtime version: 17.0.11+1-b1207.24 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 11.0
GC: G1 Young Generation, G1 Old Generation
Memory: 4020M
Cores: 6
Non-Bundled Plugins:
  Dart (241.17890.8)
  com.intellij.ml.llm (241.18034.12)
Kotlin: 241.18034.62-IJ

@pq
Copy link
Member

pq commented Mar 31, 2025

@sgrekhov: did you have any plugins specified in your removed analysis options?

@sgrekhov
Copy link
Contributor

sgrekhov commented Apr 1, 2025

@sgrekhov: did you have any plugins specified in your removed analysis options?

No. Experimental flags only.

@mraleph
Copy link
Member Author

mraleph commented Apr 1, 2025

@VivienStreit we (or more specifically @jensjoha) might have identified one possible source of the regression in 3.7, @pq has made a patch to try undo the offending change. If I produce a custom 3.7 SDK build for you would you be willing to test it out to see if it solves the problem for you? If yes - please let me know what platform to build SDK for.

@mraleph
Copy link
Member Author

mraleph commented Apr 1, 2025

Here are the instructions to test:

Mac OS X (Apple Silicon)

SDK archive

  1. Close all IDEs. Make sure that no dart processes are running (check ps ax | grep dart and kill everything kill -9 $(ps ax | grep dart | awk '{print $1}'))

  2. Switch flutter to stable channel.

  3. Run flutter doctor and make sure that Flutter is at 3.29.2

  4. Go to the bin folder in Flutter SDK (e.g. by doing cd $(dirname $(which flutter))) and execute the following commands:

    $ cd bin/cache
    $ rm -rf dart-sdk
    $ curl -O https://storage.googleapis.com/vegorov-artifacts/dart-sdk-with-cl-419340-mac-arm64.zip
    $ unzip dart-sdk-with-cl-419340-mac-arm64.zip
  5. Start IDE, open your Flutter project and make sure that it is using dart binary from the Flutter SDK which we just updated. You can check ps ax | grep dart which should show dart binaries running from Flutter SDK.

The Dart SDK is unsigned so you might hit some hiccups with Mac OS X security policies. You should be able to work around that by adding your IDE to Security > Developer Tools list system settings.

Windows (X64)

SDK archive

Note

Instructions below use PowerShell commands.

  1. Close all IDEs. Make sure that no dart processes are running. (e.g. Get-Process dart should not find anything)

  2. Switch flutter to stable channel.

  3. Run flutter doctor and make sure that Flutter is at 3.29.2

  4. Go to the bin folder in Flutter SDK (e.g. by doing Set-Location -Path (Split-Path -Path (Get-Command flutter).Path -Parent)) and execute the following commands:

    Remove-Item -Force -Recurse dart-sdk
    $ProgressPreference = 'SilentlyContinue'
    Invoke-WebRequest -Uri "https://storage.googleapis.com/vegorov-artifacts/dart-sdk-with-cl-419340-win-x64.zip" -Method "GET"  -Outfile dart-sdk.zip
    Expand-Archive dart-sdk.zip .
    Remove-Item dart-sdk.zip

    Warning: without $ProgressPreference = 'SilentlyContinue' download will be extremely slow!

  5. Start IDE, open your Flutter project and make sure that it is using dart.exe binary from the Flutter SDK which we just updated. You can check Get-Process dart | Format-List Path which should show dart.exe binaries running from Flutter SDK.

Linux (X64)

SDK archive

  1. Close all IDEs. Make sure that no dart processes are running (check ps ax | grep dart and kill everything kill -9 $(ps ax | grep dart | awk '{print $1}'))

  2. Switch flutter to stable channel.

  3. Run flutter doctor and make sure that Flutter is at 3.29.2

  4. Go to the bin folder in Flutter SDK (e.g. by doing cd $(dirname $(which flutter))) and execute the following commands:

    $ cd bin/cache
    $ rm -rf dart-sdk
    $ curl -O https://storage.googleapis.com/vegorov-artifacts/dart-sdk-with-cl-419340-linux-x64.zip
    $ unzip dart-sdk-with-cl-419340-linux-x64.zip
  5. Start IDE, open your Flutter project and make sure that it is using dart binary from the Flutter SDK which we just updated. You can check ps ax | grep dart which should show dart binaries running from Flutter SDK.

@petrnymsa
Copy link

@VivienStreit we (or more specifically @jensjoha) might have identified one possible source of the regression in 3.7, @pq has made a patch to try undo the offending change. If I produce a custom 3.7 SDK build for you would you be willing to test it out to see if it solves the problem for you? If yes - please let me know what platform to build SDK for.

I am interested.

Mac OS Apple Sillicon and Windows 11 Machine too.

@mraleph
Copy link
Member Author

mraleph commented Apr 1, 2025

@petrnymsa see instructions in this comment: #60335 (comment) I have now produced both versions of the SDK

@sgrekhov
Copy link
Contributor

sgrekhov commented Apr 1, 2025

I just tried the updated SDK on Windows. I believe I have a good project for testing development tools (23,000+ files, thousands of which have intentional compile-time errors). I didn't follow the instructions above, but simply downloaded the SDK and replaced my own. There was an analyzer server crash on https://github.com/dart-lang/co19/blob/master/LanguageFeatures/Augmentation-libraries/augmenting_members_A04_t05_lib.dart. Yes, this is an experimental feature, but the analyzer server shouldn't crash anyway.

Failure report issue-1.md.

@bwilkerson
Copy link
Member

@scheglov For the crash report.

@pq
Copy link
Member

pq commented Apr 1, 2025

Experimental flags only.

Thanks, @sgrekhov! This is really interesting.

FYI + @stereotype441, @johnniwinther for context around possible augmentation library performance issues

@luis901101
Copy link

I have tested the dart-sdk with the fix today (Mac OS Silicon, with Android Studio) in a project with over 1K files and it has worked as expected, syntax highlighting, formatting, auto completion, auto imports all very good. I will continue testing with other projects.

@pq
Copy link
Member

pq commented Apr 1, 2025

Fantastic. That's encouraging. Thanks for the feedback @luis901101!

@mraleph
Copy link
Member Author

mraleph commented Apr 1, 2025

@luis901101 just to double check - you get a better experience (e.g. faster completion, etc) than you were getting with Flutter 3.29 / Dart 3.7?

@luis901101
Copy link

@luis901101 just to double check - you get a better experience (e.g. faster completion, etc) than you were getting with Flutter 3.29 / Dart 3.7?

Affirmative.
To be more clear: today I started working as usual using latest stable Flutter 3.29.2/3.7.2 and the analyzer was struggling with completions, hightlitting and all that we already know... then I got the notification about this fix and I immediately downloaded the dart-sdk, following the instructions above, I killed Android Studio, killall dart, removed my current dart-sdk and replaced with the new one with the fix... after that I resumed working in my project and it was really nice...

@mraleph
Copy link
Member Author

mraleph commented Apr 1, 2025

@luis901101 Thanks! That's very reassuring. Please keep us posted if you observe any issues.

@luis901101
Copy link

I hope others also to test the sdk fix and share their experiences... in my case it has been really weird because Android Studio had the issue but VSCode not (or at least not so hard as Android Studio)... but I have read that other users had issues with VSCode... nevertheless today after downloading the sdk Android Studio has been working great.

@nietsmmar
Copy link

Is it possible to test this SDK on linux?

@mraleph
Copy link
Member Author

mraleph commented Apr 2, 2025

@nietsmmar I have built an SDK version for Linux X64 and updated instructions above. (They are basically the same as for Mac OS X - just a different SDK download link).

@nietsmmar
Copy link

@mraleph I just tested it the last hour and it is definitely a lot faster again! :)

@diegotori
Copy link

@mraleph if the testing goes well, how long do you think it will be until we finally get an updated Dart/Flutter release with this change? So far (knock on wood), it looks like it's definitely working. Thanks in advance.

@mraleph
Copy link
Member Author

mraleph commented Apr 2, 2025

@diegotori right now it is targeting the next stable release. Given the severity we might consider CP into the current stable - I will inquire about the current schedule to see if that is feasible.

@diegotori
Copy link

@mraleph to be brutally honest, this definitely warrants a CP, mainly because it's affecting my day-to-day usage of Dart/Flutter and Android Studio. It takes forever for changes to propagate due to this issue. That and I don't think myself and the rest of my team can wait until I/O for that change to make it to stable.

Bottom line, since this is a Tier 1 issue affecting every developer, this definitely requires a new 3.29 patch release.

@mraleph
Copy link
Member Author

mraleph commented Apr 2, 2025

@diegotori I got a confirmation that CP window for current stable is still open, so it should be possible.

@pq could you prepare a CP for this? We probably need to let it cook a bit more (e.g. it should go through all rolls at the very least) - but after that happens we should be able to CP into the current stable.

@bwilkerson
Copy link
Member

bwilkerson commented Apr 2, 2025

We have an issue suggesting that that fix might have caused other problems: #60463. We'll look to see whether we can mitigate the crashes without regressing the performance.

Edit: fixed the link to the issue

@saropa
Copy link

saropa commented Apr 2, 2025

Speaking of our own productivity, the occasional crash would be preferred to the current sluggishness :)

@diegotori
Copy link

@mraleph any updates, since it feels like progress has stalled somewhat on the fix. Thanks in advance.

@pq
Copy link
Member

pq commented Apr 8, 2025

We have an issue suggesting that that fix might have caused other problems: #60463. We'll look to see whether we can mitigate the crashes without regressing the performance.

@bwilkerson : did this get resolved?

@bwilkerson
Copy link
Member

We decided that the performance problem would impact users more than the crashes, so we will be shipping the fix for the performance problem even though we have not yet resolved the problem with crashes.

I am working toward fixing the crashes, but it won't be a small enough change to CP, even if I can get the work done soon (which is an unknown).

@pq
Copy link
Member

pq commented Apr 8, 2025

@thanhdatvo
Copy link

Just a tip for vscode user: in order to test this dart-sdk, please update new sdk in settings.json and restart vscode

   "dart.sdkPath": "[DOWNLOAD_PATH]/bin/cache/dart-sdk",

@therybrian
Copy link

After testing I've noticed it's gotten much faster compared to before but what I'm getting now is the occasional Android Studio just freezing (on MacOS) and not being able to do anything until I force close it

@bwilkerson
Copy link
Member

@jwren For visibility.

As far as I'm aware, none of the changes we made to improve performance could cause Android Studio to freeze because they're all running in a separate process. I suspect that what you're seeing is a different problem.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
area-dart-model For issues related to conformance to the language spec in the parser, compilers or the CLI analyzer. model-performance Performance/memory issues in analyzer/cfe P1 A high priority bug; for example, a single project is unusable or has many test failures type-performance Issue relates to performance or code size
Projects
None yet
Development

No branches or pull requests