fix(graphics): revert to v1.1.9 rendering defaults, fix UI lag
Reverts the aggressive GPU disabling introduced in v1.1.10/11 that caused severe UI lag for all users. The previous approach disabled WEBKIT_DISABLE_DMABUF_RENDERER globally (not just NVIDIA) because hardware_accel defaulted to false. New behavior (matches v1.1.9 targeted mitigations): - X11 non-NVIDIA: nothing disabled (full GPU acceleration) - X11 + NVIDIA: only DMA-BUF disabled - Wayland: compositing + DMA-BUF disabled (prevents EGL crashes) - Wayland + force_x11: runs as X11 (XWayland) - VM: software rendering via llvmpipe Improvement over v1.1.9: DMA-BUF now disabled for ALL Wayland GPUs (not just NVIDIA), which prevents the Intel Arc EGL crash from #59. All settings bypassable via env vars: - QBZ_HARDWARE_ACCEL=0 disables all GPU rendering (nuclear opt-out) - QBZ_HARDWARE_ACCEL=1 bypasses all safety (full GPU everywhere) - QBZ_FORCE_X11=1 forces XWayland backend - QBZ_FORCE_DMABUF=1 / QBZ_DISABLE_DMABUF=1 fine-grained DMA-BUF - QBZ_SOFTWARE_RENDER=1 forces Mesa llvmpipe Also adds GDK_SCALE and GDK_DPI_SCALE DB persistence for XWayland scaling (workaround from #67). cc
This commit is contained in:
1 parent
63abf1f90c
commit
31019d9b6a
4 files changed
+162
-49
No files matched your search
@@ -3,10 +3,14 @@
|
||||
//! Stores GPU/rendering preferences that take effect before WebView initialization.
|
||||
//! These settings are device-level (not per-user) and persist across sessions.
|
||||
//!
|
||||
//! - hardware_acceleration: opt-in GPU rendering (default: off)
|
||||
//! Env var QBZ_HARDWARE_ACCEL=1|0 always overrides the stored value.
|
||||
//! - force_x11: force X11/XWayland backend on Wayland sessions (default: off)
|
||||
//! Env var QBZ_FORCE_X11=1|0 always overrides the stored value.
|
||||
//! - gdk_scale / gdk_dpi_scale: display scaling overrides for XWayland
|
||||
//!
|
||||
//! Note: hardware_acceleration is kept in the DB for legacy compatibility but
|
||||
//! is no longer read at startup. GPU rendering defaults are now determined by
|
||||
//! auto-detection (Wayland/NVIDIA). Use QBZ_HARDWARE_ACCEL=0 env var to
|
||||
//! explicitly disable all GPU rendering.
|
||||
|
||||
use rusqlite::{Connection, params};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -14,17 +18,23 @@ use std::sync::{Arc, Mutex};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct GraphicsSettings {
|
||||
/// Enable hardware-accelerated rendering (requires restart)
|
||||
/// Legacy field (kept for DB compat, not used at startup anymore)
|
||||
pub hardware_acceleration: bool,
|
||||
/// Force X11 (XWayland) backend on Wayland sessions (requires restart)
|
||||
pub force_x11: bool,
|
||||
/// GDK_SCALE override for XWayland (None = auto). Integer values: "1", "2"
|
||||
pub gdk_scale: Option<String>,
|
||||
/// GDK_DPI_SCALE override for XWayland (None = auto). Float values: "0.5", "1", "1.5"
|
||||
pub gdk_dpi_scale: Option<String>,
|
||||
}
|
||||
|
||||
impl Default for GraphicsSettings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
hardware_acceleration: false,
|
||||
hardware_acceleration: true,
|
||||
force_x11: false,
|
||||
gdk_scale: None,
|
||||
gdk_dpi_scale: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,10 +64,16 @@ impl GraphicsSettingsStore {
|
||||
INSERT OR IGNORE INTO graphics_settings (id, hardware_acceleration) VALUES (1, 0);"
|
||||
).map_err(|e| format!("Failed to create graphics settings table: {}", e))?;
|
||||
|
||||
// Migration: add force_x11 column (no-op if already present)
|
||||
// Migrations: add columns (no-op if already present)
|
||||
let _ = conn.execute_batch(
|
||||
"ALTER TABLE graphics_settings ADD COLUMN force_x11 INTEGER NOT NULL DEFAULT 0;"
|
||||
);
|
||||
let _ = conn.execute_batch(
|
||||
"ALTER TABLE graphics_settings ADD COLUMN gdk_scale TEXT;"
|
||||
);
|
||||
let _ = conn.execute_batch(
|
||||
"ALTER TABLE graphics_settings ADD COLUMN gdk_dpi_scale TEXT;"
|
||||
);
|
||||
|
||||
Ok(Self { conn })
|
||||
}
|
||||
@@ -65,12 +81,14 @@ impl GraphicsSettingsStore {
|
||||
pub fn get_settings(&self) -> Result<GraphicsSettings, String> {
|
||||
self.conn
|
||||
.query_row(
|
||||
"SELECT hardware_acceleration, force_x11 FROM graphics_settings WHERE id = 1",
|
||||
"SELECT hardware_acceleration, force_x11, gdk_scale, gdk_dpi_scale FROM graphics_settings WHERE id = 1",
|
||||
[],
|
||||
|row| {
|
||||
Ok(GraphicsSettings {
|
||||
hardware_acceleration: row.get::<_, i64>(0)? != 0,
|
||||
force_x11: row.get::<_, i64>(1)? != 0,
|
||||
gdk_scale: row.get::<_, Option<String>>(2)?,
|
||||
gdk_dpi_scale: row.get::<_, Option<String>>(3)?,
|
||||
})
|
||||
},
|
||||
)
|
||||
@@ -96,6 +114,26 @@ impl GraphicsSettingsStore {
|
||||
.map_err(|e| format!("Failed to set force_x11: {}", e))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_gdk_scale(&self, value: Option<String>) -> Result<(), String> {
|
||||
self.conn
|
||||
.execute(
|
||||
"UPDATE graphics_settings SET gdk_scale = ?1 WHERE id = 1",
|
||||
params![value],
|
||||
)
|
||||
.map_err(|e| format!("Failed to set gdk_scale: {}", e))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_gdk_dpi_scale(&self, value: Option<String>) -> Result<(), String> {
|
||||
self.conn
|
||||
.execute(
|
||||
"UPDATE graphics_settings SET gdk_dpi_scale = ?1 WHERE id = 1",
|
||||
params![value],
|
||||
)
|
||||
.map_err(|e| format!("Failed to set gdk_dpi_scale: {}", e))?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// Thread-safe wrapper for Tauri state management
|
||||
@@ -149,3 +187,25 @@ pub fn set_force_x11(
|
||||
let store = guard.as_ref().ok_or("Graphics settings store not initialized")?;
|
||||
store.set_force_x11(enabled)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn set_gdk_scale(
|
||||
state: tauri::State<'_, GraphicsSettingsState>,
|
||||
value: Option<String>,
|
||||
) -> Result<(), String> {
|
||||
log::info!("[GraphicsSettings] Setting gdk_scale to {:?} (restart required)", value);
|
||||
let guard = state.store.lock().map_err(|e| format!("Lock error: {}", e))?;
|
||||
let store = guard.as_ref().ok_or("Graphics settings store not initialized")?;
|
||||
store.set_gdk_scale(value)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn set_gdk_dpi_scale(
|
||||
state: tauri::State<'_, GraphicsSettingsState>,
|
||||
value: Option<String>,
|
||||
) -> Result<(), String> {
|
||||
log::info!("[GraphicsSettings] Setting gdk_dpi_scale to {:?} (restart required)", value);
|
||||
let guard = state.store.lock().map_err(|e| format!("Lock error: {}", e))?;
|
||||
let store = guard.as_ref().ok_or("Graphics settings store not initialized")?;
|
||||
store.set_gdk_dpi_scale(value)
|
||||
}
|
||||
Reference in new issue
Block a user