{"record":{"id":"dfff375ec432f65f","repo":"cjpais/Handy","slug":"get-available-accelerators-panicked","errorCode":null,"errorMessage":"get_available_accelerators panicked","messagePattern":"get_available_accelerators panicked","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/src/shortcut/mod.rs","lineNumber":1404,"sourceCode":"pub fn change_transcribe_gpu_device(app: AppHandle, device: Option<String>) -> Result<(), String> {\n    let mut s = settings::get_settings(&app);\n    s.transcribe_gpu_device = device;\n    save_accelerator_and_reload_next_use(&app, s);\n    Ok(())\n}\n\n/// Return which accelerators and GPU devices are available for this build.\n///\n/// First-call cost is dominated by enumerating GPU devices through the\n/// transcribe.cpp Metal/Vulkan backend, which loads dynamic libraries and\n/// probes hardware. Run it on the blocking pool so the webview thread\n/// stays responsive — see also the startup pre-warm in `lib.rs`.\n#[tauri::command]\n#[specta::specta]\npub async fn get_available_accelerators() -> crate::managers::transcription::AvailableAccelerators {\n    tauri::async_runtime::spawn_blocking(crate::managers::transcription::get_available_accelerators)\n        .await\n        .expect(\"get_available_accelerators panicked\")\n}\n","sourceCodeStart":1386,"sourceCodeEnd":1406,"githubUrl":"https://github.com/cjpais/Handy/blob/fbd4e15fa14a721c66c57006ae110428b9e255b3/src-tauri/src/shortcut/mod.rs#L1386-L1406","documentation":"Panic when the spawn_blocking task running get_available_accelerators itself panics: awaiting the JoinHandle yields a JoinError with is_panic(), which this .expect converts into an abort of the awaiting task. The wrapped function enumerates ORT accelerators (transcribe-rs) and transcribe-cpp GPU devices, which loads Metal/Vulkan dynamic libraries and probes hardware — a panic inside those native layers bubbles out here.","triggerScenarios":"Invoking the get_available_accelerators Tauri command (settings UI or the lib.rs startup pre-warm) while native enumeration panics — typically a broken Vulkan ICD/loader or driver mismatch on Linux, or Metal problems on non-standard macOS setups. The panic payload is lost unless you inspect the JoinError.","commonSituations":"Broken or mismatched GPU drivers after an OS update; stale Vulkan loader with bad ICD configs; VMs or translation layers without a real GPU; a transcribe-cpp version regression that panics during device enumeration.","solutions":["Validate the graphics stack first: on Linux run vulkininfo/vulkaninfo and fix ICD/driver errors it reports; on other platforms update GPU drivers","Select the CPU accelerator in settings so GPU paths are not exercised (if enumeration still runs, keep the app but report the crash with logs)","Replace .expect with JoinError logging (downcast the panic payload) to capture the real panic message and backtrace","If it started after a dependency bump, pin/rollback the transcribe-cpp or transcribe-rs version"],"exampleFix":"// before\ntauri::async_runtime::spawn_blocking(crate::managers::transcription::get_available_accelerators)\n    .await\n    .expect(\"get_available_accelerators panicked\")\n\n// after — degrade to a CPU-only answer instead of aborting the command\nmatch tauri::async_runtime::spawn_blocking(\n    crate::managers::transcription::get_available_accelerators,\n)\n.await\n{\n    Ok(accels) => accels,\n    Err(e) => {\n        log::error!(\"accelerator enumeration failed: {e}\");\n        crate::managers::transcription::AvailableAccelerators::cpu_only()\n    }\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match tauri::async_runtime::spawn_blocking(\n    crate::managers::transcription::get_available_accelerators,\n)\n.await\n{\n    Ok(accels) => accels,\n    Err(join_err) => {\n        log::error!(\"accelerator enumeration panicked: {join_err}\");\n        // degrade: report CPU-only so the settings UI still works\n        cpu_only_accelerators()\n    }\n}","preventionTips":["Never .expect a JoinHandle from FFI-backed probes; always convert panics into a degraded answer","Wrap native GPU enumeration in catch_unwind at the source so a driver bug becomes a Result","Validate the Vulkan/Metal environment on test machines (vulkaninfo, Metal diagnostics) before running GPU-dependent paths"],"tags":["rust","tauri","gpu","vulkan","panic","async","spawn-blocking"],"backgroundTag":"gpu-enumeration-failed","analyzedSha":"fbd4e15fa14a721c66c57006ae110428b9e255b3","analyzedAt":"2026-08-17T10:29:55.597Z","contentChangedAt":"2026-08-17T10:29:55.597Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}