iOS14 Beta 1 Killing VoIP app because it failed to post an incoming call in time.

With iOS14 App I am seeing frequent crashes when send in an incoming call VOIP Push.

iOS is killing the App with the message

"Killing VoIP app because it failed to post an incoming call in time"

When SDK13 arrived we changed our code so as to avoid the iOS crash "terminateAppIfThereAreUnhandledVoIPPushes".

So we always offer the call to Callkit before we return from

pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(PKPushType)type withCompletionHandler:(void (^)(void))completion

and our App has worked fine with iOS13 versions.

So is this a new error "Killing VoIP app because it failed to post an incoming call in time" ??

I attach a log file snippet.

You can see from log file attached that I was about to offer the call to Callkit just after iOS killed it. There is 19 mSec gap between Push arriving and iOS killing the App.

default 19:36:42.598051 +0100 Our App MDS DEBUG => => => => => => New Push: Payload is [142],[Davemaj XS],[],[],[0]
...
...
error 19:36:42.600513 +0100 callservicesd Killing VoIP app mds.mds.appname.us2 because it failed to post an incoming call in time. 
...
...
default 19:36:42.617861 +0100 Our App MDS CALLKIT  => => => => => offerIncomingCallToCallkit from caller Davemaj XS {PBX:142}
I also see iOS killing the App Even BEFORE our App gets to run didReceiveIncomingPushWithPayload as can be seen from these 4 lines from console log


OUR PUSH ARRIVES
default 14:43:56.306168 +0100 apsd <APSCourier: 0x100e0d7d0>: Received message for enabled topic 'mds.mds.ourapp.us2.voip' onInterface: NonCellular with payload '{
aps =     {
        alert = "[1095],[Dave Maj Main],[],[],[0]";
    };
}' with priority (null) for device token: NO
....

iOS DECIDES TO KILL OUR APP after 28 mSec
error 14:43:56.334866 +0100 callservicesd Killing VoIP app mds.mds.ourapp.us2 because it failed to post an incoming call in time.
....

didReceiveIncomingPushWithPayload is run in the App but iOS has already decided to kill it

default 14:43:56.341304 +0100 Our App MDS DEBUG => => => => => => New Push: Payload is [1095],[Dave Maj Main],[],[],[0]
....

iOS kills our App
default 14:43:56.345273 +0100 runningboardd [application<mds.mds.ourapp.us2>:641] Terminating with context: <RBSTerminateContext| domain:10 code:0xBAADCA11 explanation:<no explanation given> reportType:CrashLog maxTerminationResistance:Interactive>


We have also been seeing this. We are unable to reproduce locally, but we have crash reports coming in that look the same, all on iOS 14, and we had a few on iOS 13.6 starting on about July 21st. The crashes have different stack traces, but all have the same tell tale failure reason. We have evidence of it working fine for a customer for 8 different consecutive calls sent via push, and on the ninth call, it failed the moment the push was sent to APNS from our backend.

We are also doing exactly what was required in iOS 13, reporting directly to CallKit the incoming call from the receipt of the push event. We have a minimal little bit of processing time to get the push event and get it ready for callkit (we have some validations and decryption, etc) but it directly gets to callkit in a synchronous flow. The stack traces show us failing about half way along this processing time. Depending on where it stops it, we get a different stack trace. We are both in the foreground and background.
While digging deeper it seems to me to be a threading issue.... I have a stack trace that shows:

Code Block
Thread 16 name:
Thread 16:
0 libsystem_kernel.dylib 0x00000001ad963504 kevent_id + 8
1 libdispatch.dylib 0x00000001ad80aff4 _dispatch_kq_poll + 228 (event_kevent.c:750)
2 libdispatch.dylib 0x00000001ad80ba94 _dispatch_event_loop_wait_for_ownership$VARIANT$armv81 + 436 (event_kevent.c:2203)
3 libdispatch.dylib 0x00000001ad801388 DISPATCH_WAIT_FOR_QUEUE + 312 (queue.c:1657)
4 libdispatch.dylib 0x00000001ad800f90 _dispatch_sync_f_slow + 140 (queue.c:1738)
5 PushKit 0x00000001c3f2c624 -[PKPushRegistry _noteIncomingCallReported] + 76 (PKPushRegistry.m:360)
6 CoreFoundation 0x00000001adac0cf8 CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER + 20 (CFNotificationCenter.c:706)
7 CoreFoundation 0x00000001adac0cb8 _CFXRegistrationPost_block_invoke + 48 (CFNotificationCenter.c:173)
8 CoreFoundation 0x00000001adac02b0 _CFXRegistrationPost + 400 (CFNotificationCenter.c:198)
9 CoreFoundation 0x00000001adabfca8 _CFXNotificationPost + 696 (CFNotificationCenter.c:1071)
10 Foundation 0x00000001ade6aa00 -[NSNotificationCenter postNotificationName:object:userInfo:] + 60 (NSNotification.m:575)
11 CallKit 0x00000001bd8bd708 -[CXProvider reportNewIncomingCallWithUUID:update:completion:] + 160 (CXProvider.m:221)
<10-20 redacted>
21 PushKit 0x00000001c3f2b554 73-[PKPushRegistry voipPayloadReceived:mustPostCall:withCompletionHandler:]_block_invoke + 400 (PKPushRegistry.m:175)
22 libdispatch.dylib 0x00000001ad81d298 _dispatch_call_block_and_release + 24 (init.c:1454)
23 libdispatch.dylib 0x00000001ad81e280 _dispatch_client_callout + 16 (object.m:559)
24 libdispatch.dylib 0x00000001ad7fa4fc _dispatch_lane_serial_drain$VARIANT$armv81 + 568 (inline_internal.h:2548)
25 libdispatch.dylib 0x00000001ad7fafe8 _dispatch_lane_invoke$VARIANT$armv81 + 404 (queue.c:3862)
26 libdispatch.dylib 0x00000001ad804808 _dispatch_workloop_worker_thread + 692 (queue.c:6590)
27 libsystem_pthread.dylib 0x00000001ad8755a4 _pthread_wqthread + 272 (pthread.c:2194)
28 libsystem_pthread.dylib 0x00000001ad878874 start_wqthread + 8

Which clearly is showing the push event calling the reportIncoming to the CXProvider, which then post a notification to the notification center which is picked up by the PKPushRegistry, noting that the incoming call was acknoledged. but at the same time on a different thread i have this:

Code Block
Last Exception Backtrace:
0 CoreFoundation 0x1adb5dea8 __exceptionPreprocess + 216 (NSException.m:199)
1 libobjc.A.dylib 0x1ad880f48 objc_exception_throw + 56 (objc-exception.mm:565)
2 CoreFoundation 0x1ada6d064 +[NSException raise:format:arguments:] + 96 (NSException.m:146)
3 Foundation 0x1adedbfc8 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 128 (NSException.m:231)
4 PushKit 0x1c3f2c5b4 -[PKPushRegistry _terminateAppIfThereAreUnhandledVoIPPushes] + 208 (PKPushRegistry.m:353)
5 libdispatch.dylib 0x1ad81e280 _dispatch_client_callout + 16 (object.m:559)
6 libdispatch.dylib 0x1ad7f6c04 _dispatch_continuation_pop$VARIANT$armv81 + 404 (inline_internal.h:2548)
7 libdispatch.dylib 0x1ad807474 _dispatch_source_invoke$VARIANT$armv81 + 1252 (source.c:570)
8 libdispatch.dylib 0x1ad7fa3c8 _dispatch_lane_serial_drain$VARIANT$armv81 + 260 (inline_internal.h:2589)
9 libdispatch.dylib 0x1ad7fafe8 _dispatch_lane_invoke$VARIANT$armv81 + 404 (queue.c:3862)
10 libdispatch.dylib 0x1ad804808 _dispatch_workloop_worker_thread + 692 (queue.c:6590)
11 libsystem_pthread.dylib 0x1ad8755a4 _pthread_wqthread + 272 (pthread.c:2194)
12 libsystem_pthread.dylib 0x1ad878874 start_wqthread + 8


which makes me think that the handling of checking if we are in a acknowledged state seems to not be thread safe, or there is some timer that has a super short fuse that is detonating even if the call was acknowleged.
We are still seeing this issue on iOS14 Beta 8

After some testing we have not seen it happen yet on iOS 13.7

I presume iOS14 will be released soon so I hope we can get some solution from Apple.

Are other developers seeing this?
Hi there,
Do you have any update on this issue ?
I got this issue with iOS 14 using Twilio SDK
Regards
Do someone have any update on this issue ?
I am facing same issue on iOS 14.4 any one handled this
iOS14 Beta 1 Killing VoIP app because it failed to post an incoming call in time.
 
 
Q