Skip to content

Error: Audio Engine Error(Audio engine returned error code: -3010) #849

@luciana-ezcurra

Description

@luciana-ezcurra

Describe the bug

I’m unable to get the audio session or the video camera to work reliably when using
Room.localParticipant.setMicrophone(enabled:) and
Room.localParticipant.setCamera(enabled:) in LiveKit iOS SDK 2.9.0.

I need to publish media in H.264 to interoperate with Meta (Horizon / Workrooms).
Audio sometimes activates incorrectly, and video often fails to start or freezes at the first frame.

I have tried:

  • letting LiveKit manage the AVAudioSession automatically
  • providing my own AVAudioSession configuration (.playAndRecord, .voiceChat)
  • publishing video using:
    • setCamera(enabled: true)
    • LocalVideoTrack.createCameraTrack() + publish(videoTrack:)

None of these combinations provide consistent camera or audio activation.

Expected behavior

  • setCamera(enabled: true) should initialize camera, create the local video track, and publish it successfully.
  • setMicrophone(enabled: true) should activate recording without interfering with AVAudioSession.
  • Using RoomOptions with .h264 codec hint should reliably force H.264 encoding.

Actual behavior

  • Camera sometimes does not start at all.
  • When using my own AVAudioSession configuration, LiveKit throws audio-session activation errors.
  • When removing my configuration and letting LiveKit manage the session, audio still fails intermittently with:

Livekit Version
2.9.0/2.10.0 (both same issue)

xcode Version
16.2

Apple M3 pro

func connectToRoom(url: String, token: String, isVideoCall: Bool) async {
guard room == nil else { return }

    self.isVideoCall = isVideoCall

    // Crear Room
    let options = RoomOptions(
        defaultCameraCaptureOptions: CameraCaptureOptions(
            position: .front,
            dimensions: .h720_169,
            fps: 30
        ), defaultVideoPublishOptions:
            VideoPublishOptions(
            encoding: VideoEncoding(
                maxBitrate: 300_000, // 300 kbps
                maxFps: 30
            ),
            preferredCodec: .h264
        )
    )

    let newRoom = Room(delegate: self, roomOptions: options)  //if I just put Room() the error changes -> Error: Audio Engine Error(Audio engine returned error code: -9001). I already checked the mic and camera permissions.

    self.room = newRoom

    do {
        try await newRoom.connect(url: url, token: token)
        try await newRoom.localParticipant.setMicrophone(enabled: true)
        
        if isVideoCall {
            try await newRoom.localParticipant.setCamera(enabled: true)
        }
    } catch {
        print("Error: \(error.localizedDescription)")
    }
}

func configureAudioSession() { //just tried with this one with no luck
let audioSession = AVAudioSession.sharedInstance()
do {
try audioSession.setCategory(
.playAndRecord,
mode: .voiceChat,
options: [.defaultToSpeaker, .allowBluetooth, .allowBluetoothA2DP, .mixWithOthers]
)
try audioSession.setActive(true)
let isSpeaker = audioSession.currentRoute.outputs.contains { $0.portType == .builtInSpeaker }
print("Audio session configurada: (audioSession.currentRoute) (isSpeaker)")
} catch {
print("Error configurando audio session: (error.localizedDescription)")
}
}

Metadata

Metadata

Assignees

Labels

audiobugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions