Are you struggling with slow Visual Studio Code on Raspberry Pi 4?
When I upgraded from a Raspberry Pi 3B to a Raspberry Pi 4B for a project I was working on, I was hoping to see Visual Studio Code benefit from the bump from 1GB to 4GB RAM. Instead I was treated to a slugfest, where I could barely type, do lookups, git sync, etc.
After a long evening of digging around, I finally figured out the root cause:
- Visual Studio Code is built on top of Chromium, the codebase that Google’s Chrome browser is based upon.
- Chromium has hardware acceleration enabled by default.
- The implementation of hardware acceleration sucks on Raspberry Pi 4B, as of 2021-11.
You can work around this by disabling hardware acceleration in both Chromium and VS Code:
How to Disable Hardware Acceleration in Chromium
The Chromium web browser is installed by default in the latest Raspbian Desktop release. It suffers the same issues as VS Code: horribly slow user interface, delayed clicking and scrolling etc.
To fix this:
- Open Chromium / “Web Browser”
- Click on the three vertical dots (aka hamburger) menu button, then Settings
- Scroll all the way down to the bottom and click Advanced to open the System section.
- Uncheck the “Use hardware acceleration when available” option (pictured below)
- Close and re-open Chromium for the change to take effect.
How to Disable Hardware Acceleration in Visual Studio Code
Changing the setting in Chromium doesn’t disable hardware acceleration in Visual Studio Code.
Here’s how to do it:
- Open Visual Studio Code
- Open the Command Palette by hitting your F1 key or the key combo Ctrl+Shift+P
- Begin typing runtime and you should see “Preferences: Configure Runtime Arguments” appear (Pictured below). Click it or hit Enter to open a configuration file called argv.json which allows us to set runtime arguments.
- There should be the line
"disable-hardware-acceleration": true,
commented out. (Pictured below)
- Uncomment the line by deleting the preceding
//
or add the line if it is missing entirely.
Tip: Be careful not forget the comma if the line is not the last uncommented one inside the curly braces.
- Save the file and restart Visual Studio Code for the change to take effect.
Get on with your life!
I hope this has saved you some trouble. Perhaps one day Chromium will be able to detect degraded performance and suggest disabling hardware acceleration to us. Until then, this is our “fix”!
As always, thanks for reading, and do drop a comment in the box below to let me know if this helped you out!
Cheers!
Ben
Thanks Ben! This made it from “completely unusable, how on earth did this even ship?!?” to “usable”!
You and me both, buddy!
You, Sir, gave me my pi4 back !
Thank you.
Glad to hear it Guibert!
This reared its ugly head when logging in via VNC.
When I search for runtime or any other term from the setting it doesn’t show up in the command bar. Is there any other way to acces this file?
Sorry for the late reply. The default Visual Studio Code config filepath is C:\Users\{username}\.vscode\argv.json on Windows, ~/.vscode/argv.json on Linux. Have you tried opening the file and adding the “disable-hardware-acceleration”: true line manually?