microsoft / vscode

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

Leaking notifications make VS Code freeze #62970

Closed gregvanl closed 5 years ago

gregvanl commented 5 years ago

Several hangs in a row. Attached are the log files from two of the hangs which contain the error [error] [VS Code]: detected unresponsive.

InsidersHangs.zip

roblourens commented 5 years ago

What were you doing before the hangs?

I don't think the logs have any useful info besides this error which shows up many times after the hang message in one instance

[error] SyntaxError: Unexpected token o in JSON at position 0
    at JSON.parse (<anonymous>)
    at c (C:\Users\gregvanl\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\code\electron-main\main.js:177:254)
    at e.onBuffer (C:\Users\gregvanl\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\code\electron-main\main.js:182:571)
    at C:\Users\gregvanl\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\code\electron-main\main.js:180:669
    at e.fire (C:\Users\gregvanl\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\code\electron-main\main.js:122:218)
    at C:\Users\gregvanl\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\code\electron-main\main.js:185:795
    at C:\Users\gregvanl\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\code\electron-main\main.js:120:478
    at C:\Users\gregvanl\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\code\electron-main\main.js:120:705
    at e.fire (C:\Users\gregvanl\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\code\electron-main\main.js:122:218)
    at EventEmitter.r (C:\Users\gregvanl\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\code\electron-main\main.js:127:987)
    at emitTwo (events.js:131:20)
    at EventEmitter.emit (events.js:214:7)
    at WebContents.<anonymous> (C:\Users\gregvanl\AppData\Local\Programs\Microsoft VS Code Insiders\resources\electron.asar\browser\api\web-contents.js:286:13)
    at emitTwo (events.js:126:13)
    at WebContents.emit (events.js:214:7)

@jrieken is there any way to tie this to issues we've looked at lately?

jrieken commented 5 years ago

Yeah, could be the memory/listener leak... Best is to try with latest insiders or 1.29 stable...

jrieken commented 5 years ago

Otherwise, jump straight to cpu profiling the renderer processes via: F1 > Toggle Developer Tools. In the overflow menu select 'More Tools > JavaScript Profiler'. In there select start, let it profile for 30 to 60 seconds, stop it, save it to a file and attach the file here. Thanks.

screen shot 2017-09-28 at 09 44 31
sgyzetrov commented 5 years ago

Hi, I am also experiencing hang. VS Code version Version 1.29.0, macOS 10.13.6 (17G3025)

But unfortunately, because the window was unresponsive, I cannot get developer tool to launch, so I did not get any CPU profiling. But I do have control over other VS Code windows running separately to the window that frozen. Will profiling other windows produce useful information? Also, during the hang, Code Helper spiked to 100%.

joseph1125 commented 5 years ago

1.29 stable with Windows 10 also experience this problem

tomaxsas commented 5 years ago

same here with Win 10 and 1.29.0

jrieken commented 5 years ago

@sgyzetrov @joseph1125 @tomaxsas Only CPU profiling will help us understand this. If the hang is very bad, then restart VS Code, start dev tools and keep them in the background, and profile when the editor is unresponsive.

sgyzetrov commented 5 years ago

@sgyzetrov @joseph1125 @tomaxsas Only CPU profiling will help us understand this. If the hang is very bad, then restart VS Code, start dev tools and keep them in the background, and profile when the editor is unresponsive.

Yeah...I did that, just now. After letting dev tool run in the background for more than 3 hrs, finally VS Code hang again (I was not even working on it, I was browsing Reddit on another macOS desktop), and this time, CPU profiler got stuck too.

I clicked start (it then turned into a red 'stop'), I then let it run for 57 sec, nothing happened, so I clicked 'stop'. BUT then it just STUCK. There is no info coming up, I tried to start a new profile, but the button is a grey 'start'. And collect garage, clear all profiles were all unresponsive. start CPU profiling told me another profiling is already running, but I definitely clicked stop.

activity_monitor__all_processes_-2 activity_monitor__all_processes_

Looks to me there is a serious memory leak. I will wait for another hang and keep trying to acquire the CPU profile you want, stand by.

sgyzetrov commented 5 years ago

Had to force quit Code Helper and VS Code to let my fan slow down...

jrieken commented 5 years ago

I then let it run for 57 sec,

Try to profile for much shorter then, 5-10 seconds and even then it can take a very long time to finally save the profile.

vishwa-raj commented 5 years ago

I have also experienced this twice just now. VS Code freezing when it's not even being worked on. 1.29 on Windows 10

tecosaur commented 5 years ago

I'm getting this severely too. Is there any way I can roll back to the previous version?

jrieken commented 5 years ago

@VishwaRajGit @tecosaur please help us profile this.

nov-13-2018 18-08-19

Thanks for your help.

jrieken commented 5 years ago

everyone also attach the list of extensions you are using, simply run code --list-extensions.

dgolovin commented 5 years ago

@jrieken After vs code window was frozen, I was following the steps above and profiler just got into state shown below. I am still waiting for 'Save' to appear, but it seems never going to happen. image

I am on Windows 10 Pro

code --version
1.29.0
5f24c93878bd4bc645a4a17c620e2487b11005f9
x64
gitawego commented 5 years ago

my vscode got hangs as well with new version in windows 10

my extensions: dbaeumer.vscode-eslint donjayamanne.githistory eamodio.gitlens EditorConfig.EditorConfig eg2.tslint esbenp.prettier-vscode formulahendry.auto-close-tag formulahendry.auto-rename-tag mikegleasonjr.theme-go ms-python.python ms-vscode.Go msjsdiag.debugger-for-chrome PeterJausovec.vscode-docker redhat.java robertohuertasm.vscode-icons rust-lang.rust streetsidesoftware.code-spell-checker

florentcm commented 5 years ago

Same here. Happens every 10-15 minutes. version 1.29 on Windows 10. Experienced the freeze more than a dozen of times today since updating to last version.

khayuenkam commented 5 years ago

Freeze quite frequently to me as well. I have attached the cpu profile which is in .txt extension since Github not allow to upload .cpuprofile

profile.txt

VSCode Version: 1.29.0 OS Version: MacOS 10.13.6

Code Extensions:

sgyzetrov commented 5 years ago

Hi folks,

It sees VS Code will reproduce this hang whenever it is not being worked on. Although strangely if your workspace only contains markdown or HTML this issue would not occur. Since I did not experience hang in separate VS Code windows where I was editing .md or .html files.

The window I got hang was the one I was editing .tex files with latex-workshop plugin.

@jrieken Johannes, I finally got the CPU profile. This time I profiled for 5 sec, after waiting for about 5 min I was able saved it.

My extensions are listed below.

Gimly81.matlab
austin.code-gnu-global
DavidAnson.vscode-markdownlint
DotJoshJohnson.xml
gnhuy91.theme-oceanicnext-sublime
James-Yu.latex-workshop
magicstack.MagicPython
mitaki28.vscode-clang
ms-python.python
ms-vscode.azure-account
ms-vscode.cpptools
naumovs.theme-oceanicnext
PeterJausovec.vscode-docker
PKief.material-icon-theme
redhat.java
tht13.python
vscjava.vscode-java-debug
vscjava.vscode-java-pack
vscjava.vscode-java-test
vscjava.vscode-maven
yzhang.markdown-all-in-one

CPU profile with .txt extension added CPU-20181114T084129.cpuprofile.txt

alex-ketch commented 5 years ago

Similar to @sgyzetrov I've noticed VS Code reliably freezing if I switch focus to a different application and then come back to it.

Attached is a CPU profile from the latest freeze. I only tabbed over to Safari for a few seconds. Please let me know if I can help any further.

VSCode Version: 1.30.0-insider OS Version: MacOS 10.14.1

Installed Extensions - `Zarel.sublime-commands` - `Zignd.html-css-class-completion` - `aaron-bond.better-comments` - `abusaidm.html-snippets` - `alanz.vscode-hie-server` - `alefragnani.Bookmarks` - `alefragnani.project-manager` - `alqiu.ts-loader-problem-matcher` - `andys8.jest-snippets` - `arcticicestudio.nord-visual-studio-code` - `bierner.markdown-preview-github-styles` - `christian-kohler.npm-intellisense` - `christian-kohler.path-intellisense` - `chrmarti.regex` - `daltonjorge.scala` - `dbaeumer.vscode-eslint` - `deerawan.vscode-dash` - `dinhani.divider` - `donjayamanne.githistory` - `eamodio.find-related` - `eamodio.gitlens` - `EditorConfig.EditorConfig` - `eg2.tslint` - `esbenp.prettier-vscode` - `felipe.nasc-touchbar` - `formulahendry.auto-rename-tag` - `gamunu.vscode-yarn` - `GitHub.vscode-pull-request-github` - `HookyQR.beautify` - `infeng.vscode-react-typescript` - `jcanero.hoogle-vscode` - `joelday.docthis` - `jpoissonnier.vscode-styled-components` - `jtlowe.vscode-icon-theme` - `justusadam.language-haskell` - `kevinkyang.auto-comment-blocks` - `kumar-harsh.graphql-for-vscode` - `maptz.camelcasenavigation` - `mgmcdermott.vscode-language-babel` - `mrmlnc.vscode-stylefmt` - `ms-vsliveshare.vsliveshare` - `msjsdiag.debugger-for-chrome` - `naumovs.color-highlight` - `nmsmith89.incrementor` - `nwolverson.ide-purescript` - `nwolverson.language-purescript` - `Orta.vscode-jest` - `PeterJausovec.vscode-docker` - `quicktype.quicktype` - `ryanluker.vscode-coverage-gutters` - `Shan.code-settings-sync` - `shaunlebron.vscode-parinfer` - `shinnn.stylelint` - `silvenon.mdx` - `sleistner.vscode-fileutils` - `stringham.move-ts` - `stubailo.ignore-gitignore` - `teabyii.ayu` - `vscodevim.vim` - `WallabyJs.quokka-vscode` - `wix.vscode-import-cost` - `wmaurer.change-case` - `xabikos.JavaScriptSnippets` - `xabikos.ReactSnippets` - `Yummygum.city-lights-icon-vsc` - `yzhang.markdown-all-in-one` - `zhuangtongfa.Material-theme`


CPU profile with .txt extension added CPU-20181113T205652.cpuprofile.txt

roblourens commented 5 years ago

@alex-ketch and @khayuenkam's traces appear to show the same as others I've seen, basically just tons of IPC message receiving. I see NotificationsToasts.purgeNotification showing up a lot? I think that's workbench.main.js:3620

This commit https://github.com/Microsoft/vscode/commit/9efef6a484cda14209399356ad814a4f0248b0f6 looks a bit suspicious considering it involves the window onDidChangeFocus, but I have no clue what this would have to do with IPC traffic.

Did anyone have notifications visible when this happened?

@mjbvz did you get anywhere when looking at the window switching issue?

sgyzetrov commented 5 years ago

Hi all,

I have noticed there is little useful information in my previous profile, possibly because the profile time is too short. I am uploading a much larger profile (over 30 sec). @jrieken @roblourens I hope it will be of help.

CPU-20181114T160347.cpuprofile.txt

edvinv commented 5 years ago

Same issue here on ubuntu 18.04. Not sure, but I think that it hangs when I work on other application for some time and then switch back to vscode.

jrieken commented 5 years ago

Thanks @sgyzetrov. That profile shows much more. Just a QQ is that 1.29-stable or 1.30-insiders?

Yours and other traces hint towards a storm of IPC messages that overwhelm the renderer process. Can please run VS Code with extension host communication logging enabled, like so:

code --logExtensionHostCommunication

That will print all messages that are exchanged between the renderer and extension process to the dev tool console. Again, open dev tools early and when the freeze happened, then select the console tab, right click in there, and select save as and share the log. Thanks for helping us.

sgyzetrov commented 5 years ago

@jrieken I am using 1.29.0-stable / 5f24c93878bd4bc645a4a17c620e2487b11005f9 / x64.

jrieken commented 5 years ago

Thanks @sgyzetrov. Please try code --logExtensionHostCommunication

sgyzetrov commented 5 years ago

Will do, standing by for the next freeze.

On Nov 14, 2018, at 16:43, Johannes Rieken notifications@github.com wrote:

Thanks @sgyzetrov https://github.com/sgyzetrov. Please try code --logExtensionHostCommunication

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Microsoft/vscode/issues/62970#issuecomment-438582350, or mute the thread https://github.com/notifications/unsubscribe-auth/AhCStbyO1Sj52G4KAicMa2wWlGdjYE_Oks5uu9fFgaJpZM4YafiK.

jrieken commented 5 years ago

@sgyzetrov Sorry, wrong trace... This isn't between the extension host and the render but between the main process and the renderer. So, logging the extension host communication won't add more info.

The behaviour does look like a listener leak. Yesterday, I have pushed https://github.com/Microsoft/vscode/commit/b548ced43cb1c9f86f3a013e20ccd8613fbd4138 which is a check for leaking listeners. @sgyzetrov and everyone else please use todays Insiders build and keep an eye on the dev tools console. It will print warnings when listeners appear to be leaking: http://code.visualstudio.com/insiders/

neildom commented 5 years ago

@roblourens Yes I had three notifications open. One relating to a Jest extension and another two relating to a Flow extension. I moved to a new PC recently and I'm using wsl so I expected that to be the cause of the notifications. In the previous version of vscode, I dismissed the notifications but I read in the release notes for this version that even notifications with buttons should disappear so I have been ignoring the notifications.

jrieken commented 5 years ago

Thanks @neildom. Also, please try http://code.visualstudio.com/insiders/ keep an eye open for leakage warnings.

jrieken commented 5 years ago

Not yet sure what happened but the attached movie shows how tabbing between two windows increases the number of listeners drastically (from 1789 to 5689 with not many switches). cmd-tab-party.mov.zip

As @roblourens already pointed out, this code is fishy https://github.com/Microsoft/vscode/blob/c9408a694059aed5216f188141b829b877755cae/src/vs/workbench/browser/parts/notifications/notificationsToasts.ts#L214-L228

I don't know yet what it is but whenever this if-condition (L222) is true and focus has been gained then listeners recursively add them as part of handling the event. Somehow auto hiding notification toats aren't disposed (or disposed too late) and that causes this crazy listener accumulation.

jrieken commented 5 years ago

nov-14-2018 15-29-21

I can reliably reproduce this. In above gif I have added a message that prints whenever a new listener is added, I have also tweaked the purge timeout to make things happen faster.

  1. have a sticky notification, like the update notifications or one with buttons
  2. when it pops up and within the purge timeout (15sec) focus another app
  3. now we have a sticky notification but no window focus (L222) which means we add another listener (L223) - we now have 2 listeners for that notification.
  4. Repeat steps 1-3 you have 4 listeners, then 8, 16, 32, 64, 128, etc

Eventually everything is cleaned-up (once the toast hides) but with an unlucky sequence of focus changes and because this leak grows exponential things get messy quickly. I have reached states with 500000+ listeners easily which means game over.

jrieken commented 5 years ago

I have created https://github.com/Microsoft/vscode/pull/63136 to fix this.

jrieken commented 5 years ago

Everyone that is affected by this: Clearing your notifications should help to workaround this.

filipesilva commented 5 years ago

I was seeing this while editing a file for which I did not have the suggested extension, which triggered a popup that I didn't bother clearing.

jrieken commented 5 years ago

I have pushed https://github.com/Microsoft/vscode/commit/aa4ef3a42c2240b22863c64ba972c08fa9b224f3 to master which should fix this for next insiders

fusengine commented 5 years ago

Vscode is Nice this frozen completly my mac hahahah

24edbb38-8459-47e4-b3fc-e44d8694ab6a

jrieken commented 5 years ago

@fusion809 not nice but also unrelated to this issue. please create a separate issue for this (cc @roblourens)

sgyzetrov commented 5 years ago

Make sense. With freshly installed insider ver, I never experienced hang since I don't have plugins that popup errors.

fusengine commented 5 years ago

Window😻

fusion809 commented 5 years ago

@jrieken Am I right in saying you pinged me by accident? That you were really aiming for @fusengine?

jrieken commented 5 years ago

Yeah, sorry about about...

fusengine commented 5 years ago

Yeah, sorry about about...

why aim for me?

christoxl commented 5 years ago

I just leave it unattended for 5 or more minutes and it freezes completely.

I'm using Linux Mint 18.3 and this wasn't happening last week.

enabled_extensions.txt system_information.txt

roblourens commented 5 years ago

We have pushed a possible fix to Insiders. Would appreciate if everyone checks out our insiders build to verify that you don't see this issue there: https://code.visualstudio.com/insiders/

alex-ketch commented 5 years ago

I've been using today's build all day and haven't encountered the problem so far🤞 Version 1.30.0-insider (6ef7e81ec086ced5fb20e904ea405075be474023)

Appreciate all your help @jrieken @roblourens

fusengine commented 5 years ago

Your insider not change problem

fusengine commented 5 years ago

sublime text is much more stable than vscode it's a shame on the part of windows. before publishing a version, try the machine

jrieken commented 5 years ago

@fusengine According to your first comment (https://github.com/Microsoft/vscode/issues/62970#issuecomment-438693227) you are not having the problem discussed in this issue. There is a separate issue about many rg processes so please make sure to comment on the right issue

fusengine commented 5 years ago

@jrieken start to publish stable software.

and I think I'm in the right section. And congratulations for the update. as I repeat again the process rg frozen completly my mac and it is your colleague who moved me here so I will write here. for informartion insider bug always in my opinion you do not find the problem.