You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: audio-mix and stop/start races in both publishers
Two pre-existing robustness gaps shared by RTMPPublisher and SessionPublisher,
surfaced by the issue #20 resilience review. Fixed in both via the shared layer.
1. App-audio mix went permanently silent if the mic route was dead from
go-live. HaishinKit renders the multitrack mix only when the MAIN track
(mic, track 0) appends; the mic-stall failover only promoted app audio to
the main track once the mic had appended at least once (`lastMicAppendAt >
0`), so a mic dead from the start never promoted and the whole mix — app
audio included — stayed silent forever. MicStallEvaluator now measures mic
silence from `startedAt` (go-live) when the mic has never appeared, so a
dead-from-start route still promotes app audio once the grace window passes.
The previously-working stall path is byte-for-byte unchanged (micReference ==
lastMicAppendAt when > 0).
2. stop() during start()'s pre-`isRunning` setup leaked long-lived tasks. Both
publishers ran their setup awaits (factory/mixer setup + startRunning) before
setting isRunning and spawning the path-supervisor / watchdog / frame-repeat
tasks; a stop() interleaving there early-returned via `guard isRunning`,
then start() resumed and spawned tasks it could never cancel (leaving a 2s
watchdog timer waking forever and the mixer running). Added a
`guard !userInitiatedStop` bail-out after mixer.startRunning in both, plus a
second re-check in RTMP after the two status awaits (a narrower window Session
doesn't have) so the supervisors/watchdog are never spawned post-teardown.
RTMP's normal go-live path is unchanged (both guards fire only on a concurrent
stop). Reviewed adversarially. StreamCore: 99 tests pass (+3 mic-stall cases);
full app builds against the iOS 27 SDK.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments