client-sdk-swift icon indicating copy to clipboard operation
client-sdk-swift copied to clipboard

Answering call with callkit when App is in background and the phone is locked, there is no audio.

Open sanketns opened this issue 2 years ago • 12 comments

when the app is in background and the phone is locked. There is no audio of opponent user. Tried every possible way but no luck. Kindly guide me for the same.

sanketns avatar Feb 14 '23 12:02 sanketns

Hi @sanketns I would be happy to investigate, if you could prepare a minimal reproducible example simulating your issue.

hiroshihorie avatar Feb 15 '23 05:02 hiroshihorie

Getting these errors in console randomly, see if you can get any hints from this if possible.

ATAudioSessionPropertyManager.mm:359 FAILED to set property 1684431725 on AVAudioSession with error Error Domain=NSOSStatusErrorDomain Code=-50 "(null)"

AURemoteIO.cpp:1679 AUIOClient_StartIO failed (561015905)

sanketns avatar Feb 15 '23 06:02 sanketns

Hello @hiroshihorie, I’m experiencing the same issue. When I create a room (in my case, start a call), if I immediately go to the background without waiting for the video/audio section to be initialized, I encounter these errors:

AURemoteIO.cpp:2087 AURemoteIO@0x10b025c40: IOThread exiting with error 0x10004006 AURemoteIO.cpp:1702 AUIOClient_StartIO failed (561145187)

Otherwise, if I wait a couple of seconds and the audio/video initializes before going to the background, everything works fine.


raphaelalkamim avatar Feb 12 '24 13:02 raphaelalkamim

@raphaelalkamim , may be it's related to audio session configuration while making a call. By the way, are you doing this with callkit?

sanketns avatar Feb 14 '24 09:02 sanketns

@sanketns , Yes, it might be related to the audio session configuration during calls. I'm currently using the default LiveKit configuration and CallKit solely for managing the call display.

raphaelalkamim avatar Feb 14 '24 15:02 raphaelalkamim

@raphaelalkamim , Are you doing something when these below functions get called?

func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession){

} func provider(_ provider: CXProvider, didDeactivate audioSession: AVAudioSession) {

}

sanketns avatar Feb 15 '24 05:02 sanketns

@sanketns No, I'm not using these delegates at all. Should I configure something beyond the LiveKit default configuration?

raphaelalkamim avatar Feb 15 '24 09:02 raphaelalkamim

Hi any solution to fix this . I am experiencing same when using callKit? @hiroshihorie @sanketns

ajayz7 avatar Apr 01 '24 10:04 ajayz7

Yes, I have the same situation. Is there any solution

liuyang2211 avatar Jul 08 '24 12:07 liuyang2211

alright according to the team, the iOS SDK doesn't support background mode. Screenshot 2024-07-30 at 1 22 33 AM

zackzhuang1996 avatar Jul 29 '24 17:07 zackzhuang1996

@zackzhuang1996 that's the react native sdk, which is separate from this swift sdk.

@sanketns For CallKit, the didActivate and didDeactivate methods should be implemented as follows:

  1. Add import LiveKitWebRTC to your CallProvider file.

func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession){
    LKRTCAudioSession.sharedInstance().audioSessionDidActivate(audioSession)
    // ...
}
func provider(_ provider: CXProvider, didDeactivate audioSession: AVAudioSession) {    
    LKRTCAudioSession.sharedInstance().audioSessionDidDeactivate(audioSession)
    // ...
}

davidliu avatar Aug 15 '24 05:08 davidliu

I have the same error when I answer with callkit. Also I received this message: AudioManager.defaultConfigureAudioSessionFunc(newState:oldState:) Failed to configure audio session with error: Error Domain=NSOSStatusErrorDomain Code=1701737535 "Session activation failed" UserInfo={NSLocalizedDescription=Session activation failed}

EDIT:

On the first call, there is incoming audio in the background. There is no incoming audio on the second and subsequent calls. At the same time, the other party can hear me all the time.

Could be problem here: audioSessionDidDeactivate?

Viktorianec avatar Sep 04 '24 14:09 Viktorianec