如何在 Visual Studio 代码中禁用 GPU 渲染
How can I disable GPU rendering in Visual Studio Code
我遇到了糟糕的渲染问题...似乎 Visual Studio 代码 window 在重绘之前不清理屏幕区域。 chrome 浏览器也会发生同样的事情,但在 chrome 中,我可以使用“--disable-gpu-rendering”启动它,一切顺利。
如何在 Visual Studio 代码中禁用 GPU 渲染?
我认为这是一个特定于硬件的问题,我也在寻找其他方法来解决它。
了解我的硬件可能会有用:
Machine: Notebook dell vostro 3500 (intel chipset)
CPU: Intel i5
RAM: 8G
linux kernel: 4.0
video graphics: intel i915 (latest)
X -version: X.Org X Server 1.14.0
在 Windows 下,我可以确认用 --disable-gpu
启动 VSCode 不会创建 GPU 进程:
C:\Users\alex\AppData\Local\Code\app-0.1.0>Code.exe --disable-gpu
也许同样的标志也适用于 Linux?
在 Ubuntu,要编辑的文件是 /usr/share/applications/code.desktop
。
变化:
Exec=/usr/share/code/code --unity-launch %F
至:
Exec=/usr/share/code/code --disable-gpu --unity-launch %F
macOS 用户可以在终端中尝试以下命令:
转到“应用程序”文件夹:
cd Applications
在禁用 GPU 的情况下打开 VS 代码:
Visual\ Studio\ Code.app/Contents/MacOS/Electron --disable-gpu
注意:您可能需要为第二个命令提供 sudo
。
对于 Windows 用户
Visual studio 代码基于 chrome,要使其正常工作,您必须禁用硬件加速。
将 --disable-gpu --disable-gpu-compositing
添加到桌面上的 vs 代码快捷方式。
示例:
"C:\Program Files (x86)\Microsoft VS Code\Code.exe" --disable-gpu --disable-gpu-compositing
在 Linux Mint 上,我必须右键单击左下方的 mint 按钮,然后选择配置,然后按菜单按钮。然后按"Open Menu Editor"键,在编程组中找到Visual Studio代码。单击属性并找到命令字段。在那里你可以设置 --disable-gpu 选项。
请注意 VSCode 1.40 (Oct. 2019) 提出了替代 parameter/flag --disable-gpu
:
Disable GPU acceleration
We have heard issue reports from users that seem related to how the GPU is used to render VS Code's UI.
These users have a much better experience when running VS Code with the additional --disable-gpu
command-line argument.
Running with this argument will disable the GPU hardware acceleration and fall back to a software renderer.
To make life easier, you can add this flag as a setting so that it does not have to be passed on the command line each time.
To add this flag:
- 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.
Note: Do not use this setting unless you are seeing issues!
注意 Gilbert points out in to "How To Fix Screen Flickering Issue On Mac, MacBook, And iMac" from Preeti Seth.
吉尔伯特补充道:
I fixed the problem by disabling automatic graphics switching on my macbook pro.
The setting is located in system preferences -> battery
.
It worked!
如果环境变量映射正确,你可以简单地使用cmd.exe启动一个code的实例和--disable-gpu。请参阅屏幕截图。 enter image description here
在settings.json里面你可以这样写:-
"terminal.integrated.gpuAcceleration": "off"
有时问题是由于计算机试图节省能源而自动切换图形引起的。
就我而言,我的 macbook pro 有电池问题,所以每当我 运行 密集型应用程序(如 vscode。
时,它们表现为屏幕闪烁
要禁用自动图形切换,请转到系统偏好设置 -> 电池并取消勾选 Automatic graphic switching
。
参考本指南:https://wethegeek.com/how-to-fix-screen-flickering-issue-on-mac-macbook-and-imac/
我遇到了糟糕的渲染问题...似乎 Visual Studio 代码 window 在重绘之前不清理屏幕区域。 chrome 浏览器也会发生同样的事情,但在 chrome 中,我可以使用“--disable-gpu-rendering”启动它,一切顺利。
如何在 Visual Studio 代码中禁用 GPU 渲染?
我认为这是一个特定于硬件的问题,我也在寻找其他方法来解决它。
了解我的硬件可能会有用:
Machine: Notebook dell vostro 3500 (intel chipset)
CPU: Intel i5
RAM: 8G
linux kernel: 4.0
video graphics: intel i915 (latest)
X -version: X.Org X Server 1.14.0
在 Windows 下,我可以确认用 --disable-gpu
启动 VSCode 不会创建 GPU 进程:
C:\Users\alex\AppData\Local\Code\app-0.1.0>Code.exe --disable-gpu
也许同样的标志也适用于 Linux?
在 Ubuntu,要编辑的文件是 /usr/share/applications/code.desktop
。
变化:
Exec=/usr/share/code/code --unity-launch %F
至:
Exec=/usr/share/code/code --disable-gpu --unity-launch %F
macOS 用户可以在终端中尝试以下命令:
转到“应用程序”文件夹:
cd Applications
在禁用 GPU 的情况下打开 VS 代码:
Visual\ Studio\ Code.app/Contents/MacOS/Electron --disable-gpu
注意:您可能需要为第二个命令提供 sudo
。
对于 Windows 用户
Visual studio 代码基于 chrome,要使其正常工作,您必须禁用硬件加速。
将 --disable-gpu --disable-gpu-compositing
添加到桌面上的 vs 代码快捷方式。
示例:
"C:\Program Files (x86)\Microsoft VS Code\Code.exe" --disable-gpu --disable-gpu-compositing
在 Linux Mint 上,我必须右键单击左下方的 mint 按钮,然后选择配置,然后按菜单按钮。然后按"Open Menu Editor"键,在编程组中找到Visual Studio代码。单击属性并找到命令字段。在那里你可以设置 --disable-gpu 选项。
请注意 VSCode 1.40 (Oct. 2019) 提出了替代 parameter/flag --disable-gpu
:
Disable GPU acceleration
We have heard issue reports from users that seem related to how the GPU is used to render VS Code's UI.
These users have a much better experience when running VS Code with the additional--disable-gpu
command-line argument.
Running with this argument will disable the GPU hardware acceleration and fall back to a software renderer.To make life easier, you can add this flag as a setting so that it does not have to be passed on the command line each time.
To add this flag:
- Open the Command Palette (Ctrl+Shift+P).
- Run the
Preferences: Configure Runtime Arguments
command. This command will open aargv.json
file to configure runtime arguments.
You might see some default arguments there already.- Add
"disable-hardware-acceleration": true
- Restart VS Code.
Note: Do not use this setting unless you are seeing issues!
注意 Gilbert points out in
吉尔伯特补充道:
I fixed the problem by disabling automatic graphics switching on my macbook pro.
The setting is located insystem preferences -> battery
.
It worked!
如果环境变量映射正确,你可以简单地使用cmd.exe启动一个code的实例和--disable-gpu。请参阅屏幕截图。 enter image description here
在settings.json里面你可以这样写:-
"terminal.integrated.gpuAcceleration": "off"
有时问题是由于计算机试图节省能源而自动切换图形引起的。
就我而言,我的 macbook pro 有电池问题,所以每当我 运行 密集型应用程序(如 vscode。
时,它们表现为屏幕闪烁要禁用自动图形切换,请转到系统偏好设置 -> 电池并取消勾选 Automatic graphic switching
。
参考本指南:https://wethegeek.com/how-to-fix-screen-flickering-issue-on-mac-macbook-and-imac/