dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.2k stars 1.57k forks source link

[Dart Analyzer] Dart process occupy almost 100% of CPU. #47635

Closed terry960302 closed 1 year ago

terry960302 commented 2 years ago

When turn on flutter project with vscode. Dart process occupy almost 100% of CPU. (sometimes more than 100%). and never goes down lower than 94%. All the Flutter projects were same.(It's not about project size). Another typescript, go projects doesn't have this problem. Only the flutter projects have dart zombie process issue.

• No issues found!


- `code --status` result
```bash
CPU %   Mem MB     PID  Process
    2       98   15899  code main
    0       66   15902     gpu-process
    0       16   15904     utility
    0       66   15940     shared-process
    1       33   16033       ptyHost
    0        0   17022         /bin/zsh -l
    0        0   19526           bash /usr/local/bin/code --status
    1       33   19536             electron_node cli.js 
    1      229   17012     window (like_review_button.dart — monegi)
    0       49   17013       extensionHost
    0        0   17063         bash /Users/terry/Development/flutter/bin/flutter daemon
    0       66   17084           /Users/terry/Development/flutter/bin/cache/dart-sdk/bin/dart --disable-dart-dev --packages=/Users/terry/Development/flutter/packages/flutter_tools/.packages /Users/terry/Development/flutter/bin/cache/flutter_tools.snapshot daemon
    0        0   17514             /usr/bin/script -t 0 /dev/null xcrun xcdevice observe --both
    0       16   17515               /Applications/Xcode.app/Contents/Developer/usr/bin/xcdevice observe --both
   96      229   17065         /Users/terry/Development/flutter/bin/cache/dart-sdk/bin/dart /Users/terry/Development/flutter/bin/cache/dart-sdk/bin/snapshots/analysis_server.dart.snapshot --lsp --client-id=VS-Code --client-version=3.28.0
    0       16   17307         /Users/terry/Development/flutter/bin/cache/dart-sdk/bin/dart pub global run devtools --machine --try-ports 10 --allow-embedding
    0        0   17452           electron_node config.js 
    0       16   17972         /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Renderer).app/Contents/MacOS/Code Helper (Renderer) /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/json-language-features/server/dist/node/jsonServerMain --node-ipc --clientProcessId=17013
    0       16   17015       watcherServiceNSFW

Workspace Stats: 
|  Window (like_review_button.dart — monegi)
|    Folder (monegi): more than 20119 files
|      File types: dev(2155) prod(2155) staging(2155) xml(196) iml(20) bin(11)
|                  properties(7) lock(6) json(5) jar(4)
|      Conf files: launch.json(1)
|      Launch Configs: dart(3)

App: Visual Studio Code Version: 1.62.0 Platform: mac

Workspace type: Flutter Analyzer type: LSP Multi-root?: false

Dart SDK: Loc: /Users/terry/Development/flutter/bin/cache/dart-sdk Ver: 2.14.4 Flutter SDK: Loc: /Users/terry/Development/flutter Ver: 2.5.3

HTTP_PROXY: undefined NO_PROXY: undefined

Logging Categories: General, Analyzer, CommandProcesses, DAP, VmService, DevTools, FlutterDaemon, FlutterRun, FlutterTest, PubTest, WebDaemon

Fri Nov 05 2021 [20:49:11 GMT+0900 (대한민국 표준시)] Log file started [오후 8:49:12] [General] [Error] Failed to background start DevTools [오후 8:49:12] [General] [Error] Dart DevTools exited with code 66. [오후 8:49:13] [FlutterDaemon] [Info] <== [{"event":"device.added","params":{"id":"chrome","name":"Chrome","platform":"web-javascript","emulator":false,"category":"web","platformType":"web","ephemeral":false,"emulatorId":null}}] [오후 8:49:13] [General] [Info] Checking 1 projects for supported platforms [오후 8:49:13] [FlutterDaemon] [Info] ==> [{"id":"3","method":"daemon.getSupportedPlatforms","params":{"projectRoot":"/Users/terry/Desktop/FullStackProjects/Monegi/monegi-review/app/monegi"}}] [오후 8:49:13] [FlutterDaemon] [Info] <== [{"id":"3","result":{"platforms":["ios","android","web"]}}] [오후 8:49:13] [General] [Info] Supported platforms for the workspace are ios, android, web Fri Nov 05 2021 [20:56:28 GMT+0900 (대한민국 표준시)] Log file ended

DJafari commented 2 years ago

+1 it's mine :

image

Mac Mini, M1, Monterey

DanTup commented 2 years ago

Some things to try:

  1. Enable the analysis server instrumentation log then reproduce the issue and have a look at the last lines inside tat log to see if there's an obvious error (or perhaps a loop in analysis)
  2. If this happens only in some specific folders and not others, try and narrow down what's in that folder that triggers it (for example by opening sub-folders of that folder one at a time, or duplicating the folder and deleting folders until you find the one that causes it)

@terry960302 out of interest, is your Mac also an M1?

terry960302 commented 2 years ago

Some things to try:

  1. Enable the analysis server instrumentation log then reproduce the issue and have a look at the last lines inside tat log to see if there's an obvious error (or perhaps a loop in analysis)
  2. If this happens only in some specific folders and not others, try and narrow down what's in that folder that triggers it (for example by opening sub-folders of that folder one at a time, or duplicating the folder and deleting folders until you find the one that causes it)

@terry960302 out of interest, is your Mac also an M1?

  1. did analysis server instrumentation log, but there's no log recorded. Am I doing right?
    • set dart.analyzerIntrumentationLogFile : "Desktop/filename.txt" on vscode settings.json
    • and re open project -> no log recorded.
    • run dart capture log -> no log recorded.
  2. when open android/app/build/intermediates directory with vscode, bug start to reproduce. but each directory under intermediates folder(open javac or open processed_res etc...), there's no bug happened, dart zombie process issue only happened when open android/app/build/intermediates.

many directories under intermediates folder

drwxr-xr-x   5 terry  staff   160B 11 11 21:46 ..
drwxr-xr-x   3 terry  staff    96B 11  6 14:19 aapt_proguard_file
drwxr-xr-x   5 terry  staff   160B 11 11 14:35 compile_and_runtime_not_namespaced_r_class_jar
drwxr-xr-x   3 terry  staff    96B 11  7 01:48 default_proguard_files
drwxr-xr-x   5 terry  staff   160B 11 11 14:34 flutter
drwxr-xr-x   8 terry  staff   256B 11 11 18:00 incremental
drwxr-xr-x   4 terry  staff   128B 11  7 01:03 javac
drwxr-xr-x   5 terry  staff   160B 11 11 14:35 legacy_multidex_aapt_derived_proguard_rules
drwxr-xr-x   3 terry  staff    96B 11  6 14:19 merged-not-compiled-resources
drwxr-xr-x   5 terry  staff   160B 11 11 14:35 merged_assets
drwxr-xr-x   3 terry  staff    96B 11  6 14:19 packaged_manifests
drwxr-xr-x   5 terry  staff   160B 11 11 14:35 processed_res
drwxr-xr-x   3 terry  staff    96B 11  6 14:19 res
drwxr-xr-x   5 terry  staff   160B 11 11 14:35 runtime_symbol_list
drwxr-xr-x   5 terry  staff   160B 11 11 14:35 symbol_list_with_package_name

@DanTup No. My mac is not M1 but intel chip(2019 Macbook pro 16inch)

DanTup commented 2 years ago

did analysis server instrumentation log, but there's no log recorded. Am I doing right? set dart.analyzerIntrumentationLogFile : "Desktop/filename.txt" on vscode settings.json

I'm not certain, but I think this path might need to be a full absolute path (and the folder might need to exist).

when open android/app/build/intermediates directory with vscode, bug start to reproduce

Can you reproduce this from a new project created with flutter create, or only in this specific project?

fidelisakilan commented 2 years ago

i'm facing same issue with dart process, not sure what is causing it. When im running a project its fine. After i close android studio, this process is still running and my computer becomes hot. image

Machine: Macbook Air M1

[✓] Flutter (Channel stable, 2.5.3, on macOS 12.0.1 21A559 darwin-arm, locale en-IN) • Flutter version 2.5.3 at /Users/fidelisakilan/development/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 18116933e7 (8 weeks ago), 2021-10-15 10:46:35 -0700 • Engine revision d3ea636dc5 • Dart version 2.14.4

DanTup commented 2 years ago

@fidelisakilan could you try the things noted in https://github.com/dart-lang/sdk/issues/47635#issuecomment-965006034 to see if there's anything useful in a log, or if you can narrow down if it's caused by a specific set of files?

github-actions[bot] commented 1 year ago

Without additional information we're not able to resolve this issue, so it will be closed at this time. You're still free to add more info and respond to any questions above, though. We'll re-open the case if you do. Thanks for your contribution!