fix(ios): reuse AVAudioEngine instance in rebuildAudioEngine to prevent owningEngine assertion crash#1014
Open
radko93 wants to merge 1 commit intosoftware-mansion:mainfrom
Conversation
…of creating new one Fixes a production iOS crash (SIGABRT) where the owningEngine assertion fires during interruption recovery. The old code detached nodes from the current engine, created a new AVAudioEngine, and reattached the same node objects — violating AVFAudio's ownership assumptions. This changes rebuildAudioEngine to keep the existing engine instance and only rebuild graph connections (disconnect/reconnect), avoiding cross-engine node reuse. Also removes redundant reset calls before rebuild since the method now resets internally.
Member
|
@radko93 Hey, thanks for the PR, this is a huge help in hardening the engine! 🙌 Although we won't be able to use it as it is - reusing the engine, will cause crash/issues for other audio paths (i.e. media services were reset system notification to name one). But i've included fixes for your issue in my pull request :) It needs some cleanup in the test code, but should be merged within a day or two, and available in nightly version shortly after. Although I can't promise when it will be released as an stable version or patch |
Author
|
@michalsek no worries, thanks for the update feel free to close this one and update the linked issues when it's fixed. |
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.
Closes #1013
Introduced changes
AudioEngine.mmto rebuild graph connections on the currentAVAudioEngineinstance instead of creating a new engine and re-attaching the same node objectsresetcalls beforerebuildAudioEngine, since rebuild now resets the current engine internallyAVAudioSourceNode/AVAudioSinkNodeinstances across differentAVAudioEngineinstances, which can trigger AVFAudio'sowningEngineassertionNotes for reviewers
packages/react-native-audio-api/ios/audioapi/ios/system/AudioEngine.mm.mainstill had the detach-create-reattach flow when this PR was prepared on 2026-04-10.AudioEngine.mm, but it still recreates the engine inrebuildAudioEngine, so it does not address this specificowningEngineassertion. If that PR lands first, this patch will probably need a small rebase.Checklist