react-native-callkeep icon indicating copy to clipboard operation
react-native-callkeep copied to clipboard

NSRangeException on getAudioOutput

Open endlessBacon opened this issue 2 years ago • 3 comments

Bug report

  • [x] I've checked the example to reproduce the issue.

  • Reproduced on:

  • [ ] Android

  • [x] iOS

Description

NSRangeException on getAudioOutput

Steps to Reproduce

Happens intermittently when working with audio sources

Versions

- Callkeep: 4.3.12
- React Native: 0.68.15
- iOS: 17.0.3
- Android:
- Phone model: iPhone 14 Pro

Logs

CoreFoundation +0x0ed5e0 __exceptionPreprocess
libobjc.A +0x02bbfc objc_exception_throw
CoreFoundation +0x0f8a48 -[__NSArray0 objectAtIndex:]
Mango Voice +0x24f8a8 +[RNCallKeep getAudioOutput] (RNCallKeep.m:192)
Mango Voice +0x24f540 -[RNCallKeep onAudioRouteChange:] (RNCallKeep.m:151)

endlessBacon avatar Oct 24 '23 19:10 endlessBacon

I'm facing also the same random issue on iPhone 13 Pro with following versions :

- Callkeep: 4.3.9
- React Native: 0.68.7
- iOS: 17.4.1

Did you find a more recent version that fixed it ? Or you also still struggle with it ?

ajantiss avatar May 07 '24 09:05 ajantiss

Nevermind, I see that a fix has been done somehow related to it : https://github.com/react-native-webrtc/react-native-callkeep/pull/772

I will try and let you now if it solves my issue

ajantiss avatar May 07 '24 09:05 ajantiss

if it doesn't work out, try copying the array before accessing. it can be modified by system from another thread

// system can alter outputs from another thread, copy before access to avoid crash:
    // *** -[__NSArray0 objectAtIndex:]: index 0 beyond bounds for empty array
    NSArray<AVAudioSessionPortDescription *> *outputs = [[AVAudioSession sharedInstance].currentRoute.outputs copy];
    AVAudioSessionPortDescription *firstOutput = [outputs firstObject];
    return firstOutput != nil ? firstOutput.portType : nil;
    ```

heyalexchoi avatar May 11 '24 00:05 heyalexchoi