twilio / video-quickstart-ios

Twilio Video Quickstart for iOS
https://www.twilio.com/docs/api/video
MIT License
461 stars 178 forks source link

Crash on startup when using ExampeAVAudioEngineDevice as AudioDevice #592

Open dericpr opened 3 years ago

dericpr commented 3 years ago

I've been working with @piyushtank on integrating the ExampleAVAudioEngineDevice into our Twilio based app and it's working great from the mixed audio standpoint, the major issue I currently have is that the application will randomly crash on startup sometimes when it creates an instance of ExampleAVAudioEngineDevice. It is not reproducible every time, but it happens much more frequently on the simulator then on an actual device, although it's happening on about 25% of launches on our testing hardware.

The crash occurs in the ExampleAVAudioEngineDevicePlayoutCallback and it ALWAYS happens when the system goes through the else path in the startRendering function below. The crash doesn't happen when the startup doesn't fall through this else path. I'm wondering if anyone has any insight into how we can lock down the startup sequence so it's not random in how it starts up so we don't end up crashing on startup.

My current version of the device file ( minimal changes made to export the AudioEngines )

`- (BOOL)startRendering:(nonnull TVIAudioDeviceContext)context { @synchronized(self) { NSLog(@"START RENDERING"); /*

dericpr commented 3 years ago

Just as a further piece of information it seems like if the device has a 48mhz microphone we end up in this crash scenario as the call to check if our current engineFormat matches the activeFormat fails ( engineFormat is 44100 ). On some devices these values match and on others they do not which causes the crash.

Any thoughts on how we can work around this?

spalmertwilio commented 3 years ago

@piyushtank this issue is linked to support request 5979254 and engineering VIDEO-4533.