12 Replies
      Latest reply on Nov 8, 2016 8:26 AM by RCP
      tpnpgo Level 1 Level 1 (0 points)

        If the device is locked the provider callback for - (void)provider:(CXProvider *)provider didActivateAudioSession:(AVAudioSession *)audioSession is never called when trying to answer a call using CallKit (bug 28549610). This happens when the app state is backgrounded or force closed. However, if the device is not locked CallKit works perfectly in both app states. I've also noticed that any attempts to answer incoming calls after the initial "failure" (failure is in quotes because there are no errors given to my application) will succeed. To rule out exceptions, back audio unit/session management and anything my code may be doing wrong, I've disabled all my business logic and have still reproduced the issue.


        Has anyone run into similar issues?

         

        • Re: Callkit Not Activating Audio Session Consistently
          bubble Level 1 Level 1 (10 points)

          Did you make sure to configure your audio session (i.e. set its category to PlayAndRecord and its mode to VoiceChat or VideoChat) before you answer or start a call?

            • Re: Callkit Not Activating Audio Session Consistently
              tpnpgo Level 1 Level 1 (0 points)

              Yes, I'm setting up the AudioSession just like the SpeakerBox sample. I'm not getting any errors from any of the session setup, and everything works in most cases. Just the initial call while locked seems to have the issue.

               

              
                          NPLogDebug(@"configuring audio session..");
                          [audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:&err];
                          if (err) {
                              NPLogError(@"error setting audio category %@",err);
                          }
                          [[AVAudioSession sharedInstance] setMode:AVAudioSessionModeVoiceChat error:&err];
                          if (err) {
                              NPLogError(@"error setting audio Mode %@",err);
                          }
                          double sampleRate = 44100.0;
                          [audioSession setPreferredSampleRate:sampleRate error:&err];
                          if (err) {
                              NPLogError(@"Error %ld, %@",(long)err.code, err.localizedDescription);
                          }
                          /
                          NSTimeInterval bufferDuration = .005;
                          [audioSession setPreferredIOBufferDuration:bufferDuration error:&err];
                          if (err) {
                              NPLogError(@"Error %ld, %@",(long)err.code, err.localizedDescription);
                          }
              
                          [action fulfill];
              
            • Re: Callkit Not Activating Audio Session Consistently
              tpnpgo Level 1 Level 1 (0 points)

              After providing Apple more logs by request, they've mark my issue as a "Duplicate of 27823760 (Open)" I checked openradar to see if anyone posted it there, but no luck.

              • Re: Callkit Not Activating Audio Session Consistently
                paynerc Level 1 Level 1 (0 points)

                I am seeing a similar issue, but I am not sure it is exactly the same.

                 

                What I am seeing is that upon a fresh launch of the application, the first time I try to accept an incoming call by way of call kit, `provider:didActivateAudioSession:` is never invoked. If I make an outgoing call, everything works and subsequent incoming calls work. So it mainly appears to be an issue when the app first launches?

                 

                I initially thought it was an issue with the code that reaches out to our infrastructure and the media layer. So to try and troubleshoot this a bit more, I went back to the Speakerbox sample app.

                 

                When I start the app fresh, and make an outbound call with CallKit, I get `provider:didActivateAudioSession:` invoked. Then I used their simulate button using the local notification to start an incoming call and... it worked... I was a little surprised because that was not the experience that I was expecting. I then thought about the differences and realized that, yes, to test this in the exact same way as my application, I will need to have the app notified via a VoIP push. So I set up a VoIP cert for Speakerbox and fired off a push. And low and behold, I get the same behavior as in my app. I do NOT get the `provider:didActivateAudioSession:` callback and I see this in the logs:

                 

                Configuring audio session
                2016-10-13 16:13:46.096232 Speakerbox[7252:1785573] [aurioc] 889: failed: 'ent?' (enable 3, outf< 1 ch,  44100 Hz, Float32> inf< 1 ch,  44100 Hz, Float32>)
                2016-10-13 16:13:46.096288 Speakerbox[7252:1785573] Error returned from setupIOUnit: 1701737535: couldn't initialize Apple Voice Processing IO instance
                
                
                  • Re: Callkit Not Activating Audio Session Consistently
                    smontgomery Apple Staff Apple Staff (30 points)

                    Hi paynerc,

                     

                    I am investigating the issue reported in Radar # 28774388. I believe it may be a duplicate of a known issue, and if it is this issue I suspect, then a workaround would be to configure your app's audio session (call `configureAudioSession()`) earlier in your app's lifecycle, before the `-provider:performAnswerCallAction:` method is invoked. For instance, you could call `configureAudioSession()` immediately before calling `-[CXProvider reportNewIncomingCallWithUUID:update:completion:]` in order to ensure that the audio session is fully configured prior to informing CallKit about the incoming call.

                     

                    I know that the Speakerbox sample app does not do it this way (it calls `configureAudioSession()` from within `-provider:performAnswerCallAction:`), but once we fix this known issue in CallKit, that existing Speakerbox code should work as it was originally intended and this issue should no longer reproduce. In the meantime, this workaround may fix the issue.

                     

                    Can you give that workaround a try?

                     

                    Thanks,
                    Stuart

                  • Re: Callkit Not Activating Audio Session Consistently
                    RCP Level 1 Level 1 (0 points)

                    I am seeing a similar issue, but I am not sure it is exactly the same.

                     

                    What I am seeing is that upon a fresh launch of the application, the first time I try to accept an incoming call by way of call kit, `provider:didActivateAudioSession:` is never invoked. If I make an outgoing call, everything works and subsequent incoming calls work. So it mainly appears to be an issue when the app first launches?

                     

                    I initially thought it was an issue with the code that reaches out to our infrastructure and the media layer. So to try and troubleshoot this a bit more, I went back to the Speakerbox sample app.

                     

                    When I start the app fresh, and make an outbound call with CallKit, I get `provider:didActivateAudioSession:` invoked. Then I used their simulate button using the local notification to start an incoming call and... it worked... I was a little surprised because that was not the experience that I was expecting. I then thought about the differences and realized that, yes, to test this in the exact same way as my application, I will need to have the app notified via a VoIP push. So I set up a VoIP cert for Speakerbox and fired off a push. And low and behold, I get the same behavior as in my app. I do NOT get the `provider:didActivateAudioSession:` callback and I see this in the logs:

                     

                    Configuring audio session
                    2016-10-13 16:13:46.096232 Speakerbox[7252:1785573] [aurioc] 889: failed: 'ent?' (enable 3, outf< 1 ch,  44100 Hz, Float32> inf< 1 ch,  44100 Hz, Float32>)
                    2016-10-13 16:13:46.096288 Speakerbox[7252:1785573] Error returned from setupIOUnit: 1701737535: couldn't initialize Apple Voice Processing IO instance
                    
                    
                      • Re: Callkit Not Activating Audio Session Consistently
                        smontgomery Apple Staff Apple Staff (30 points)

                        Do you have the 'Audio, AirPlay, and Picture in Picture' Background Mode enabled in the Capabilities tab for your app target in Xcode? I believe the 'ent?' error you mentioned can be caused by missing that background mode.

                         

                        If you still see this issue, I'd recommend filing a bug report at http://bugreport.apple.com

                          • Re: Callkit Not Activating Audio Session Consistently
                            tpnpgo Level 1 Level 1 (0 points)

                            And to you Mr. Montgomery, you've replied to two post that are either from bots or people that didn't read beyond the first step of building a VOIP application. When will you respond to the true issue. The following code in does not activate the audio session 100% of the time when called from within the handler for VOIP push. When this happens, our call is connected at the signaling layer, however there is no media because didActivateAudioSession doesn't get called.

                             

                            
                                AVAudioSession *audioSession = [AVAudioSession sharedInstance];
                                NSError* err;
                                NPLogDebug(@"configuring audio session..");
                                [audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:&err];
                                if (err) {
                                    NPLogError(@"error setting audio category %@",err);
                                }
                                [audioSession setMode:AVAudioSessionModeVoiceChat error:&err];
                                if (err) {
                                    NPLogError(@"error setting audio Mode %@",err);
                                }
                                double sampleRate = 44100.0; /
                                [audioSession setPreferredSampleRate:sampleRate error:&err];
                                if (err) {
                                    NPLogError(@"Error %ld, %@",(long)err.code, err.localizedDescription);
                                }
                                /
                                NSTimeInterval bufferDuration = .005; /
                                [audioSession setPreferredIOBufferDuration:bufferDuration error:&err];
                                if (err) {
                                    NPLogError(@"Error %ld, %@",(long)err.code, err.localizedDescription);
                                }
                              
                                [self.provider reportNewIncomingCallWithUUID:callId update:incomingCall completion:^(NSError * _Nullable error) {
                            
                          • Re: Callkit Not Activating Audio Session Consistently
                            tpnpgo Level 1 Level 1 (0 points)

                            you litterally copy and pasted the post from paynerc. what are you a bot or somthing?