NSRangeException on getAudioOutput
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)
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 ?
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
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;
```