Files
thoughtsync/desktop/src-tauri/src/lib.rs
T
bvandeusenandClaude Opus 4.8 3f5b87682e
Desktop (Tauri) / Tauri desktop (Linux) (push) Successful in 3m12s
issue 2021: harden Linux WebKit rendering (fixes black AppImage window)
WebKitGTK's DMA-BUF/EGL renderer fails to init on many Linux GPU/driver/Wayland
setups -> 'EGL_BAD_PARAMETER' -> black window (known WebKitGTK issue, not app code).
Per Tauri's Linux-graphics guidance, set the software-fallback env vars at startup
before the webview is created, scoped to AppImage launches (native installs keep GPU
accel): __NV_DISABLE_EXPLICIT_SYNC / WEBKIT_DISABLE_DMABUF_RENDERER /
WEBKIT_DISABLE_COMPOSITING_MODE, each only if the user already set it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FRgehjoz7Yv8LkUfADxACm
2026-07-24 14:38:27 -04:00

55 lines
2.3 KiB
Rust

//! ThoughtSync desktop (Tauri v2).
//!
//! The window loads the shared Vue 3 frontend (`../../frontend`). The Rust core will
//! own the on-device SQLite store (M10.4) and the opt-in sync engine (M10.7), which
//! the frontend reaches through the `frontend/src/adapters/` seam (M10.3) over Tauri
//! `invoke`. Today it exposes desktop integration (menu-entry install for the Linux
//! AppImage) and boots the UI.
mod integration;
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
#[cfg(target_os = "linux")]
harden_linux_webkit_rendering();
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![
integration::integration_status,
integration::integrate_desktop,
integration::unintegrate_desktop,
])
.run(tauri::generate_context!())
.expect("error while running the ThoughtSync desktop app");
}
/// WebKitGTK's GPU-accelerated rendering (the DMA-BUF renderer + EGL compositing) fails
/// to initialize on a wide range of Linux GPU/driver/Wayland setups — "Could not create
/// default EGL display: EGL_BAD_PARAMETER" → a black/blank window. This is a well-known
/// WebKitGTK issue that hits Tauri apps broadly, NOT app-specific. Tauri's guidance
/// (https://v2.tauri.app/develop/debug/linux-graphics/) is to force the software
/// fallbacks at startup, before the webview is created, so end users don't have to.
///
/// We apply the fix ONLY for AppImage launches (where these failures cluster and where
/// bundled libs are in play), leaving each var overridable — native (.deb) installs use
/// system libs and keep GPU acceleration untouched. WebKit software rendering is plenty
/// for this UI.
#[cfg(target_os = "linux")]
fn harden_linux_webkit_rendering() {
let is_appimage =
std::env::var_os("APPIMAGE").is_some() || std::env::var_os("APPDIR").is_some();
if !is_appimage {
return;
}
// Ordered per Tauri's escalation ladder; each set only if the user hasn't chosen.
for (key, value) in [
("__NV_DISABLE_EXPLICIT_SYNC", "1"),
("WEBKIT_DISABLE_DMABUF_RENDERER", "1"),
("WEBKIT_DISABLE_COMPOSITING_MODE", "1"),
] {
if std::env::var_os(key).is_none() {
std::env::set_var(key, value);
}
}
}