fix(settings): use --disable-gpu-compositing to keep webview renderable

This commit is contained in:
xintaofei
2026-04-25 16:32:47 +08:00
parent acc0cb3f06
commit 560b3083f0

View File

@@ -54,11 +54,15 @@ mod tauri_app {
/// libraries like reqwest/rustls that read `HTTP_PROXY` etc. /// libraries like reqwest/rustls that read `HTTP_PROXY` etc.
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
fn apply_webview2_rendering_override() { fn apply_webview2_rendering_override() {
// Only `--disable-gpu`. Pairing it with `--disable-software-rasterizer` // Use `--disable-gpu-compositing` rather than `--disable-gpu`:
// removes the SwiftShader fallback and produces a white-screen webview // - `--disable-gpu` forces SwiftShader software rendering, which fails
// on machines where GPU init fails — leaving no renderer at all. Match // to initialize on a non-trivial subset of Windows + GPU driver
// Electron's `app.disableHardwareAcceleration()` behavior. // combinations and leaves the webview entirely blank.
const DISABLE_GPU_ARGS: [&str; 1] = ["--disable-gpu"]; // - `--disable-gpu-compositing` only disables the GPU compositor (the
// path that triggers the AMD/Intel black-screen bug) while keeping
// GPU rasterization. This is the same flag Electron's
// `app.disableHardwareAcceleration()` ultimately injects.
const DISABLE_GPU_ARGS: [&str; 1] = ["--disable-gpu-compositing"];
const ENV_KEY: &str = "WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS"; const ENV_KEY: &str = "WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS";
let prefs = crate::preferences::load(); let prefs = crate::preferences::load();