Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(linux): scope DMABuf disable to NVIDIA, fix AMD/Wayland UI lag

juve51672da956e5
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index fd2793966f..6ab89f4559 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -142,15 +142,27 @@ fn build_app_menu<R: tauri::Runtime>(app_handle: &tauri::AppHandle<R>) -> tauri:
}
#[cfg_attr(not(target_os = "linux"), allow(dead_code))]
-fn linux_webkit_rendering_workarounds() -> &'static [(&'static str, &'static str)] {
- &[
- // WebKitGTK's DMABUF renderer can produce a blank AppImage window or
- // Wayland protocol errors on Fedora/Wayland/NVIDIA systems.
- ("WEBKIT_DISABLE_DMABUF_RENDERER", "1"),
- // Tauri's Linux graphics guidance recommends this for Wayland explicit
- // sync issues that can prevent WebKitGTK from creating a usable surface.
- ("__NV_DISABLE_EXPLICIT_SYNC", "1"),
- ]
+fn linux_has_nvidia_gpu() -> bool {
+ // Detect the proprietary NVIDIA driver by checking for its kernel device
+ // node / proc entry. This is more reliable than parsing lspci output and
+ // has no external deps. Nouveau (open-source) does not create these nodes
+ // and falls through to the Mesa / DMABuf path, which is the desired behavior.
+ std::path::Path::new("/dev/nvidiactl").exists() || std::path::Path::new("/proc/driver/nvidia/version").exists()
+}
+
+#[cfg_attr(not(target_os = "linux"), allow(dead_code))]
+fn linux_webkit_rendering_workarounds(has_nvidia: bool) -> &'static [(&'static str, &'static str)] {
+ if has_nvidia {
+ // NVIDIA + Wayland: the DMABuf renderer triggers blank-window / Wayland
+ // protocol errors (EGL_EXT_image_dma_buf_import mismatch). Disable it
+ // and suppress explicit-sync to avoid a compositor crash.
+ &[("WEBKIT_DISABLE_DMABUF_RENDERER", "1"), ("__NV_DISABLE_EXPLICIT_SYNC", "1")]
+ } else {
+ // AMD / Intel / other Mesa drivers support DMABuf natively.
+ // Keeping DMABUF enabled lets WebKitGTK use GPU compositing, which
+ // dramatically reduces CPU usage and eliminates UI lag on Wayland.
+ &[]
+ }
}
#[cfg_attr(not(target_os = "linux"), allow(dead_code))]
@@ -211,7 +223,8 @@ fn linux_appimage_system_gtk_immodules_cache(
#[cfg(target_os = "linux")]
fn apply_linux_webkit_rendering_workarounds() {
- for (key, value) in linux_webkit_rendering_workarounds() {
+ let has_nvidia = linux_has_nvidia_gpu();
+ for (key, value) in linux_webkit_rendering_workarounds(has_nvidia) {
if std::env::var_os(key).is_none() {
std::env::set_var(key, value);
}
@@ -464,10 +477,13 @@ mod tests {
#[test]
fn applies_linux_webkit_rendering_workarounds_before_webkit_starts() {
+ // NVIDIA: DMABuf must be disabled to avoid blank window / Wayland protocol errors.
assert_eq!(
- linux_webkit_rendering_workarounds(),
+ linux_webkit_rendering_workarounds(true),
&[("WEBKIT_DISABLE_DMABUF_RENDERER", "1"), ("__NV_DISABLE_EXPLICIT_SYNC", "1")]
);
+ // AMD / Intel / Mesa: DMABuf is supported — no workarounds needed.
+ assert_eq!(linux_webkit_rendering_workarounds(false), &[]);
}
#[test]