microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.5k stars 29.38k forks source link

VS Code freezes regularly on macOS 12.3 with Apple M1 #145387

Closed stefanbschneider closed 1 year ago

stefanbschneider commented 2 years ago

I'm using the latest stable VS Code on my MacBook Pro 2021 with M1 chip for programming Python (and C++). I have been having issues with VS Code randomly slowing down and freezing until macOS asks to stop it. Then I have to terminate VS Code and restart it. That happens multiple times within a couple of hours, so it's really annoying when coding & debugging.

The freeze happens out of nowhere. CPU load is very low, I'm not doing anything special or running expensive other programs in the background. I can't really reproduce the freeze quickly, but it does happen regularly (roughly every 0,5-2h).

Seems like other users also have this issue: https://github.com/microsoft/vscode/issues/122111 and https://github.com/microsoft/vscode/issues/129076 Unfortunately, these issues were closed and locked without providing a solution.

My extensions are:

code --install-extension alefragnani.Bookmarks
code --install-extension cschlosser.doxdocgen
code --install-extension eamodio.gitlens
code --install-extension jeff-hykin.better-cpp-syntax
code --install-extension mhutchie.git-graph
code --install-extension ms-python.python
code --install-extension ms-python.vscode-pylance
code --install-extension ms-toolsai.jupyter
code --install-extension ms-toolsai.jupyter-keymap
code --install-extension ms-toolsai.jupyter-renderers
code --install-extension ms-vscode-remote.remote-containers
code --install-extension ms-vscode-remote.remote-ssh
code --install-extension ms-vscode-remote.remote-ssh-edit
code --install-extension ms-vscode-remote.remote-wsl
code --install-extension ms-vscode.cmake-tools
code --install-extension ms-vscode.cpptools
code --install-extension ms-vscode.cpptools-extension-pack
code --install-extension ms-vscode.cpptools-themes
code --install-extension njpwerner.autodocstring
code --install-extension trond-snekvik.simple-rst
code --install-extension twxs.cmake

Since I need the extensions for development and I can't quickly reproduce the freeze, I couldn't test if the freeze eventually occurs with all extensions disabled.

Also, I tried recording a crash dump as described here, but no dump was created. Maybe because VS Code froze and didn't crash.

Any help is really appreciated. This really disturbs my coding workflow.

stefanbschneider commented 2 years ago

Any ideas? My guess is that this is connected to mypy somehow.

deepak1556 commented 2 years ago

Can you reproduce the freeze with 1.66 which comes with a newer runtime ? If it still repros, can you take a process dump following the steps below,

* Once the freeze happens, note the process ID of the window/workbench that froze using `code --status`
* Open Activity monitor and find the process with the same ID
* Double click on the process and choose the sample option button in the new window
* Attach the generated sample in this issue
deepak1556 commented 2 years ago

Also are you using the apple silicon build or the universal build ?

stefanbschneider commented 2 years ago

@deepak1556 I just had the freeze again after upgrading to VS Code 1.66. But I noticed that I had the universal build, so I can switch to the Silicon Build if that should help? While the docs do say that the universal build should support both M1 and Intel.

Or should I proceed with your process on the universal build?

deepak1556 commented 2 years ago

Hosting on the universal build is better, it was just to confirm whether the intel build was accidentally used. Please take a process dump with this version.

stefanbschneider commented 2 years ago

Hi, I followed your process. Once VS Code froze, I ran code --status:

Version:          Code 1.66.0 (e18005f0f1b33c29e81d732535d8c0e47cafb0b5, 2022-03-30T05:50:04.419Z)
OS Version:       Darwin arm64 21.4.0
CPUs:             Apple M1 Pro (10 x 24)
Memory (System):  32.00GB (6.28GB free)
Load (avg):       2, 2, 2
VM:               0%
Screen Reader:    no
Process Argv:     --crash-reporter-id e3d787a0-2d51-41f2-b68c-91b5e862d394
GPU Status:       2d_canvas:                              enabled
                  canvas_oop_rasterization:               disabled_off
                  direct_rendering_display_compositor:    disabled_off_ok
                  gpu_compositing:                        enabled
                  metal:                                  disabled_off
                  multiple_raster_threads:                enabled_on
                  oop_rasterization:                      enabled
                  opengl:                                 enabled_on
                  rasterization:                          enabled
                  raw_draw:                               disabled_off_ok
                  skia_renderer:                          enabled_on
                  video_decode:                           enabled
                  video_encode:                           enabled
                  webgl:                                  enabled
                  webgl2:                                 enabled

CPU %   Mem MB     PID  Process
    0      229     732  code main
    9      131     785     gpu-process
    0       33     822     utility-network-service
  116      721     825     window (stop_reward.py)
    4      557     882     extensionHost
    4      197     900       /Users/stefanshschneider/.vscode/extensions/ms-vscode.cpptools-1.9.7/bin/cpptools
    0       66     927       /Applications/Visual Studio Code.app/Contents/MacOS/Electron --ms-enable-electron-run-as-node /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/json-language-features/server/dist/node/jsonServerMain --node-ipc --clientProcessId=882
   31      492    1038       /Applications/Visual Studio Code.app/Contents/MacOS/Electron --ms-enable-electron-run-as-node /Users/stefanshschneider/.vscode/extensions/ms-python.vscode-pylance-2022.3.4/dist/server.bundle.js --cancellationReceive=file:7ce4afade22f3afa1537a52ac6f267a25b7705cfe5 --node-ipc --clientProcessId=882
    0      197     934     shared-process
    0       66     947       ptyHost
    0        0    3773         /bin/zsh -l
    0       98     995       fileWatcher
    0      131    4532     window (undefined)
    0      131    4621     window (undefined)

Workspace Stats:
|  Window (stop_reward.py)
|    Folder (dbbsim): more than 21322 files
|      File types: json(4506) py(4252) pyc(4233) png(1570) pyi(1148) so(314)
|                  pxd(200) txt(189) zip(162) c(127)
|      Conf files: dockerfile(4) makefile(2) launch.json(1) settings.json(1)
|                  package.json(1)
|      Launch Configs: python

Would I then look for process 825, which takes most of the CPU? Or 1038, ie, the electron process? Here is the dump/process sample for the latter: sample_electron.txt

deepak1556 commented 2 years ago

Please take process dump for the window process which has the high CPU consumption.

seanbischoff commented 2 years ago

@deepak1556 I'd closed my ticket - I'm on an Intel Mac - and it is still doing the same thing. I cannot get you a sample because the process is not responding - the sample window just hangs. I can't even screen capture it because nothing responds now.

ConnorDoesDev commented 2 years ago

I'm also having this issue on a MacBook Air M1 Monterey (12.1) - VS Code version 1.66.0 It freezes almost every few minutes, sometimes after tabbing out and back in, after closing an editor, switching files.. etc. If I recall correctly, this issue never happened before I updated to 1.66.0

ConnorDoesDev commented 2 years ago

Update: I've downloaded Visual Studio Code for Insiders and it seems to work fine.

stefanbschneider commented 2 years ago

I feel like this is due to mypy. I have it installed in one of my environments where VS Code keeps freezing. In another environment, where I don't use mypy and don't have it installed, VS Code does not freeze.

I'll provide more details/dump on the next freeze.

seanbischoff commented 2 years ago

I feel like this is due to mypy. I have it installed in one of my environments where VS Code keeps freezing. In another environment, where I don't use mypy and don't have it installed, VS Code does not freeze.

Our team suspects our use of iTerm and NodeJS. I'm planning to work with these & another IDE, and see if my Mac still freezes today.

seanbischoff commented 2 years ago

Happened with the other IDE, instant freeze, fan spunup & laptop crash/restart. 5 minutes after starting up local server, Node.js v14.15.4.

sumerc commented 2 years ago

Same issue. Regularly getting. Except in my case it never happens when docker is not running. It seems to be related with docker. Will try getting a dump.

UPDATE: I installed insiders and problem fixed.

mxagar commented 2 years ago

Same issue here.

Visual Studio Code Version: 1.66.2 Commit: dfd34e8260c270da74b5c2d86d61aee4b6d56977 Date: 2022-04-11T07:47:29.396Z (3 wks ago) Electron: 17.2.0 Chromium: 98.0.4758.109 Node.js: 16.13.0 V8: 9.8.177.11-electron.0 OS: Darwin arm64 21.4.0

sumerc commented 2 years ago

Problem still persists. It happens with 1.67.2 but not with 1.67.0 insiders version. This is an incredibly annoying problem and I would love to help for anyone interested in debugging this issue...

billychanRGA commented 2 years ago

any update?

trkee commented 2 years ago

+1

nikhilsarvaiye commented 2 years ago

facing same issue

wtclarke commented 2 years ago

Also having this issue on an Intel mac, macos 12.1. Occured after I updated from pylance v2021 to v2022.

trkee commented 2 years ago

I found that excluding vscode from the time machine seems to solve the problem. At least for about a week now it has been way better.

On Sat, May 28, 2022, 4:03 PM William T Clarke @.***> wrote:

Also having this issue on an Intel mac, macos 12.1. Occured after I updated from pylance v2021 to v2022.

— Reply to this email directly, view it on GitHub https://github.com/microsoft/vscode/issues/145387#issuecomment-1140329360, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSI4PRWA4GELSHXQ5MVFLTVMKC3FANCNFSM5RBQBWJA . You are receiving this because you commented.Message ID: @.***>

wtclarke commented 2 years ago

@trkee As in the workspace folder or the actual vscode app?

trkee commented 2 years ago

https://support.apple.com/en-il/guide/mac-help/mh15622/mac

trkee commented 2 years ago

The vscode app. @wtclarke

seanbischoff commented 2 years ago

For me, either slow freezes or hard fast crashes with VSCode, both stable & Insiders edition, and Webstorm, when running latest version of Node w/Nginx. We suspect it's with the OS memory management.

glaide commented 2 years ago

I'm facing the same issue here, with my mac M1, my OS is Monterey 12.3.1, vscode version: 1.67.2. I use vscode to run flutter, and when I use Android Studio it works pretty well.

codefingas commented 2 years ago

Facing the same issue. ☹️

sumerc commented 2 years ago

Ok. Another update:

I have again faced the issue with 1.68.0. But this time, I tried to debug the issue. Some findings:

Sample of Code Helper (Renderer).txt

Hope this helps! Please prioritize this issue. We have been facing this for months now...

specOper99 commented 2 years ago

as @sumerc wrote, I am facing the same problem with 1.68.0 and MacOS 12.4

deepak1556 commented 2 years ago

@sumerc thanks for the Code Helper (Renderer) process sample, can you also provide the sample of Code Helper and Code processes when the freeze happens. Also can you check the following,

(i) Does launching with code --disable-features="ParkableStringsToDisk" prevents the hang (ii) Does the issue happen with latest insiders https://code.visualstudio.com/insiders that comes with a newer runtime.

sumerc commented 2 years ago

Does the issue happen with latest insiders https://code.visualstudio.com/insiders that comes with a newer runtime.

I have been using Insiders 1.67.0 for a while now without any problem. I get this issue only when I use the normal version. Do you still want me to try the newest Insider version?

I will try to get the other information you requested.

FI: I get following warning:

> code --disable-features="ParkableStringsToDisk"
Warning: 'disable-features' is not in the list of known options, but still passed to Electron/Chromium.

I assume this is OK?

sumerc commented 2 years ago

I have reproduced the problem again. I ran the code with --disable-features="ParkableStringsToDisk" but get the warning above, so unsure if the flag has an effect or not.

I get samples from the following processes:

  1. Code
  2. Code Helper (There were several of them, I just selected one, no one seems to be using more CPU)
  3. Code Helper GPU (not too much CPU)
  4. Code Helper (Renderer) (There were several of them, I just selected the one that has %100 all the time)

Sample of Code Helper (GPU)2.txt Sample of Code Helper2.txt Sample of Code2.txt Sample of Code Helper (Renderer)2.txt

deepak1556 commented 2 years ago

Thanks for the logs, the warning is just to convey that the flag will be passed down to the runtime, you can ignore it.

From the Code Helper (Renderer) sample most of the cycle is spent on JIT code that cannot be symbolicated. As a next step, can you take a JS profile following the steps below,

* Launch vscode stable normally
* Open Command Palette and run `Toggle Developer Tools`
* Detach the devtools from the workbench into a separate window
* Choose Javascript Profiler tab from the devtools
* Start recording
* Once the workbench freezes
* Stop the profiler and attach the generated trace

I have been using Insiders 1.67.0 for a while now without any problem. I get this issue only when I use the normal version. Do you still want me to try the newest Insider version?

Is there a difference in extensions or settings used between stable and insiders ? Does the issue repro with insiders if you try with the same profile as stable.

sumerc commented 2 years ago

Is there a difference in extensions or settings used between stable and insiders ? Does the issue repro with insiders if you try with the same profile as stable.

Yes, the extension were different and I do a quick check: I uninstalled the ones (5 in total) there were not installed in the Insiders and the issue did not reproduced. So, I will (in parallel) try to find the problematic extension.

sample most of the cycle is spent on JIT code that cannot be symbolicated. As a next step, can you take a JS profile following the steps below,

Nice to know where the unsymbolicated frames were coming from. I was curious. Anyway, I have done that and reproduced the problem. However, the issue is: the resulting file is 159Mb and as I am using a company laptop, I am really unsure about what the profile can contain, I might need to ask security team. Having said that, is there anything you would like to see in the CPU profile? Below is a small screenshot of the top functions:

Screen Shot 2022-06-16 at 20 59 26

BTW, I am not closing the stuck app. right now just in case you would need to request any information by attaching it somehow?

sumerc commented 2 years ago

@deepak1556, another point: title is misleading that this issue only happens on macOS 12.3, as I can reproduce it in 12.4 as well.

sumerc commented 2 years ago

For reference: I have disabled CMake and CMake tools extensions and the problem is fixed for me.

So, I believe there is some extension API that causes the renderer process to get stuck. @deepak1556 , is there any other way to debug this issue other than the javascript profile? Do you still think you need the JS profile to move further on this issue?

deepak1556 commented 2 years ago

@sumerc sorry for the delay, tackling some milestone related issues. If you can share the JS profile that would be helpful to move the issue forward, also there shouldn't be any private data that should be of concern in sharing the profile. The call stacks should only be from VSCode core and it extensions. If there is concern, you can share the profile to my contact Deepak.Mohan@microsoft.com

Since you have narrowed down the problematic extensions, can you list any specific steps to be followed when recreating this issue (ex: install said extension and open a particular type of file) ? If possible, I would like to repro the issue on my setup which can also help simplify the debugging part.

sumerc commented 2 years ago

If there is concern, you can share the profile to my contact Deepak.Mohan@microsoft.com

Ok. I will reproduce it again(without involving any repos) and send you the profile.

Since you have narrowed down the problematic extensions, can you list any specific steps to be followed when recreating this issue (ex: install said extension and open a particular type of file) ? If possible, I would like to repro the issue on my setup which can also help simplify the debugging part.

For this, I will need to find out if the extensions are the root cause the problem or the extensions are conflicting with some other extension? In order to do that, I will try to reproduce the issue in a separate VS Code profile (with installing the extensions one-by-one) and see what happens.

Rickion commented 2 years ago

Same issue. And I found something strange. When VS Code is not responding, my Chrome costs CPU over 50%: image image

After a few secs: image

Only VS Code is not responding. Other Apps works well. After 10-20 sec, everything turns to good. This happens regularly when I switch apps bewteen chrome and vscode.

Run code -status seems good:

Version:          Code 1.68.1 (30d9c6cd9483b2cc586687151bcbcd635f373630, 2022-06-14T12:52:13.188Z)
OS Version:       Darwin x64 21.5.0
CPUs:             Apple M1 (8 x 24)
Memory (System):  16.00GB (0.04GB free)
Load (avg):       2, 1, 2
VM:               0%
Screen Reader:    no
Process Argv:     --crash-reporter-id 76ce2e8d-304c-4701-abd6-0229d6cd3a3a
GPU Status:       2d_canvas:                              enabled
                  canvas_oop_rasterization:               disabled_off
                  direct_rendering_display_compositor:    disabled_off_ok
                  gpu_compositing:                        enabled
                  metal:                                  disabled_off
                  multiple_raster_threads:                enabled_on
                  oop_rasterization:                      enabled
                  opengl:                                 enabled_on
                  rasterization:                          enabled
                  raw_draw:                               disabled_off_ok
                  skia_renderer:                          enabled_on
                  video_decode:                           enabled
                  video_encode:                           enabled
                  webgl:                                  enabled
                  webgl2:                                 enabled

CPU %   Mem MB     PID  Process
   10       66     994  code main
    0       49     997     gpu-process
    0       16    1000     utility-network-service
    0       33    1001     window (xxxx.py — xxx9)
    0      180    1004     window (Content.js — XXX)
    0       33    1534     shared-process
    0       16    1547       ptyHost
    0        0    2259         /bin/zsh -l
    0        0    2430         /bin/zsh -l
    0        0   75606         /bin/zsh -l
    0        0   96607         /bin/zsh -l
    0       16    2054       fileWatcher
    0       16   60364       fileWatcher
    0        0   96606       fileWatcher
    0       16    1544     extensionHost
    0       16    4718       /Applications/APPs/Visual Studio Code.app/

Update chrome not help. (Current version 103.0.5060.53 )

bebimoj commented 2 years ago

I just had a complete macos crash on M1 when opening vscode.

Vscode opened and It popped a recommendation for an angular extension, after clicking on extension it first froze my mouse and keyboard and then the mac restarted. After it restarted I got a send report to apple popup, by clicking on send report it then also froze the whole computer. Not sure if it's vscode or M1 related issue. IMHO M1 is the worst computer experience i've ever had including windows 98 and windows vista. Vscode on my old intel mac has never crashed and is still working fine.

bebimoj commented 2 years ago

This is the crash report i had. Doesn't even seem related to vscode it's showing logs about xcode ios coresimulator. I use vscode for python and angular development no simulator required and xcode wasn't even running.

Screenshot 2022-07-03 at 01 08 12
thedeterminedsoul commented 2 years ago

I have this issue on both intel and M1 macs. All of a sudden visual studio code freezes and slowly it freezes entire computer. +1 for the issue.

shennan commented 2 years ago

I get this issue (same behaviour but perhaps different reasons to OP) when I run a bash script for deployment which does a lot of cleaning and building of js packages in a monorepo/workspace that I currently have open in VS Code. I also get it sometimes when just doing a npx npkill to dump all node_module folders in the monorepo, sometimes followed by a yarn install. The commands don't error out, but often I'll have to restart VS Code.

Same behaviour; VS Code freezes and after a while it either recovers or gives me an unresponsive modal. Most of the time I have to force quite the app and restart.

I'm using macOS Monterey 12.4 on an M1 Pro.

michaelw76 commented 2 years ago

Hello, I have been experiencing more or less the same issue as folks were experiencing here - except that my VS Code would freeze the moment I would click on the "Open" link in the "Get Started" tab upon starting up VS Code. What I have done is I have installed Xcode Version 14.0 beta 3 (14A5270f) as well as the CLI tools for it. What I have than done is install Visual Studio for Mac version 17.0 - I made sure to check the option during installation to download the libraries for MacOS development. Once installation finished, I have opened up Visual Studio for Mac - it worked fine. I than deleted Visual Studio for Mac and installed VS Code from this link: https://code.visualstudio.com/?wt.mc_id=DX_841432 i.e. version 1.69.1 (universal). And it now works like a charm - without freezing.

Unfortunately I have not tested whether this issue got resolved due to me installing Xcode, or installing Visual Studio for Mac - but I would suggest trying Xcode first, than VS Code - and if it doesn't kill the freezing, delete VS Code, install Visual Studio for Mac, than VSCode and see if that helps.

I am running this Mac:

macOS Monterey Version 12.4 MacBook Air (M1, 2020) Chip: Apple M1 Memory: 8Gb

mmalik23 commented 2 years ago

I was having this issue. I fixed it by removing Sophos Home AV. It occured when compiling code through VSCode, not when compiling through another IDE or the command line.

My entire computer would also freeze when navigating to classes ( cpu/mem usage was be normal). I think the AV was either preventing the language server from properly reading the build files or blocking the connection between the text editor and the language server which uses rpc ( there were some connection errors in the logs)

I am using VSCode for scala development, so my setup is quite different from users here, however, this worked for me so I am putting this out there.

VScode 1.6.9

Extensions: Metals, scala-lang

macOS Monterey Version 12.4 MacBook Pro ( 14", M1, 2021) CPU: 10 cores Memory: 32Gb

k-vikram commented 2 years ago

Facing Same issue on Mac M1 16GB system as @Rickion (https://github.com/microsoft/vscode/issues/145387#issuecomment-1169808264)

sumerc commented 2 years ago

For future reference and FYI @deepak1556:

I have removed CMake and CMake tool extensions and my freeze problem went away.

image

I think this is a hard issue to reproduce and debug, I suggest anyone facing this issue to disable some part of their extensions to see what is causing the problem and report it here. For me, it was CMake however I am still suspecting that there might be a problematic API that is called from the extension that causes the problem.

daniel-han-ioof commented 2 years ago

same issue here on M1 mac 12.5

VAIMORSS commented 2 years ago

Getting the same issue with 12.0.1 (21A559), especially when changes are made in the package.json file (React project)

ghost commented 2 years ago

Same here with M1 Pro, 12.5 and VS Code 1.69.2. This looks like a correlation with the SSD, because when the VS code hangs, the whole system hangs.