diff --git a/CHANGELOG.md b/CHANGELOG.md index ab9ec20..19ad6a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). --- +## [0.4.26] — 2026-11-03 + +### Added + +- **Settings > Rendering > Disable hardware acceleration (Windows).** A workaround for a stutter affecting the whole display while WaveTrace has focus, seen so far on one PC with G-SYNC on. WaveTrace may feel slower and use more CPU with it on, so it's off by default. + +--- + ## [0.4.25] — 2026-11-02 ### Fixed diff --git a/package-lock.json b/package-lock.json index 19c5bc3..4158a5e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "wavetrace", - "version": "0.4.25", + "version": "0.4.26", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "wavetrace", - "version": "0.4.25", + "version": "0.4.26", "license": "MIT", "dependencies": { "@tauri-apps/api": "^2.12.4", diff --git a/package.json b/package.json index 6c1f2e8..f355618 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "wavetrace", "private": true, - "version": "0.4.25", + "version": "0.4.26", "license": "MIT", "type": "module", "scripts": { diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index d7547c1..86848f2 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -6106,7 +6106,7 @@ dependencies = [ [[package]] name = "wavetrace" -version = "0.4.25" +version = "0.4.26" dependencies = [ "arboard", "base64 0.22.1", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index d22e312..2f42ae7 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wavetrace" -version = "0.4.25" +version = "0.4.26" description = "WaveTrace — automatic per-wave tracking for The Tower" edition = "2021" license = "MIT" diff --git a/src-tauri/src/accounts.rs b/src-tauri/src/accounts.rs index a6acc15..f1deb33 100644 --- a/src-tauri/src/accounts.rs +++ b/src-tauri/src/accounts.rs @@ -324,6 +324,17 @@ pub fn spawn_and_replace(id: &str) -> Result<(), String> { Ok(()) } +/// Replace this process with a fresh one on the same account. +pub fn respawn_current() -> Result<(), String> { + let id = current_id().ok_or("No account is open.")?; + release_lock(); + if let Err(e) = spawn_with_account(&id) { + let _ = acquire_lock(&active_data_dir()); + return Err(e); + } + Ok(()) +} + fn release_lock() { if let Ok(mut slot) = INSTANCE_LOCK.lock() { *slot = None; diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index ed2389d..db7102a 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -204,6 +204,26 @@ pub fn save_settings(new_settings: Settings) -> Result<(), String> { Ok(()) } +#[tauri::command] +pub fn get_software_rendering() -> crate::webview_rendering::SoftwareRendering { + crate::webview_rendering::status() +} + +#[tauri::command] +pub fn set_software_rendering(enabled: bool) -> Result<(), String> { + crate::webview_rendering::save(enabled) +} + +#[tauri::command] +pub fn restart_app(app: AppHandle, state: State) -> Result<(), String> { + if state.scanner.is_running() { + return Err("Stop the scanner before restarting WaveTrace.".into()); + } + accounts::respawn_current()?; + crate::tray::exit_app(&app); + Ok(()) +} + #[tauri::command] pub fn send_test_ntfy(app: AppHandle) -> Result<(), String> { crate::notifications::send_test_ntfy(&app) diff --git a/src-tauri/src/debug_package.rs b/src-tauri/src/debug_package.rs index 2e28b2b..4fc6d51 100644 --- a/src-tauri/src/debug_package.rs +++ b/src-tauri/src/debug_package.rs @@ -325,7 +325,7 @@ pub fn build_debug_package_zip(input: &DebugPackageBuildInput) -> Result<(Vec Result<(Vec() { @@ -152,6 +156,9 @@ pub fn run() { commands::quit_app, commands::get_settings, commands::save_settings, + commands::get_software_rendering, + commands::set_software_rendering, + commands::restart_app, commands::send_test_ntfy, commands::get_ntfy_status, commands::clear_ntfy_rate_limit, diff --git a/src-tauri/src/renderer_recovery.rs b/src-tauri/src/renderer_recovery.rs index a1c8576..bb99663 100644 --- a/src-tauri/src/renderer_recovery.rs +++ b/src-tauri/src/renderer_recovery.rs @@ -168,16 +168,7 @@ mod windows { std::thread::sleep(Duration::from_millis(50)); } - let config = app - .config() - .app - .windows - .iter() - .find(|w| w.label == "main") - .cloned() - .ok_or("no \"main\" window in the app config")?; - let window = tauri::WebviewWindowBuilder::from_config(app, &config) - .map_err(|e| e.to_string())? + let window = crate::webview_rendering::main_window_builder(app)? .visible(false) .build() .map_err(|e| format!("building the new window: {e}"))?; diff --git a/src-tauri/src/webview_rendering.rs b/src-tauri/src/webview_rendering.rs new file mode 100644 index 0000000..e4b60c2 --- /dev/null +++ b/src-tauri/src/webview_rendering.rs @@ -0,0 +1,136 @@ +//! The "Disable hardware acceleration" option, for PCs where WebView2's GPU rendering makes +//! the whole display stutter while WaveTrace has focus. +//! +//! It's one choice per PC, not per account, because it describes the machine. WebView2 +//! refuses to start in a data folder whose running browser process has different flags, and +//! that browser process can briefly outlive a restart, so each mode has its own data folder. + +use std::fs; +use std::io::ErrorKind; +use std::path::Path; +use std::sync::OnceLock; + +use serde::Serialize; +use tauri::{AppHandle, WebviewWindowBuilder, Wry}; + +const SOFTWARE_RENDERING_FILE: &str = "software_rendering"; +/// Under the app's local data folder, where WebView2 keeps its default data folder too. +#[cfg(windows)] +const SOFTWARE_RENDERING_DATA_DIR: &str = "software-rendering"; +/// Setting browser args replaces wry's defaults, so they're repeated here. +#[cfg(windows)] +const SOFTWARE_RENDERING_BROWSER_ARGS: &str = + "--disable-gpu --disable-features=msWebOOUI,msPdfOOUI,msSmartScreenProtection"; + +/// The mode this process started in. Fixed for its lifetime: changing the saved choice only +/// applies on restart, and a window rebuilt after a crash has to stay in the same mode. +static ACTIVE: OnceLock = OnceLock::new(); + +#[derive(Debug, Serialize)] +pub struct SoftwareRendering { + /// Whether this platform has the option at all. + pub supported: bool, + /// The choice to apply on the next start. + pub saved: bool, + /// The mode this process is running in. + pub active: bool, +} + +pub fn status() -> SoftwareRendering { + SoftwareRendering { + supported: cfg!(windows), + saved: saved(), + active: active(), + } +} + +pub fn active() -> bool { + *ACTIVE.get_or_init(saved) +} + +fn saved() -> bool { + cfg!(windows) && read_choice(&crate::accounts::data_root()) +} + +pub fn save(enabled: bool) -> Result<(), String> { + if !cfg!(windows) { + return Err("This option is only available on Windows.".into()); + } + // Pin the running mode before the saved choice changes under it. + active(); + write_choice(&crate::accounts::data_root(), enabled).map_err(|e| e.to_string()) +} + +fn read_choice(root: &Path) -> bool { + root.join(SOFTWARE_RENDERING_FILE).exists() +} + +fn write_choice(root: &Path, enabled: bool) -> std::io::Result<()> { + let path = root.join(SOFTWARE_RENDERING_FILE); + if enabled { + return fs::write(path, ""); + } + match fs::remove_file(path) { + Err(e) if e.kind() != ErrorKind::NotFound => Err(e), + _ => Ok(()), + } +} + +/// The main window as configured, in the mode this process started in. +pub fn main_window_builder( + app: &AppHandle, +) -> Result, String> { + let config = app + .config() + .app + .windows + .iter() + .find(|w| w.label == "main") + .cloned() + .ok_or("no \"main\" window in the app config")?; + let builder = WebviewWindowBuilder::from_config(app, &config).map_err(|e| e.to_string())?; + #[cfg(windows)] + if active() { + use tauri::Manager; + let data_dir = app + .path() + .app_local_data_dir() + .map_err(|e| e.to_string())? + .join(SOFTWARE_RENDERING_DATA_DIR); + return Ok(builder + .additional_browser_args(SOFTWARE_RENDERING_BROWSER_ARGS) + .data_directory(data_dir)); + } + Ok(builder) +} + +#[cfg(test)] +mod tests { + use super::*; + + fn temp_root() -> std::path::PathBuf { + let dir = std::env::temp_dir().join(format!("wavetrace-render-{}", uuid::Uuid::new_v4())); + fs::create_dir_all(&dir).unwrap(); + dir + } + + #[test] + fn the_choice_is_off_until_saved_and_can_be_saved_twice() { + let root = temp_root(); + assert!(!read_choice(&root)); + write_choice(&root, true).unwrap(); + write_choice(&root, true).unwrap(); + assert!(read_choice(&root)); + write_choice(&root, false).unwrap(); + assert!(!read_choice(&root)); + fs::remove_dir_all(root).unwrap(); + } + + #[test] + fn turning_it_off_when_already_off_is_fine() { + let root = temp_root(); + write_choice(&root, false).unwrap(); + assert!(!read_choice(&root)); + fs::remove_dir_all(root).unwrap(); + } +} diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index f753a0d..a53aac7 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "WaveTrace", - "version": "0.4.25", + "version": "0.4.26", "identifier": "com.wavetrace.app", "build": { "beforeDevCommand": "npm run dev", @@ -12,6 +12,7 @@ "app": { "windows": [ { + "create": false, "title": "WaveTrace", "width": 1150, "height": 780, diff --git a/src/api.ts b/src/api.ts index fe02c2e..cc7504e 100644 --- a/src/api.ts +++ b/src/api.ts @@ -80,6 +80,15 @@ export interface Settings { capture_adb_device_id: string; } +export interface SoftwareRendering { + /** Whether this platform has the option at all. */ + supported: boolean; + /** The choice to apply on the next start. */ + saved: boolean; + /** The mode the app is running in. */ + active: boolean; +} + export interface AdbDeviceInfo { serial: string; /** Stable fingerprint (aid:.../avd:...); null when unreadable. */ @@ -269,6 +278,10 @@ export const api = { getSettings: () => invoke("get_settings"), saveSettings: (newSettings: Settings) => invoke("save_settings", { newSettings }), + getSoftwareRendering: () => invoke("get_software_rendering"), + setSoftwareRendering: (enabled: boolean) => + invoke("set_software_rendering", { enabled }), + restartApp: () => invoke("restart_app"), gameSaveStatus: () => invoke("game_save_status"), pullGameSave: () => invoke("pull_game_save"), pickSavePullDir: () => invoke("pick_save_pull_dir"), diff --git a/src/components/SettingsPage.tsx b/src/components/SettingsPage.tsx index 9c2bc10..2069ef6 100644 --- a/src/components/SettingsPage.tsx +++ b/src/components/SettingsPage.tsx @@ -9,6 +9,7 @@ import { NtfyStatusInfo, ScreenCaptureAccess, Settings, + SoftwareRendering, WindowInfo, } from "../api"; import { DATA_RESTORED_EVENT } from "../runRows"; @@ -111,6 +112,7 @@ function SettingsPage({ const [gameSaveDevices, setGameSaveDevices] = useState([]); const [devicesBusy, setDevicesBusy] = useState(false); const [waylandSession, setWaylandSession] = useState(false); + const [softwareRendering, setSoftwareRendering] = useState(null); const load = async () => { const [loadedSettings, listedWindows, access, dataPaths, wayland] = await Promise.all([ @@ -203,6 +205,22 @@ function SettingsPage({ return () => window.clearInterval(id); }, [probing]); + useEffect(() => { + api + .getSoftwareRendering() + .then(setSoftwareRendering) + .catch((e) => reportUiError(e, "Settings.softwareRendering", { alert: false })); + }, []); + + const toggleSoftwareRendering = async (current: SoftwareRendering, enabled: boolean) => { + try { + await api.setSoftwareRendering(enabled); + setSoftwareRendering({ ...current, saved: enabled }); + } catch (e) { + reportUiError(e, "Settings.softwareRendering"); + } + }; + const persistSettings = async (next: Settings) => { setSaveState("saving"); try { @@ -692,6 +710,43 @@ function SettingsPage({ + {softwareRendering?.supported && ( +
+

Rendering

+

+ Try this if your whole PC stutters while WaveTrace has focus, which can + happen with G-SYNC on for windowed apps. WaveTrace may feel slower and use + more CPU with it on. This applies to every account, and + view preferences such as collapsed panels are kept separately for each mode. +

+ + {softwareRendering.saved !== softwareRendering.active && ( +
+ Takes effect after WaveTrace restarts. + +
+ )} +
+ )} +

Tool export