react-native-webrtc / react-native-callkeep

iOS CallKit framework and Android ConnectionService for React Native
ISC License
923 stars 445 forks source link

call keep crash : index 0 beyond bounds for empty array #755

Closed fukemy closed 6 months ago

fukemy commented 11 months ago

Bug report

Description

Fatal Exception: NSRangeException *** -[__NSArray0 objectAtIndex:]: index 0 beyond bounds for empty array

Steps to Reproduce

answer the call then got this error

Versions

- Callkeep: 4.3.12
- React Native: 0.72.5
- iOS: 17.0.3
- Android: NO
- Phone model: IOS

Logs

Fatal Exception: NSRangeException
*** -[__NSArray0 objectAtIndex:]: index 0 beyond bounds for empty array
0
CoreFoundation
__exceptionPreprocess
2
CoreFoundation
-[__NSArray0 objectEnumerator]
3
VedaxLink
RNCallKeep.m - Line 182
+[RNCallKeep getAudioOutput] + 182
4
VedaxLink
RNCallKeep.m - Line 141
-[RNCallKeep onAudioRouteChange:] + 141
5
CoreFoundation
__CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__
20
UIKitCore
UIApplicationMain
21
VedaxLink
main.m - Line 8
main + 8
22
(Missing)
fukemy commented 9 months ago

any solution????????

CaptainJeff commented 9 months ago

Same issue here

fukemy commented 9 months ago

@CaptainJeff use my code to solve this:

+ (NSString *) getAudioOutput {
//    return [AVAudioSession sharedInstance].currentRoute.outputs.count > 0 ? [AVAudioSession sharedInstance].currentRoute.outputs[0].portType : nil;
    @try{
        NSArray<AVAudioSessionPortDescription *>* outputs = [AVAudioSession sharedInstance].currentRoute.outputs;
        if(outputs != nil && outputs.count > 0){
            return outputs[0].portType;
        }
        return nil;
    }@catch(NSException* anException) {
        NSLog(@"getAudioOutput error :%@", [anException description]);
        return nil;
    }
}
h4rshil commented 7 months ago

We are getting same issue,

Pikkurthi commented 1 month ago

I got this same error in Expo, I am using eas to build the project, How to fix this in expo?