Please read: See the last bit. I don't believe this is an issue related to Ubuntu, but rather VS Code.
Recently, under 17.10 and 18.04 (I just upgraded today), Ubuntu will randomly and completely freeze. I cannot move the cursor or use the keyboard. Naturally, I have tried switching to a TTY session with no success. Every time, I must resort to SysRq + REISUB, which is (obviously) not preferred.
I have attempted to switch graphics drivers, on the theory that it may be that. I was originally using the open source nVidia driver, and switched to the proprietary to no avail. I'm currently using the open source driver.
All that I typically have open is Firefox (not a ton of tabs loaded) and VS Code, with at most a couple files and a terminal open.
Any ideas?
Update: The system logs show no indication of anything at all happening, let alone something wrong. I don't know if this is related, but sometimes (and especially after booting) programs take a significant amount of time (> 5-10 seconds), even command line programs.
Yet another update! — Even with all GNOME extensions disabled, it still crashed. I tried XFCE, which still crashed.
Summary: Ubuntu completely freezes at seemingly random times, leaving no trace in logs, and is not related to any specific desktop environment or GNOME extensions.
(likely final) update: I'm convinced this is an issue with VS Code. I have been running GNOME for days, with other Electron apps open (Slack, Pulse, etc.), and have not had a single freeze. I have DM'd VS Code on Twitter, and will likely file a bug report as they haven't responded yet.
So it turns out that this isn't specific to Ubuntu, but I'll post this here anyways for future reference.
Apparently, even though I'm ignoring certain files using the
files.exclude
setting (notably the./node_modules
directory), VS Code still watches those files for changes.To solve that, simply copy the list from
files.exclude
tofiles.watcherExclude
. This will prevent VS Code from searching the many thousands of files that are innode_modules
or other similar directories. That way, it will leave some RAM for Chrome to gobble up.I just ran into this. Upon launch, in a big project, my system would freeze after ~20 seconds and become unresponsive (Ubuntu 18.04). Running htop while launching VSCode showed that it took all the cores to 100% (i7-8700K), ate all the memory (16gb) and then the swap. The freeze happened moments later. This was happening because of a bad extension, in my case it was CSS Peek.
So try launching vscode with extensions disabled (code --disable-extensions) and see if it still happens. If it doesn't track down the faulty extension and send it to hell.
I had random full freezes happening and spent quite a few hours trying to find out why. On restart the logs were really not helpful. I initially thought it was the nvidia driver, but no - just a VSCode extension.
I got the same issue in my Ubuntu 16.04.
I did switch off git.autorefresh in the Settings, then it works flawlessly and smoothly
I've experienced the same problem. Eventually I realized that in my case the problem is running out of memory (I have 8gb ram and just 1gb swap partition on disk). I fixed this by allocating additional swap space using file in my root directory:
this will temporary enable additional 8gb of swap for your system. If it will help, here you can read further instructions for enabling new swap constantly.
Another options are: add RAM physically or add/enlarge swap partition.
I used new swap as a file because I got luks+lvm encrypted system and resizing existing swap partition is too complicated and risky in my case.
P.S. I got Ubuntu 18.04
I had the same issue. To fix this for a particular project you will want to update the
.vscode/settings.json
to look something like this:For me, disabling gpu when calling vscode solved the problem.
Do it by using this alias to open vscode:
I have also suffered from random system crashes when running VSC. Even tried to start without extensions, which didn't help me at all. A few times my system froze right on startup of VSC.
However, I checked the logs and found that these crashes might correlate to the graphics driver (NVidia GTX 660).
Solution in my case: Switching from Nouveau to proprietary driver (I have chosen the metapackage)
Btw: Using Ubuntu 18.04
I had tried above workarounds and no luck.
For me, set the intel_idle.max_cstate=1 parameter in grub worked perfectly.
reboot it.
For me following workaround worked
Open the Command Palette (Ctrl+Shift+P). Run the Preferences: Configure Runtime Arguments command. This command will open a argv.json file to configure runtime arguments. You might see some default arguments there already. Add "disable-hardware-acceleration": true Restart VS Code.
Download VSCode and extract it. You'll see a file name “code” in the folder. Open a terminal and navigvate to that folder. Enter the command
via phero_constructs on reddit
Also, see this issue comments. You can do CTRL+SHIFT+P, then find Preferences Configuration. Insert this into the json (don't forget to add a comma after the preceding entry):