mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-03-27 05:10:22 +08:00
fix(linux): disable WebKitGTK hardware acceleration to prevent white screen (#986)
On some Linux systems with AMD GPUs (e.g., AMD Cezanne/Radeon Vega), WebKitGTK's GPU process fails to initialize EGL, causing the app to show a white screen on startup. Root cause: `amdgpu_query_info(ACCEL_WORKING)` returns EACCES (-13), which causes EGL display creation to fail with EGL_BAD_PARAMETER, crashing the GPU process. Fix: Use WebKitGTK's `set_hardware_acceleration_policy(Never)` API to disable GPU acceleration on Linux, falling back to software rendering. This is applied at startup via Tauri's `with_webview` API. Co-authored-by: Naozhong AI <oursnoah@gmail.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -768,6 +768,21 @@ pub fn run() {
|
||||
restore_proxy_state_on_startup(&state).await;
|
||||
});
|
||||
|
||||
// Linux: 禁用 WebKitGTK 硬件加速,防止 EGL 初始化失败导致白屏
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
if let Some(window) = app.get_webview_window("main") {
|
||||
let _ = window.with_webview(|webview| {
|
||||
use webkit2gtk::{WebViewExt, SettingsExt, HardwareAccelerationPolicy};
|
||||
let wk_webview = webview.inner();
|
||||
if let Some(settings) = WebViewExt::settings(&wk_webview) {
|
||||
SettingsExt::set_hardware_acceleration_policy(&settings, HardwareAccelerationPolicy::Never);
|
||||
log::info!("已禁用 WebKitGTK 硬件加速");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 静默启动:根据设置决定是否显示主窗口
|
||||
let settings = crate::settings::get_settings();
|
||||
if let Some(window) = app.get_webview_window("main") {
|
||||
|
||||
Reference in New Issue
Block a user