iOS VoIP (Pushkit) app is crashing while in background, works ok in foreground

2.2k Views Asked by At

I am experiencing problem with my swift app, using PushKit / CallKit. It is a pure Swift, Xcode 13.1, testing with iOS 15 and iOS 14.7 (two physical devices) + php backend.

During the tests, I found my app is crashing on voice push receive event, all the time, if it is in background or not started. If it is in foreground, everything works perfectly, all cases and handled, pushes are OK, calls are being reported, app is working as expected. I assume it is because of [PKPushRegistry _terminateAppIfThereAreUnhandledVoIPPushes] + 192. Full crash log you can see below. Reproducing same behaviour with both sandbox (dev build from Xcode) and production (adhoc distribution build) apple APN urls.

My question is: how is it possible my app in foreground works OK (all pushes are reported to CallKit fine), while in the background it is failing to report something? Shouldn't it be all the same logic within one same method, func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) in my AppDelegate?

Is it the case I have to somehow specifically manage the app start, or enter foreground, when dealing with VoIP push?

I am struggling with it for 5 days already, any help here is highly appreciated!

A bit of a background: it is a WKWebView-based app, the PushKit part of it is about to initiate a video-call with the push send from server (the call itself it 100% running on web page, using Agora engine). The point here is just to let the app know if

  • call is about to start (e.g. someone is sitting on the web page and calling me)
  • call is changing it's state (e.g. for ex someone I am calling to had just accepted my call)
  • call was not answered, or rejected
  • call is ended (e.g. someone I'm talking to just hung up and left the conversation)

How I am handling it (brief logic description): receiving the push, checking it's payload, depending on it either starting a new call (reporting it to CallKit) or updating a call (I have one already reported to CallKit). Then, depending on the action field I have in my payload json, I am doing a variety of things - like (as said) starting the new call, accepting the call (e.g. move to some specific page in the web view), posting my status back to server, finishing the ongoing call et cetera.

In any case (it is important!) I am reporting ANY push to CallKit as a new call, answered elsewhere, rejected, ended etc.

Absolutely no cases I have where I am not reporting something to CallKit, but the one and only possible case - when the push I received has no field "action" in the payload (e.g. the push came to me is of unknown structure, misformed or corrupted). Now, having said that, I am thinking of also handling this case with CallKit, rejected or whatever alike, but anyway.

Date/Time:           2022-02-20 21:27:33.7032 +0300
Launch Time:         2022-02-20 21:27:33.6191 +0300
OS Version:          iPhone OS 15.2.1 (19C63)
Release Type:        User
Baseband Version:    2.23.02
Report Version:      104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Triggered by Thread:  0

Application Specific Information:
abort() called


Last Exception Backtrace:
0   CoreFoundation                         0x180bd50fc __exceptionPreprocess + 220
1   libobjc.A.dylib                        0x19940fd64 objc_exception_throw + 60
2   Foundation                             0x18248f3ac _userInfoForFileAndLine + 0
3   PushKit                                0x1b3a53d80 -[PKPushRegistry _terminateAppIfThereAreUnhandledVoIPPushes] + 192
4   libdispatch.dylib                      0x180847670 _dispatch_client_callout + 20
5   libdispatch.dylib                      0x1808568c4 _dispatch_lane_barrier_sync_invoke_and_complete + 56
6   PushKit                                0x1b3a52ee0 __73-[PKPushRegistry voipPayloadReceived:mustPostCall:withCompletionHandler:]_block_invoke + 540
7   libdispatch.dylib                      0x180845924 _dispatch_call_block_and_release + 32
8   libdispatch.dylib                      0x180847670 _dispatch_client_callout + 20
9   libdispatch.dylib                      0x180855b70 _dispatch_main_queue_callback_4CF + 944
10  CoreFoundation                         0x180b8dd84 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
11  CoreFoundation                         0x180b47f5c __CFRunLoopRun + 2540
12  CoreFoundation                         0x180b5b468 CFRunLoopRunSpecific + 600
13  GraphicsServices                       0x19c6e638c GSEventRunModal + 164
14  UIKitCore                              0x1834fd088 -[UIApplication _run] + 1100
15  UIKitCore                              0x18327b958 UIApplicationMain + 2092
16  Doctor                                 0x102eae2c8 main + 25288 (__hidden#331_:18)
17  dyld                                   0x10315daa4 start + 520

Thread 0 name:   Dispatch queue: com.apple.pushkit.ivarqueue
Thread 0 Crashed:
0   libsystem_kernel.dylib                 0x1b8271964 __pthread_kill + 8
1   libsystem_pthread.dylib                0x1f1ead378 pthread_kill + 268
2   libsystem_c.dylib                      0x18ba98f50 abort + 164
3   libc++abi.dylib                        0x199517bc4 abort_message + 132
4   libc++abi.dylib                        0x199508fd8 demangling_terminate_handler() + 332
5   libobjc.A.dylib                        0x199415e34 _objc_terminate() + 144
6   libc++abi.dylib                        0x199516f58 std::__terminate(void (*)()) + 20
7   libc++abi.dylib                        0x199516ef4 std::terminate() + 64
8   libdispatch.dylib                      0x180847684 _dispatch_client_callout + 40
9   libdispatch.dylib                      0x1808568c4 _dispatch_lane_barrier_sync_invoke_and_complete + 56
10  PushKit                                0x1b3a52ee0 __73-[PKPushRegistry voipPayloadReceived:mustPostCall:withCompletionHandler:]_block_invoke + 540
11  libdispatch.dylib                      0x180845924 _dispatch_call_block_and_release + 32
12  libdispatch.dylib                      0x180847670 _dispatch_client_callout + 20
13  libdispatch.dylib                      0x180855b70 _dispatch_main_queue_callback_4CF + 944
14  CoreFoundation                         0x180b8dd84 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
15  CoreFoundation                         0x180b47f5c __CFRunLoopRun + 2540
16  CoreFoundation                         0x180b5b468 CFRunLoopRunSpecific + 600
17  GraphicsServices                       0x19c6e638c GSEventRunModal + 164
18  UIKitCore                              0x1834fd088 -[UIApplication _run] + 1100
19  UIKitCore                              0x18327b958 UIApplicationMain + 2092
20  Doctor                                 0x102eae2c8 main + 25288 (__hidden#331_:18)
21  dyld                                   0x10315daa4 start + 520

Thread 1 name:   Dispatch queue: com.apple.network.connections
Thread 1:
0   libnetwork.dylib                       0x18198b820 nw_frame_create + 0
1   libnetwork.dylib                       0x18198e778 nw_channel_create_frame + 72
2   libnetwork.dylib                       0x1819758b4 nw_channel_create + 1116
3   libnetwork.dylib                       0x181996438 nw_channel_create_with_attributes + 288
4   libnetwork.dylib                       0x181839340 nw_endpoint_flow_attach_channel_protocol + 1332
5   libnetwork.dylib                       0x1819b6df8 nw_endpoint_flow_attach_protocols + 8780
6   libnetwork.dylib                       0x181836bc0 nw_endpoint_flow_setup_protocols + 3956
7   libnetwork.dylib                       0x18183ae38 nw_endpoint_flow_setup_channel + 1944
8   libnetwork.dylib                       0x18183120c -[NWConcrete_nw_endpoint_flow updatePathWithHandler:] + 2340
9   libnetwork.dylib                       0x18189539c nw_endpoint_handler_path_change + 1800
10  libnetwork.dylib                       0x181afc9cc __nw_endpoint_handler_initialize_association_block_invoke + 156
11  libnetwork.dylib                       0x181d0aa6c __nw_association_update_paths_block_invoke.81 + 92
12  libnetwork.dylib                       0x1818922e0 nw_hash_table_apply + 168
13  libnetwork.dylib                       0x181d0a37c nw_association_update_paths + 488
14  libnetwork.dylib                       0x18198d190 nw_path_necp_update_evaluator + 1996
15  libnetwork.dylib                       0x18196f340 nw_path_necp_check_for_updates + 876
16  libnetwork.dylib                       0x1818dd7b4 nw_path_evaluator_force_update + 128
17  libnetwork.dylib                       0x181d0d5b4 nw_association_force_update + 108
18  libnetwork.dylib                       0x18183c8b0 nw_endpoint_flow_setup_channel + 8720
19  libnetwork.dylib                       0x181832d8c -[NWConcrete_nw_endpoint_flow startWithHandler:] + 3608
20  libnetwork.dylib                       0x18189539c nw_endpoint_handler_path_change + 1800
21  libnetwork.dylib                       0x1818c2080 nw_endpoint_handler_start + 1096
22  libnetwork.dylib                       0x18182e9e0 nw_endpoint_resolver_start_next_child + 4168
23  libdispatch.dylib                      0x180845924 _dispatch_call_block_and_release + 32
24  libdispatch.dylib                      0x180847670 _dispatch_client_callout + 20
25  libdispatch.dylib                      0x180850dac _dispatch_workloop_invoke + 2092
26  libdispatch.dylib                      0x18085a1b8 _dispatch_workloop_worker_thread + 656
27  libsystem_pthread.dylib                0x1f1ea70f4 _pthread_wqthread + 288
28  libsystem_pthread.dylib                0x1f1ea6e94 start_wqthread + 8

Thread 2:
0   libsystem_pthread.dylib                0x1f1ea6e8c start_wqthread + 0

Thread 3:
0   libsystem_pthread.dylib                0x1f1ea6e8c start_wqthread + 0

Thread 4 name:  com.apple.uikit.eventfetch-thread
Thread 4:
0   libsystem_kernel.dylib                 0x1b826b504 mach_msg_trap + 8
1   libsystem_kernel.dylib                 0x1b826bb9c mach_msg + 76
2   CoreFoundation                         0x180b43738 __CFRunLoopServiceMachPort + 372
3   CoreFoundation                         0x180b47a2c __CFRunLoopRun + 1212
4   CoreFoundation                         0x180b5b468 CFRunLoopRunSpecific + 600
5   Foundation                             0x182377c94 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 236
6   Foundation                             0x1823b8dc8 -[NSRunLoop(NSRunLoop) runUntilDate:] + 92
7   UIKitCore                              0x183476230 -[UIEventFetcher threadMain] + 524
8   Foundation                             0x1823c740c __NSThread__start__ + 808
9   libsystem_pthread.dylib                0x1f1ea79a4 _pthread_start + 148
10  libsystem_pthread.dylib                0x1f1ea6ea0 thread_start + 8

Thread 5:
0   libsystem_pthread.dylib                0x1f1ea6e8c start_wqthread + 0

Thread 6 name:   Dispatch queue: com.apple.coreaudio.ASClientManager
Thread 6:
0   libsystem_kernel.dylib                 0x1b826b504 mach_msg_trap + 8
1   libsystem_kernel.dylib                 0x1b826bb9c mach_msg + 76
2   libdispatch.dylib                      0x1808660d0 _dispatch_mach_msg_send + 700
3   libdispatch.dylib                      0x18086596c _dispatch_mach_send_drain + 344
4   libdispatch.dylib                      0x180861eec _dispatch_mach_send_msg + 364
5   libdispatch.dylib                      0x1808621b4 _dispatch_mach_send_and_wait_for_reply + 304
6   libdispatch.dylib                      0x18086263c dispatch_mach_send_with_result_and_wait_for_reply + 56
7   libxpc.dylib                           0x1f1ecfb9c xpc_connection_send_message_with_reply_sync + 240
8   CoreFoundation                         0x180c04cd0 __104-[CFPrefsSearchListSource synchronouslySendDaemonMessage:andAgentMessage:andDirectMessage:replyHandler:]_block_invoke_2 + 40
9   CoreFoundation                         0x180bd17a8 -[_CFXPreferences withConnectionForRole:performBlock:] + 52
10  CoreFoundation                         0x180bf44cc __104-[CFPrefsSearchListSource synchronouslySendDaemonMessage:andAgentMessage:andDirectMessage:replyHandler:]_block_invoke + 140
11  CoreFoundation                         0x180c0cd60 CFPREFERENCES_IS_WAITING_FOR_SYSTEM_CFPREFSD + 100
12  CoreFoundation                         0x180c2b59c -[CFPrefsSearchListSource synchronouslySendDaemonMessage:andAgentMessage:andDirectMessage:replyHandler:] + 332
13  CoreFoundation                         0x180b828d4 -[CFPrefsSearchListSource alreadylocked_generationCountFromListOfSources:count:] + 232
14  CoreFoundation                         0x180b71db4 -[CFPrefsSearchListSource alreadylocked_getDictionary:] + 468
15  CoreFoundation                         0x180bd260c -[CFPrefsSearchListSource alreadylocked_copyValueForKey:] + 172
16  CoreFoundation                         0x180c39a08 -[CFPrefsSource copyValueForKey:] + 60
17  CoreFoundation                         0x180b73e2c __76-[_CFXPreferences copyAppValueForKey:identifier:container:configurationURL:]_block_invoke + 44
18  CoreFoundation                         0x180b933b8 __108-[_CFXPreferences(SearchListAdditions) withSearchListForIdentifier:container:cloudConfigurationURL:perform:]_block_invoke + 404
19  CoreFoundation                         0x180b6b3d8 normalizeQuintuplet + 356
20  CoreFoundation                         0x180b6445c -[_CFXPreferences withSearchListForIdentifier:container:cloudConfigurationURL:perform:] + 152
21  CoreFoundation                         0x180bc219c -[_CFXPreferences copyAppValueForKey:identifier:container:configurationURL:] + 168
22  CoreFoundation                         0x180b88588 _CFPreferencesCopyAppValueWithContainerAndConfiguration + 128
23  libAudioToolboxUtility.dylib           0x199da3b3c CACFPreferencesGetAppIntegerValue(__CFString const*, __CFString const*, bool*) + 28
24  AudioToolboxCore                       0x19399b28c GetMediaServerRPCTimeout() + 112
25  AudioToolbox                           0x18b6ec404 invocation function for block in AudioSessionClientManager::Instance() + 172
26  libdispatch.dylib                      0x180847670 _dispatch_client_callout + 20
27  libdispatch.dylib                      0x180848f18 _dispatch_once_callout + 32
28  AudioToolbox                           0x18b6ef660 invocation function for block in AudioSessionClientManager::CreatePrimaryClient(__CFRunLoop*, __CFString const*, void (*)(void*, unsigned int), void*) + 564
29  libdispatch.dylib                      0x180847670 _dispatch_client_callout + 20
30  libdispatch.dylib                      0x1808568c4 _dispatch_lane_barrier_sync_invoke_and_complete + 56
31  AudioToolbox                           0x18b6eea80 AudioSessionClient::InitializeAudioSessionClient(__CFRunLoop*, __CFString const*, void (*)(void*, unsigned int), void*, AudioSessionType, __CFString const*, unsigned int) + 832
32  AudioToolbox                           0x18b756d20 AudioSessionCreateSessionWithIdentifier_Priv + 552
33  AudioSession                           0x189f6d25c avfaudio::SessionConnector::Connect(AVAudioSession*, applesauce::CF::ObjectRef<__CFRunLoop*>, AudioSessionType, NSString*) + 128
34  AudioSession                           0x189f7595c -[AVAudioSession initWithSessionType:identifier:] + 304
35  AudioSession                           0x189f6d900 -[AVAudioSession initWithSessionType:] + 28
36  AudioSession                           0x189f6bcc0 __32+[AVAudioSession sharedInstance]_block_invoke + 72
37  libdispatch.dylib                      0x180847670 _dispatch_client_callout + 20
38  libdispatch.dylib                      0x180848f18 _dispatch_once_callout + 32
39  AudioSession                           0x189f6a0b4 +[AVAudioSession sharedInstance] + 156
40  CallKit                                0x1a6761ba8 __42-[CXProvider registerCurrentConfiguration]_block_invoke + 80
41  libdispatch.dylib                      0x180845924 _dispatch_call_block_and_release + 32
42  libdispatch.dylib                      0x180847670 _dispatch_client_callout + 20
43  libdispatch.dylib                      0x18084edf4 _dispatch_lane_serial_drain + 672
44  libdispatch.dylib                      0x18084f968 _dispatch_lane_invoke + 392
45  libdispatch.dylib                      0x18085a1b8 _dispatch_workloop_worker_thread + 656
46  libsystem_pthread.dylib                0x1f1ea70f4 _pthread_wqthread + 288
47  libsystem_pthread.dylib                0x1f1ea6e94 start_wqthread + 8

Thread 7:
0   libsystem_pthread.dylib                0x1f1ea6e8c start_wqthread + 0

Thread 8:
0   libsystem_pthread.dylib                0x1f1ea6e8c start_wqthread + 0

Thread 9 name:  AVAudioSession Notify Thread
Thread 9:
0   libsystem_kernel.dylib                 0x1b826b504 mach_msg_trap + 8
1   libsystem_kernel.dylib                 0x1b826bb9c mach_msg + 76
2   CoreFoundation                         0x180b43738 __CFRunLoopServiceMachPort + 372
3   CoreFoundation                         0x180b47a2c __CFRunLoopRun + 1212
4   CoreFoundation                         0x180b5b468 CFRunLoopRunSpecific + 600
5   AudioSession                           0x189f6e308 CADeprecated::GenericRunLoopThread::Entry(void*) + 164
6   AudioSession                           0x189f77d64 CADeprecated::CAPThread::Entry(CADeprecated::CAPThread*) + 92
7   libsystem_pthread.dylib                0x1f1ea79a4 _pthread_start + 148
8   libsystem_pthread.dylib                0x1f1ea6ea0 thread_start + 8


Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000000   x1: 0x0000000000000000   x2: 0x0000000000000000   x3: 0x0000000000000000
    x4: 0x000000019951b0ad   x5: 0x000000016cf562c0   x6: 0x000000000000006e   x7: 0x0000000000000a00
    x8: 0xdcc6cf154082bb6b   x9: 0xdcc6cf144399beeb  x10: 0x0000000000000002  x11: 0x000000000000000b
   x12: 0x000000009ac20840  x13: 0x000000001ac20800  x14: 0x0000000000000010  x15: 0x0000000000000002
   x16: 0x0000000000000148  x17: 0x00000001031b0580  x18: 0x000000013a10b940  x19: 0x0000000000000006
   x20: 0x0000000000000103  x21: 0x00000001031b0660  x22: 0x0000000282bf02a0  x23: 0x00000001cb4c4a4f
   x24: 0x0000000000000001  x25: 0x00000001deba8d50  x26: 0x00000001b3a55000  x27: 0x000000000000000f
   x28: 0x0000000002ffffff   fp: 0x000000016cf56230   lr: 0x00000001f1ead378
    sp: 0x000000016cf56210   pc: 0x00000001b8271964 cpsr: 0x40001000
   far: 0x00000001d79b1d58  esr: 0x56000080  Address size fault

Binary Images:
       0x1b826a000 -        0x1b829dfff libsystem_kernel.dylib arm64e  <eb3e47f3395335839feefb6cff8a8d7a> /usr/lib/system/libsystem_kernel.dylib
       0x1f1ea6000 -        0x1f1eb1fff libsystem_pthread.dylib arm64e  <c5c27e9d955739c9b9c65f6e7323ee1c> /usr/lib/system/libsystem_pthread.dylib
       0x18ba79000 -        0x18baf7fff libsystem_c.dylib arm64e  <f3afe30409793cba8338bebe9722ecd8> /usr/lib/system/libsystem_c.dylib
       0x199504000 -        0x19951dfff libc++abi.dylib arm64e  <71b1e39fb291315daf46a4343e707387> /usr/lib/libc++abi.dylib
       0x1993fa000 -        0x199433fff libobjc.A.dylib arm64e  <73e920f0e7ce394197d87a10dd2cd390> /usr/lib/libobjc.A.dylib
       0x180843000 -        0x180889fff libdispatch.dylib arm64e  <edd169e1d0db3808a19e99c1cd5a1c4c> /usr/lib/system/libdispatch.dylib
       0x1b3a4f000 -        0x1b3a57fff PushKit arm64e  <9765e782591a3b4e9ab26ed5e69627e8> /System/Library/Frameworks/PushKit.framework/PushKit
       0x180b3c000 -        0x180f8ffff CoreFoundation arm64e  <16faa70c278c3561859ecec407c2dc7c> /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
       0x19c6e5000 -        0x19c6edfff GraphicsServices arm64e  <064a1bb60e413ad2a402fb563fc141f5> /System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices
       0x182fe3000 -        0x18486dfff UIKitCore arm64e  <cd7f7ba2a2c63727aff69baab60cc6ab> /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore
       0x102ea8000 -        0x102fb3fff Doctor arm64  <4377121914133971bb4c82f325b3422e> /private/var/containers/Bundle/Application/80047B71-5198-40B8-B2C8-D9A66282ED40/Doctor.app/Doctor
       0x103144000 -        0x10319bfff dyld arm64e  <f94ccc7a6d1a33c7997ff611a6caa7e0> /usr/lib/dyld
       0x18181a000 -        0x1822e0fff libnetwork.dylib arm64e  <fb6fbf7c88273375a5006d440f277a49> /usr/lib/libnetwork.dylib
       0x18235f000 -        0x182665fff Foundation arm64e  <9618b2f2a4c23e07b7eed8d9e1bdeaec> /System/Library/Frameworks/Foundation.framework/Foundation
       0x1f1ec1000 -        0x1f1ef8fff libxpc.dylib arm64e  <4a0071bc1b1f3cbb960272663b72e875> /usr/lib/system/libxpc.dylib
       0x199d9f000 -        0x199dd2fff libAudioToolboxUtility.dylib arm64e  <670e8c2b1aaf3475a3dc3f64a81c41d0> /usr/lib/libAudioToolboxUtility.dylib
       0x19398a000 -        0x193c29fff AudioToolboxCore arm64e  <816c256e43313d5891ae7033a41f3790> /System/Library/PrivateFrameworks/AudioToolboxCore.framework/AudioToolboxCore
       0x18b5d2000 -        0x18b860fff AudioToolbox arm64e  <9dbb456d92123914a2eaa0a78f8df049> /System/Library/Frameworks/AudioToolbox.framework/AudioToolbox
       0x189f68000 -        0x189f91fff AudioSession arm64e  <8fa06a47169f3f56bc5b2ad366ad8f9e> /System/Library/PrivateFrameworks/AudioSession.framework/AudioSession
       0x1a671e000 -        0x1a679bfff CallKit arm64e  <74e4da77df3f30d09305318a76cfab7e> /System/Library/Frameworks/CallKit.framework/CallKit

EOF

Updated: when runnin in Xcode, I can see in the background app is receiving push and is attempting to manage it, sending status post back to server

REQUEST PARAMETERS ["call_id": "1045"]

And immediately after that I got

2022-02-21 08:52:04.259224+0300 Doctor[679:161536] Apps receving VoIP pushes must post an incoming call (via CallKit or IncomingCallNotifications) in the same run loop as   pushRegistry:didReceiveIncomingPushWithPayload:forType:[withCompletionHandler:] without delay.
2022-02-21 08:52:04.259413+0300 Doctor[679:161536] *** Assertion failure in -[PKPushRegistry _terminateAppIfThereAreUnhandledVoIPPushes], PKPushRegistry.m:353
2022-02-21 08:52:04.259838+0300 Doctor[679:161536] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Killing app because it never posted an incoming call to the system after receiving a PushKit VoIP push callback.'
*** First throw call stack:
(0x19ef6f25c 0x1b2d04480 0x19ee7cc98 0x1a01b4ef8 0x1c715370c 0x10542132c 0x105430520 0x1c715274c 0x10541fae8 0x10542132c 0x10542f76c 0x19eeee298 0x19eee86f8 0x19eee77d0 0x1b5629570 0x1a18142d0 0x1a181984c 0x1049e8f14 0x19ebc6140)
libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Killing app because it never posted an incoming call to the system after receiving a PushKit VoIP push callback.'
terminating with uncaught exception of type NSException

It is happening before my func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) completes.

When trying to set breakpoint in it, to preciously track the logic, I am receiving Terminated due to signal 9 from debugger immediately I do my first debug step.

Could it be somehow because of threading issue? I am posting my feedback to server with async, so probably it takes too long and the execution of didReceiveIncomingPushWith payload completes before I report my call?

1

There are 1 best solutions below

1
Andrey Lesnykh On

After some struggling, I was able to find the issue.

It was: when the push is received, I am checking for my call id to be valid with backend. It is obviously async, and it takes too long from background to handle, therefore iOS considering my app as "not reported the call in time".

I am not sure how do I manage the situation yet, but as for the issue itself - it is exactly because of my server call. Just commenting it out solved the issue completely.

TWIMC, if you're facing the same - check if you have any calls using async / closures in your PushRegistry didReceiveIncomingPushWith function code. It may help you to sort the issue out.