Description
Some of our iOS users intermittently encounter the following error when starting audio recording:
Failed to open file for writing: Invalid input format: sampleRate and channelCount must be greater than 0
This occurs despite the audio session being activated successfully (confirmed via our logs — setAudioSessionActivity(true) returns true).
Reproduction
Below is a simplified version of our recording flow:
AudioManager.setAudioSessionOptions({
iosCategory: "playAndRecord",
iosMode: "default",
iosOptions: ["defaultToSpeaker", "allowBluetoothHFP"],
});
await AudioManager.setAudioSessionActivity(true); // Returns true per our logs
// Delay to prevent empty voice note issue we observed previously
await delay(300);
recorder.enableFileOutput({
format: FileFormat.M4A,
preset: FilePreset.High,
});
const result = recorder.start({ fileNameOverride: `overridden_name_${Date.now()}` });
if (result.status === "error") {
throw new Error(result.message); // <-- Throws the error above
}
Environment
react-native-audio-api: 0.11.7
react-native: 0.79.6
Observations
- The error is intermittent — it does not happen on every recording attempt.
- The audio session is confirmed active before
recorder.start() is called.
- We already include a 300ms delay between session activation and recording to work around a separate issue with empty recordings.
Questions
- Is there a known scenario where
sampleRate or channelCount could be 0 even after a successful setAudioSessionActivity(true) call?
- Is there anything incorrect or missing in our implementation?
Any guidance would be appreciated. Thanks!
Description
Some of our iOS users intermittently encounter the following error when starting audio recording:
This occurs despite the audio session being activated successfully (confirmed via our logs —
setAudioSessionActivity(true)returnstrue).Reproduction
Below is a simplified version of our recording flow:
Environment
react-native-audio-api: 0.11.7react-native: 0.79.6Observations
recorder.start()is called.Questions
sampleRateorchannelCountcould be 0 even after a successfulsetAudioSessionActivity(true)call?Any guidance would be appreciated. Thanks!