Skip to content

Fix force-unwrap crashes in TextDecoder.decodeText during live transcription#417

Open
William-Laverty wants to merge 1 commit intoargmaxinc:mainfrom
William-Laverty:fix/text-decoder-force-unwrap
Open

Fix force-unwrap crashes in TextDecoder.decodeText during live transcription#417
William-Laverty wants to merge 1 commit intoargmaxinc:mainfrom
William-Laverty:fix/text-decoder-force-unwrap

Conversation

@William-Laverty
Copy link

Summary

Replaces three force-unwraps in TextDecoder.decodeText that cause crashes during repeated rapid transcription calls (e.g., live transcription preview at ~200ms intervals).

Changes

Three force-unwraps replaced with guard let + descriptive WhisperError throws:

  1. decoderInputs.initialPrompt.last! (line 747) — crashes if initialPrompt is empty
  2. decoderOutput.logits! (line 683) — crashes if logits is nil during language detection
  3. decoderOutput.logits! (line 829) — crashes if logits is nil during main decoding loop

All three now throw WhisperError.transcriptionFailed with descriptive messages, allowing callers to handle errors gracefully instead of crashing.

Fixes

…dling

Three force-unwraps in TextDecoder could cause crashes during repeated rapid
transcription calls (e.g., live transcription preview at ~200ms intervals):

1. decoderInputs.initialPrompt.last! — crashes if initialPrompt is empty
2. decoderOutput.logits! (line 683) — crashes if logits is nil during language detection
3. decoderOutput.logits! (line 829) — crashes if logits is nil during main decoding loop

All three are replaced with guard-let statements that throw descriptive
WhisperError values, allowing callers to handle the error gracefully instead
of crashing.

Fixes argmaxinc#414
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TextDecoder.decodeText force-unwraps cause crashes during repeated live transcription

1 participant