Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,17 @@ pub fn run(cli_args: CliArgs) {

initialize_core_logic(&app_handle);

// Pre-warm GPU/accelerator enumeration on a background thread.
// The first call into transcribe_rs::whisper_cpp::gpu::list_gpu_devices
// loads the Metal/Vulkan backend and probes devices, which can take
// several seconds. Without this, that cost is paid synchronously the
// first time the user opens the Advanced settings page (which calls
// the get_available_accelerators command), causing a UI freeze.
// Result is cached in a OnceLock inside the transcription manager.
std::thread::spawn(|| {
let _ = crate::managers::transcription::get_available_accelerators();
});

// Hide tray icon if --no-tray was passed
if cli_args.no_tray {
tray::set_tray_visibility(&app_handle, false);
Expand Down
11 changes: 9 additions & 2 deletions src-tauri/src/shortcut/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1143,8 +1143,15 @@ pub fn change_whisper_gpu_device(app: AppHandle, device: i32) -> Result<(), Stri
}

/// Return which accelerators and GPU devices are available for this build.
///
/// First-call cost is dominated by enumerating GPU devices through the
/// whisper.cpp Metal/Vulkan backend, which loads dynamic libraries and
/// probes hardware. Run it on the blocking pool so the webview thread
/// stays responsive — see also the startup pre-warm in `lib.rs`.
#[tauri::command]
#[specta::specta]
pub fn get_available_accelerators() -> crate::managers::transcription::AvailableAccelerators {
crate::managers::transcription::get_available_accelerators()
pub async fn get_available_accelerators() -> crate::managers::transcription::AvailableAccelerators {
tauri::async_runtime::spawn_blocking(crate::managers::transcription::get_available_accelerators)
.await
.expect("get_available_accelerators panicked")
}
5 changes: 5 additions & 0 deletions src/bindings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,11 @@ async changeWhisperGpuDevice(device: number) : Promise<Result<null, string>> {
},
/**
* Return which accelerators and GPU devices are available for this build.
*
* First-call cost is dominated by enumerating GPU devices through the
* whisper.cpp Metal/Vulkan backend, which loads dynamic libraries and
* probes hardware. Run it on the blocking pool so the webview thread
* stays responsive — see also the startup pre-warm in `lib.rs`.
*/
async getAvailableAccelerators() : Promise<AvailableAccelerators> {
return await TAURI_INVOKE("get_available_accelerators");
Expand Down
Loading