twilio / voice-quickstart-objc

Twilio Voice Quickstart for iOS with Objective-C
MIT License
39 stars 24 forks source link

[3.0] How to avoid AVAudioSessionErrorCodeMissingEntitlement #160

Closed MarcoCatalan closed 5 years ago

MarcoCatalan commented 5 years ago

Before filing an issue please check that the issue is not already addressed by the following:

Please ensure that you are not sharing any Personally Identifiable Information(PII) or sensitive account information (API keys, credentials, etc.) when reporting an issue.

Description

In previous version of this library (2.X), there was a workarround on reportNewIncomingCallWithUUID which called [TwilioVoice configureAudioSession]; According to https://forums.developer.apple.com/message/169511 this is done there instead of on performAnswerCallAction to avoid a race condition which throws a AVAudioSessionErrorCodeMissingEntitlement.

This workaround is no longer present on the 3.X code samples, and I found that something very similar occurs, when I receive a call, sometimes I get no audio.

Steps to Reproduce

  1. Receive a call
  2. Answer the call

Code

I am testing this with my own code, forked from this quickstart, but with no significant differences. I believe this issue would also affect the quickstart sample code

Expected Behavior

The call should have audio

Actual Behavior

The call has no audio

Reproduces How Often

About 70% of the times I tested

Logs

2019-04-15 13:04:23.563982+0200 MyApp[847:1612157] Accepting call
2019-04-15 13:04:23.599281+0200 MyApp[847:1612157] INFO:Twilio:[Core]:Creating peer connection signaling thread ...
2019-04-15 13:04:23.599732+0200 MyApp[847:1612157] INFO:Twilio:[Core]:Creating peer connection worker thread ...
2019-04-15 13:04:23.599904+0200 MyApp[847:1612157] INFO:Twilio:[Core]:Creating peer connection networking thread ...
2019-04-15 13:04:23.600088+0200 MyApp[847:1612157] INFO:Twilio:[Core]:Creating media engine ...
2019-04-15 13:04:23.600873+0200 MyApp[847:1612157] INFO:Twilio:[Core]:Done creating media engine.
2019-04-15 13:04:23.601031+0200 MyApp[847:1612157] INFO:Twilio:[Core]:Creating peer connection factory ...
2019-04-15 13:04:23.605843+0200 MyApp[847:1612157] INFO:Twilio:[Core]:Done creating peer connection factory.
2019-04-15 13:04:23.606361+0200 MyApp[847:1612157] INFO:Twilio:[Core]:Adding audio track ...
2019-04-15 13:04:23.614889+0200 MyApp[847:1612157] WARN:Twilio:[Platform]:Current sample rate (44100.00) is not the preferred rate (48000.00)
2019-04-15 13:04:23.619807+0200 MyApp[847:1612157] ERROR:Twilio:[Platform]:AVAudioSession setActive Error Domain=NSOSStatusErrorDomain Code=1701737535 "(null)"
2019-04-15 13:04:23.624563+0200 MyApp[847:1612157] WARN:Twilio:[Platform]:Current sample rate (44100.00) is not the preferred rate (48000.00)
2019-04-15 13:04:23.630963+0200 MyApp[847:1612157] INFO:Twilio:[Core]:Creating dedicated notifier queue ...
2019-04-15 13:04:23.639826+0200 MyApp[847:1612157] INFO:Twilio:[Core]:Creating peer connection ...
2019-04-15 13:04:23.643114+0200 MyApp[847:1612157] INFO:Twilio:[Core]:Adding local stream to peer connection ...
2019-04-15 13:04:23.661042+0200 MyApp[847:1612345] INFO:Twilio:[Core]:Looking up: chunderm.gll.twilio.com
2019-04-15 13:04:23.763418+0200 MyApp[847:1612345] INFO:Twilio:[Core]:Setting outbound proxy to: sip:35.157.205.11:443;transport=tls
2019-04-15 13:04:23.805864+0200 MyApp[847:1612157] INFO:Twilio:[Platform]:Inside publishConnectionEvent:, event type: accepted-by-local
2019-04-15 13:04:24.133491+0200 MyApp[847:1612157] INFO:Twilio:[Platform]:Inside publishConnectionEvent:, event type: accepted-by-remote
2019-04-15 13:04:24.228780+0200 MyApp[847:1612192] [] nw_connection_get_connected_socket_block_invoke 20 Connection has no connected handler
2019-04-15 13:04:24.274336+0200 MyApp[847:1612157] callInviteCanceled
2019-04-15 13:04:24.270742+0200 MyApp[847:1612346] [aurioc] 892: failed: 'ent?' (enable 3, outf< 1 ch,  44100 Hz, Int16> inf< 1 ch,  44100 Hz, Int16>)
2019-04-15 13:04:24.494627+0200 MyApp[847:1612346] [aurioc] 892: failed: 'ent?' (enable 3, outf< 1 ch,  44100 Hz, Int16> inf< 1 ch,  44100 Hz, Int16>)
2019-04-15 13:04:24.601881+0200 MyApp[847:1612346] [aurioc] 892: failed: 'ent?' (enable 3, outf< 1 ch,  44100 Hz, Int16> inf< 1 ch,  44100 Hz, Int16>)
2019-04-15 13:04:24.708282+0200 MyApp[847:1612346] [aurioc] 892: failed: 'ent?' (enable 3, outf< 1 ch,  44100 Hz, Int16> inf< 1 ch,  44100 Hz, Int16>)
2019-04-15 13:04:24.812219+0200 MyApp[847:1612346] [aurioc] 892: failed: 'ent?' (enable 3, outf< 1 ch,  44100 Hz, Int16> inf< 1 ch,  44100 Hz, Int16>)
2019-04-15 13:04:24.823550+0200 MyApp[847:1612345] INFO:Twilio:[Core]:Looking up: 35.156.191.217
2019-04-15 13:04:25.204953+0200 MyApp[847:1612157] Call accepted

Versions

Voice iOS SDK

3.0.0-beta8

Xcode

10.1

iOS Version

10.3.3

iOS Device

iPhone 5c

bobiechen-twilio commented 5 years ago

Hi @MarcoCanalcar

I've tried the CallKit quickstart but couldn't reproduce the audio issue. My environments: the latest Voice iOS SDK, iPhone 7+, iOS 12.2.

Back to your original question, the 3.0 SDK does have the equivalent code to configure the audio device and AVAudioSession in preparation of the outgoing or incoming calls. For more information please check out the CallKit migration (2.0 to 3.0) guide.

Thanks, -bobie

MarcoCatalan commented 5 years ago

Hello @bchen-twilio,

Thanks for looking into this, I will try replicating the issue with the quickstart code and report my results.

MarcoCatalan commented 5 years ago

Hello, It seems that after testing with the quickstart it works fine. I'll close the issue since it seems to be something in my code.

Thanks!