diff --git a/electron/stt/gpuDetector.ts b/electron/stt/gpuDetector.ts index f7aba344f..da6a72ee6 100644 --- a/electron/stt/gpuDetector.ts +++ b/electron/stt/gpuDetector.ts @@ -27,8 +27,10 @@ export interface ResolvedBinary { } /** - * Return the platform's default binary backend tag. This is only used for - * logging and as a fallback; the helper's response corrects it at runtime. + * Return the platform's default binary backend tag. The helper's response + * corrects it at runtime, with one exception: `whispercpp-cpu` makes + * `WhisperServerManager` launch the helper with `--cpu`, since the macOS x64 + * build still carries ggml's default-on Metal backend (#1594). */ export async function detectGpuBackend(): Promise { switch (process.platform) { diff --git a/electron/stt/whisperServer.test.ts b/electron/stt/whisperServer.test.ts index bd5796082..f29e72115 100644 --- a/electron/stt/whisperServer.test.ts +++ b/electron/stt/whisperServer.test.ts @@ -559,9 +559,16 @@ describe("WhisperServerManager", () => { expect(args).not.toContain("--cuda"); expect(args).not.toContain("--int8"); expect(args).not.toContain("--vad"); + // A CPU-labelled helper is CPU from the first launch: the macOS x64 build + // still carries ggml's default-on Metal backend (#1594). + expect(args).toContain("--cpu"); expect(args[args.indexOf("--threads") + 1]).toBe(String(inferenceThreads())); const os = await import("node:os"); expect(vi.mocked(os.default.setPriority)).toHaveBeenCalledWith(1234, 10); + + // An explicit binary with no backend is auto: its CPU default is a label only. + await new WhisperServerManager().start({ modelPath, binaryPath: fakeBinaryPath }); + expect(vi.mocked(spawn).mock.calls[1]?.[1]).not.toContain("--cpu"); } finally { vi.unstubAllGlobals(); } diff --git a/electron/stt/whisperServer.ts b/electron/stt/whisperServer.ts index dd75d8c99..e027603da 100644 --- a/electron/stt/whisperServer.ts +++ b/electron/stt/whisperServer.ts @@ -399,8 +399,16 @@ export class WhisperServerManager { return { port, backend: activeBackend }; }; + // A CPU-labelled helper runs with `--cpu` from its first launch. The label does + // not make the binary CPU-only: ggml turns Metal on by default for every Apple + // build, so the macOS x64 helper carries it, and without the flag whisper.cpp + // decodes on the Intel iGPU — which hung the UHD 630 render ring (#1594). + // An explicit `binaryPath` with no backend is auto: its CPU default above is only + // a label, so it does not force the flag. + const cpuLabelled = + (options.binaryPath ? options.backend : resolved.backend) === "whispercpp-cpu"; try { - return await launch(false); + return await launch(cpuLabelled); } catch (err) { const startupLog = `${err instanceof Error ? err.message : String(err)} ${this.stderrTail}`; const startupLines = startupLog.split(/\r?\n/);