audio_waveforms
audio_waveforms copied to clipboard
fix: 🐛 Prevent `nullptr == Tap()` crash on iOS during recorder stream start
Description
On iOS, starting the recorder bytes stream could crash with a fatal
nullptr == Tap() exception (issue #487).
RecorderBytesStreamEngine.attach() installed a tap on input bus 0 without
clearing any existing tap first. Two paths left a stale tap on the bus:
- A second
attach()call beforedetach()(re-start without teardown). - A prior
audioEngine.start()that threw — the tap was installed but never removed, leaking it onto the bus.
AVAudioEngine throws nullptr == Tap() when a tap is installed on a bus that
already has one, crashing the app.
This PR makes attach() reset prior state before installing:
- Stops the engine if running, removes any existing tap on bus 0, and resets
totalFrames. - On a failed
audioEngine.start(), removes the just-installed tap so it doesn't leak onto the bus and crash the nextattach().
No public API change.
Checklist
- [x] The title of my PR starts with a Conventional Commit prefix (
fix:,feat:,docs:etc). - [x] I have followed the Contributor Guide when preparing my PR.
- [ ] I have updated/added tests for ALL new/updated/fixed functionality.
- [ ] I have updated/added relevant documentation in
docsand added dartdoc comments with///. - [ ] I have updated/added relevant examples in
examplesordocs.
Breaking Change?
- [ ] Yes, this PR is a breaking change.
- [x] No, this PR is not a breaking change.
Related Issues
Closes #487