A free, open source, and extensible speech-to-text application that works completely offline.
fix: throttle mic-level IPC to mitigate WebKitWebProcess memory leak (#1444)
Mahdi Rafatjahe2c72a25ff48
diff --git a/src-tauri/src/overlay.rs b/src-tauri/src/overlay.rsindex ae03bd74..bafb6f40 100644--- a/src-tauri/src/overlay.rs+++ b/src-tauri/src/overlay.rs@@ -1,7 +1,8 @@use crate::input;use crate::settings;use crate::settings::{OverlayPosition, OverlayStyle};-use std::sync::atomic::{AtomicBool, Ordering};+use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};+use std::time::{SystemTime, UNIX_EPOCH};use tauri::{AppHandle, Emitter, Manager, PhysicalPosition, PhysicalSize};#[cfg(not(target_os = "macos"))]@@ -58,6 +59,9 @@ fn overlay_dimensions(state: &str) -> (f64, f64) {}}+static LAST_MIC_LEVEL_EMIT: AtomicU64 = AtomicU64::new(0);+const EMIT_THROTTLE_MS: u64 = 33; // ~30 FPS+#[cfg(target_os = "macos")]const OVERLAY_TOP_OFFSET: f64 = 46.0;#[cfg(any(target_os = "windows", target_os = "linux"))]@@ -484,6 +488,20 @@ pub fn emit_levels(app_handle: &AppHandle, levels: &[f32]) {return;}+ // Throttle to ~30 FPS. Even with the overlay enabled, the raw audio+ // callback fires far faster than the UI needs; capping emission rate+ // cuts the per-frame `eval_script`/IPC volume that drives the wry+ // memory growth in issue #1279 (upstream tauri-apps/wry#1489).+ let now = SystemTime::now()+ .duration_since(UNIX_EPOCH)+ .unwrap_or_default()+ .as_millis() as u64;+ let last = LAST_MIC_LEVEL_EMIT.load(Ordering::Relaxed);+ if now.saturating_sub(last) < EMIT_THROTTLE_MS {+ return;+ }+ LAST_MIC_LEVEL_EMIT.store(now, Ordering::Relaxed);+// Target only the overlay window. In Tauri 2 both `AppHandle::emit`// and `WebviewWindow::emit` broadcast to all webviews; Tauri's// listener filter then skips webviews with no registered listener