fix: replace force-unwraps in TextDecoder with guard statements#421
Closed
William-Laverty wants to merge 1 commit intoargmaxinc:mainfrom
Closed
fix: replace force-unwraps in TextDecoder with guard statements#421William-Laverty wants to merge 1 commit intoargmaxinc:mainfrom
William-Laverty wants to merge 1 commit intoargmaxinc:mainfrom
Conversation
Replace three force-unwraps in TextDecoder.decodeText that cause crashes during rapid repeated transcription (e.g., live transcription preview): 1. decoderInputs.initialPrompt.last! (line 747) — crashes if prompt is empty 2. decoderOutput.logits! (line 683) — crashes if logits nil during language detection 3. decoderOutput.logits! (line 829) — crashes if logits nil during token decoding Now throws descriptive WhisperError instead of crashing, allowing callers to handle the error gracefully. Fixes argmaxinc#414
Contributor
|
Little confused why this was opened, it looks like you already have a PR open here with the same diff? #417 |
Author
|
Apologies for the duplicate — this is the same change as #417. Closing this one. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces three force-unwraps in
TextDecoder.decodeTextthat causeEXC_BREAKPOINTcrashes during rapid repeated transcription calls (e.g., live transcription preview at ~200ms intervals).Changes
decoderInputs.initialPrompt.last!guard let+throw WhisperError.decodingFaileddecoderOutput.logits!(language detection)guard let+throw WhisperError.decodingLogitsFaileddecoderOutput.logits!(token decoding)guard let+throw WhisperError.decodingLogitsFailedAll three now throw descriptive
WhisperErrorcases that already exist in the codebase, allowing callers to handle the error gracefully instead of crashing.Context
During sustained rapid transcription calls (5-10/sec for live preview), decoder state can degrade and hit these nil/empty conditions. The force-unwraps cause hard crashes instead of recoverable errors.
Fixes #414