You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Expo-AV在iOS设备上随机触发Session Activation Failed错误(错误码561017449)的问题排查与解决方案咨询

Expo-AV在iOS设备上随机触发Session Activation Failed错误(错误码561017449)的问题排查与解决方案咨询

我在一个裸React Native项目里用expo-av做音频录制功能,Android端跑起来完全没问题,但iOS端就很玄学——只有一半的概率能正常启动录制,剩下一半时间都会弹出错误:

prepare encountered an error: Error Domain=NSOSStatus error-Domain Code=561017449"Session Activation Failed"

(附错误截图:错误截图1显示Session Activation Failed提示;错误截图2展示相关错误详情)

我翻了好多资料,目前大概猜测是当设备上有其他App或者系统服务正在占用音频相关API的时候,就会触发这个错误。但尴尬的是,expo-av好像没有提供对应的API来提前检查音频服务是否可用,也没有处理这种冲突的机制。

有没有大佬能给我一些有用的排查思路或者解决方案呀?

下面是我用来启动录制的函数代码:

const startRecording = async () => {
    try {
      // Request microphone permissions
      if (permissionResponse.status !== 'granted') {
        console.log('Requesting permission..');
        await requestPermission();
      }

      // Prepare audio recording options
      await Audio.setAudioModeAsync({
        allowsRecordingIOS: true,
        playsInSilentModeIOS: true,
        interruptionModeIOS: InterruptionModeIOS.DoNotMix,
        interruptionModeAndroid: InterruptionModeAndroid.DoNotMix,
        playsInSilentModeIOS: true,
        staysActiveInBackground: true,
      });

      // Start recording
      const {recording} = await Audio.Recording.createAsync(
        Audio.RecordingOptionsPresets.HIGH_QUALITY,
      );
      setRecording(recording);
      setIsRecording(true);
      setIsPaused(false);
      console.log('Recording started');
    } catch (err) {
      Alert.alert('Failed to start Recording: ' + err?.message);
      console.error('Failed to start recording', err);
    }
  };

我使用的依赖版本如下:

  • "expo": "^52.0.0"
  • "expo-av": "~15.0.1"
  • "react": "18.3.1"
  • "react-native": "0.76.5"

备注:内容来源于stack exchange,提问作者Harjinder Singh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.14 14:49:50