Skip to content

fix: 🐛 Prevent nullptr == Tap() crash on iOS during recorder stream start#496

Open
lavigarg-simform wants to merge 1 commit into
mainfrom
fix/I487_ios_crash_audio_bytes
Open

fix: 🐛 Prevent nullptr == Tap() crash on iOS during recorder stream start#496
lavigarg-simform wants to merge 1 commit into
mainfrom
fix/I487_ios_crash_audio_bytes

Conversation

@lavigarg-simform

@lavigarg-simform lavigarg-simform commented Jun 19, 2026

Copy link
Copy Markdown

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:

  1. A second attach() call before detach() (re-start without teardown).
  2. 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 next attach().

No public API change.

Checklist

  • The title of my PR starts with a Conventional Commit prefix (fix:, feat:, docs: etc).
  • 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 docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

Related Issues

Closes #487

@lavigarg-simform lavigarg-simform marked this pull request as ready for review June 19, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant