fix(expo-audio-studio): Resolve iOS HW Format Mismatch Crash and Enhance Logging (#218)#220
Merged
Conversation
…ce format consistency checks
…o fallback to AAC and enhance documentation for platform-specific audio support
…cking and improve error handling
…for consistency across platforms
|
|
Nice catch on hardware format changes! I have a concern regarding the forced emissions in recovery... The current fallback tap block implementation has redundant data emission:
This causes duplicate data being sent to the delegate. Can't we rely solely on |
7 tasks
4 tasks
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.



Description
This pull request addresses a critical issue on iOS where the app crashes with a "Format mismatch" error (
com.apple.coreaudio.avfaudio: input HW format is invalid) during recording preparation, as reported in issue #218. The root cause was identified as a mismatch between the audio tap format and the hardware's actual input format, particularly when switching devices or resuming recording. Additionally, this PR improves logging consistency across platforms and enhances the iOS playground app for better debugging and validation.Purpose and Impact
inputNode.inputFormat) rather than relying on potentially inconsistent session or node output formats. This fix ensures stable recording across device changes (e.g., Bluetooth headsets) and resume operations.ExpoAudioStudioprefix, making it easier to filter and debug logs on both Android and iOS. Enhanced log messages provide better context for debugging recording, device management, and audio processing.AudioDevPlaygroundapp for testing and includes detailed logging instructions in theCONTRIBUTE.mdfile, enabling developers to validate recording behavior on iOS simulators and physical devices.Key Implementation Details
installTapWithHardwareFormatmethod inAudioStreamManager.swiftto queryinputNode.inputFormat(forBus: 0)just before installing the audio tap, ensuring compatibility with the hardware's actual format.ExpoAudioStreamModule.swiftto automatically fall back to AAC on iOS when Opus is requested, as Opus is not supported on iOS. This fallback is logged as a warning to inform developers.RecordingSettings.tsxto enforce AAC as the only compression format on iOS, with clear user feedback in the UI.ExpoAudioStudioprefix (e.g.,ExpoAudioStudio:AudioDeviceManager).Logger.swiftto include class names for better context.CONTRIBUTE.mdwith detailed instructions for filtering logs on both Android and iOS, including commands for viewing logs from theAudioDevPlaygroundapp.recording-config.mdto clarify platform-specific compression support (e.g., Opus not supported on iOS, automatic fallback to AAC).ISSUE_IOS.mdfor future reference.AudioDevPlaygroundapp for iOS testing, with instructions inCONTRIBUTE.mdfor viewing logs on simulators and physical devices.record.tsxto track configuration changes and re-prepare when necessary, reducing the likelihood of crashes due to stale configurations.Breaking Changes