Skip to content

armgit / Handy

Public Imported from GitHub
0

A free, open source, and extensible speech-to-text application that works completely offline.

disable metal residency on macos

CJ Pais98a4d80cce8a
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index 2ddc5894..5c00deb7 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -588,6 +588,19 @@ fn run_headless_transcription(app: &AppHandle, args: &CliArgs) -> i32 {
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run(cli_args: CliArgs) {
+ // Avoid ggml-metal residency-set teardown assertions when a native engine
+ // outlives the Tauri shutdown sequence (#1902). This must happen before
+ // transcribe-cpp initializes its Metal device. Advanced users can restore
+ // upstream residency behavior with HANDY_METAL_RESIDENCY=1.
+ #[cfg(target_os = "macos")]
+ if std::env::var("HANDY_METAL_RESIDENCY").as_deref() == Ok("1") {
+ // ggml treats GGML_METAL_NO_RESIDENCY as presence-based, so remove an
+ // inherited value as well when explicitly opting back in.
+ std::env::remove_var("GGML_METAL_NO_RESIDENCY");
+ } else {
+ std::env::set_var("GGML_METAL_NO_RESIDENCY", "1");
+ }
+
// Pin glibc's dynamic mmap threshold before the first large allocation,
// so per-dictation transient buffers are returned to the OS on free
// instead of accumulating in malloc arenas (#1792). No-op off Linux/glibc.