fix(wayland): disable webkit dmabuf renderer on legacy wayland versions (<1.23) #6999 (#7000)

This commit is contained in:
Tunglies
2026-05-14 21:11:08 +08:00
committed by GitHub
parent a60ef75061
commit b7ae54b9f3
3 changed files with 27 additions and 1 deletions
+1
View File
@@ -13,6 +13,7 @@
- 修复 Linux 关闭 TUN 不立即生效
- 修复系统代理关闭序列逻辑(防止快速退出时系统代理关闭状态没有保存)
- 修复 Linux 快捷键映射错误
- 修复 Linux Wayland 兼容性导致渲染错误
### ✨ 新增功能
+2
View File
@@ -216,6 +216,8 @@ pub fn run() {
#[cfg(target_os = "linux")]
utils::linux::workarounds::apply_nvidia_dmabuf_renderer_workaround();
#[cfg(target_os = "linux")]
utils::linux::workarounds::apply_wayland_webkit_fix();
let _ = utils::dirs::init_portable_flag();
+24 -1
View File
@@ -4,7 +4,7 @@
//! These helpers are not fixes and may stop working as environments change.
use clash_verge_logging::{Type, logging};
use std::{fs, path::Path};
use std::{env, fs, path::Path, process::Command};
pub fn apply_nvidia_dmabuf_renderer_workaround() {
if std::env::var_os("WEBKIT_DISABLE_DMABUF_RENDERER").is_some() {
@@ -23,6 +23,29 @@ pub fn apply_nvidia_dmabuf_renderer_workaround() {
}
}
/// !Might cause more memory footpoint
pub fn apply_wayland_webkit_fix() {
let is_wayland = env::var("XDG_SESSION_TYPE").unwrap_or_default() == "wayland";
if !is_wayland {
return;
}
let version = Command::new("pkg-config")
.args(["--modversion", "wayland-client"])
.output()
.ok()
.and_then(|output| String::from_utf8(output.stdout).ok());
if let Some(v) = version
&& v.trim() <= "1.23.0"
{
unsafe {
env::set_var("WEBKIT_DISABLE_DMABUF_RENDERER", "1");
}
}
}
fn has_nvidia_gpu() -> bool {
if Path::new("/proc/driver/nvidia/version").exists()
|| Path::new("/sys/module/nvidia").exists()