Chunk offline audio decoding to prevent ONNX SIGTRAP crashes#7932
Conversation
- Limit offline STT audio decoding to bounded 30-second chunks rather than buffering the entire dictation and decoding in a single shot. - Avoid large allocations >= 2 GiB on long dictations that trigger Chromium's allocator shim to crash the app with a SIGTRAP (#7925). - Search the tail of each chunk for a quiet pause to split on, preventing mid-word cuts and preserving transcription accuracy.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR adds a new 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
This PR resolves
SIGTRAPout-of-memory crashes that occur during long offline dictation/speech-to-text (STT) sessions.Previously, the offline recognizer buffered all audio to decode in one single shot. For long recordings, ONNX Runtime's arena allocations scaled with buffer length, eventually hitting Chromium's 2 GiB allocation limit (#7925) and crashing the entire application.
This change introduces
OfflineAudioChunkerto break the audio stream into 30-second chunks before decoding. To prevent transcription degradation at boundary splits, it searches for quiet pauses (inter-word intervals) near the boundary.Screenshots
No visual change.
Testing
pnpm lintpnpm typecheckpnpm testpnpm buildAdded comprehensive unit tests in
stt-offline-audio-chunker.test.tscovering buffering, boundary limits, silence detection splits, value conservation, and empty flush behavior.AI Review Report
sherpa.createOfflineStream(recognizer)) to keep the recognizer's internal state isolated and correct.Security Audit
Notes
The 2 GiB Chromium allocation limit is a platform-level constraint affecting all Chromium/Electron environments. This worker-level chunking bypasses the restriction uniformly without requiring complex environment configurations.