Crash on iOS 15 devices happens mostly in background

Hi,

Our application is currently crashing in production, only for users with iPhone and iPad running iOS and iPadOS 15 through all releases. Unfortunately, we cannot reproduce the issue, neither through direct build from Xcode or using build from app store, so it seems to happen intermittently.

From third party crash analytics, it seems to happens mostly of background and they highlighted this as the issue.

Fatal Exception: NSInvalidArgumentException
-[_NSXPCDistantObject cleanupWithCompletionHandler:]: unrecognized selector sent to instance 0x2813293b0

From the Xcode crashlogs, it highlighted this which intrigue me a bit and it also exists on the stack trace from the third party (you can see they call a same function __cleanupWithCompletionHandler there).

5 Pegasus __58-[PGPictureInPictureProxy __cleanupWithCompletionHandler:]_block_invoke

It seems that the crash happens probably because some process related to PIP feature that triggered this function that is handled by Pegasus framework.

Any idea why this happens and is there anything i can do to prevent the crashes from happening again ?

Incident Identifier: 8B8EC2B3-E494-4407-8EC3-EF2796F210C9
Hardware Model:      iPhone14,5
Process:             Test [863]
Path:                /private/var/containers/Bundle/Application/95ADD6D4-4822-4899-A2C3-D8E360C3F3B6/Test.app/Test
Identifier:          com.Apple.Test
Version:             5.69.0 (1376)
AppStoreTools:       13C90b
AppVariant:          1:iPhone14,5:15
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd [1]
Coalition:           com.Apple.Test [712]

Date/Time:           2022-01-05 03:24:42.7538 +0700
Launch Time:         2022-01-05 01:07:51.5724 +0700
OS Version:          iPhone OS 15.1.1 (19B81)
Release Type:        User
Baseband Version:    1.15.05
Report Version:      104

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

Last Exception Backtrace:
0   CoreFoundation                	0x180e6d04c __exceptionPreprocess + 220 (NSException.m:200)
1   libobjc.A.dylib               	0x1994e1f54 objc_exception_throw + 60 (objc-exception.mm:565)
2   CoreFoundation                	0x180f4a014 -[NSObject(NSObject) doesNotRecognizeSelector:] + 144 (NSObject.m:147)
3   CoreFoundation                	0x180e02474 ___forwarding___ + 1728 (NSForwarding.m:3577)
4   CoreFoundation                	0x180e015b0 _CF_forwarding_prep_0 + 96
5   Pegasus                       	0x1a4ac88ac __58-[PGPictureInPictureProxy __cleanupWithCompletionHandler:]_block_invoke + 272 (PGPictureInPictureProxy.m:1240)
6   libdispatch.dylib             	0x180add914 _dispatch_call_block_and_release + 32 (init.c:1517)
7   libdispatch.dylib             	0x180adf660 _dispatch_client_callout + 20 (object.m:560)
8   libdispatch.dylib             	0x180ae6de4 _dispatch_lane_serial_drain + 672 (inline_internal.h:2601)
9   libdispatch.dylib             	0x180ae7958 _dispatch_lane_invoke + 392 (queue.c:3937)
10  libdispatch.dylib             	0x180af21a8 _dispatch_workloop_worker_thread + 656 (queue.c:6727)
11  libsystem_pthread.dylib       	0x1f19f60f4 _pthread_wqthread + 288 (pthread.c:2541)
12  libsystem_pthread.dylib       	0x1f19f5e94 start_wqthread + 8

Thread 0 name:
Thread 0:
0   libsystem_kernel.dylib        	0x00000001b7e0c504 mach_msg_trap + 8
1   libsystem_kernel.dylib        	0x00000001b7e0cb9c mach_msg + 76 (mach_msg.c:119)
2   CoreFoundation                	0x0000000180ddb688 __CFRunLoopServiceMachPort + 372 (CFRunLoop.c:2646)
3   CoreFoundation                	0x0000000180ddf97c __CFRunLoopRun + 1212 (CFRunLoop.c:3000)
4   CoreFoundation                	0x0000000180df33b8 CFRunLoopRunSpecific + 600 (CFRunLoop.c:3268)
5   GraphicsServices              	0x000000019c78338c GSEventRunModal + 164 (GSEvent.c:2200)
6   UIKitCore                     	0x00000001837936a8 -[UIApplication _run] + 1100 (UIApplication.m:3493)
7   UIKitCore                     	0x00000001835127f4 UIApplicationMain + 2092 (UIApplication.m:5046)
8   ---                           	0x0000000104a93ccc main + 68 (MarkSeenNotification.swift:35)
9   dyld                          	0x0000000106649a24 start + 520 (dyldMain.cpp:876)

Thread 1 name:
Thread 1:
0   libsystem_kernel.dylib        	0x00000001b7e0cf90 __psynch_cvwait + 8
1   libsystem_pthread.dylib       	0x00000001f19fd254 _pthread_cond_wait + 1228 (pthread_cond.c:636)
2   libc++.1.dylib                	0x000000019957bddc std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 28 (__threading_support:437)
3   JavaScriptCore                	0x000000018cf141d4 void std::__1::condition_variable_any::wait<std::__1::unique_lock<bmalloc::Mutex> >(std::__1::unique_lock<bmalloc::Mutex>&) + 108 (condition_variable:203)
4   JavaScriptCore                	0x000000018cf189a4 bmalloc::Scavenger::threadRunLoop() + 340 (condition_variable:212)
5   JavaScriptCore                	0x000000018cf18544 bmalloc::Scavenger::threadEntryPoint(bmalloc::Scavenger*) + 16 (Scavenger.cpp:295)
6   JavaScriptCore                	0x000000018cf19a00 void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)(bmalloc::Scavenger*), bmalloc::Scaveng... + 48 (type_traits:3694)
7   libsystem_pthread.dylib       	0x00000001f19f69a4 _pthread_start + 148 (pthread.c:891)
8   libsystem_pthread.dylib       	0x00000001f19f5ea0 thread_start + 8

Thread 2 name:
Thread 2:
0   libsystem_kernel.dylib        	0x00000001b7e0c504 mach_msg_trap + 8
1   libsystem_kernel.dylib        	0x00000001b7e0cb9c mach_msg + 76 (mach_msg.c:119)
2   CoreFoundation                	0x0000000180ddb688 __CFRunLoopServiceMachPort + 372 (CFRunLoop.c:2646)
3   CoreFoundation                	0x0000000180ddf97c __CFRunLoopRun + 1212 (CFRunLoop.c:3000)
4   CoreFoundation                	0x0000000180df33b8 CFRunLoopRunSpecific + 600 (CFRunLoop.c:3268)
5   Foundation                    	0x000000018260e354 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 236 (NSRunLoop.m:373)
6   Foundation                    	0x000000018264fc28 -[NSRunLoop(NSRunLoop) runUntilDate:] + 92 (NSRunLoop.m:420)
7   UIKitCore                     	0x000000018370c8a4 -[UIEventFetcher threadMain] + 524 (UIEventFetcher.m:1167)
8   Foundation                    	0x000000018265e36c __NSThread__start__ + 808 (NSThread.m:972)
9   libsystem_pthread.dylib       	0x00000001f19f69a4 _pthread_start + 148 (pthread.c:891)
10  libsystem_pthread.dylib       	0x00000001f19f5ea0 thread_start + 8

Thread 3 name:
Thread 3:
0   libsystem_kernel.dylib        	0x00000001b7e0c504 mach_msg_trap + 8
1   libsystem_kernel.dylib        	0x00000001b7e0cb9c mach_msg + 76 (mach_msg.c:119)
2   CoreFoundation                	0x0000000180ddb688 __CFRunLoopServiceMachPort + 372 (CFRunLoop.c:2646)
3   CoreFoundation                	0x0000000180ddf97c __CFRunLoopRun + 1212 (CFRunLoop.c:3000)
4   CoreFoundation                	0x0000000180df33b8 CFRunLoopRunSpecific + 600 (CFRunLoop.c:3268)
5   Foundation                    	0x000000018260e354 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 236 (NSRunLoop.m:373)
6   Foundation                    	0x000000018260eb10 -[NSRunLoop(NSRunLoop) run] + 92 (NSRunLoop.m:398)
7   Test                         	0x00000001053c1580 +[GAI threadMain:] + 64
8   Foundation                    	0x000000018265e36c __NSThread__start__ + 808 (NSThread.m:972)
9   libsystem_pthread.dylib       	0x00000001f19f69a4 _pthread_start + 148 (pthread.c:891)
10  libsystem_pthread.dylib       	0x00000001f19f5ea0 thread_start + 8

Thread 4 name:
Thread 4:
0   libsystem_kernel.dylib        	0x00000001b7e0c504 mach_msg_trap + 8
1   libsystem_kernel.dylib        	0x00000001b7e0cb9c mach_msg + 76 (mach_msg.c:119)
2   Test                         	0x00000001054dd3ac FIRCLSMachExceptionServer + 104
3   libsystem_pthread.dylib       	0x00000001f19f69a4 _pthread_start + 148 (pthread.c:891)
4   libsystem_pthread.dylib       	0x00000001f19f5ea0 thread_start + 8

Thread 5 name:
Thread 5:
0   libsystem_kernel.dylib        	0x00000001b7e0c504 mach_msg_trap + 8
1   libsystem_kernel.dylib        	0x00000001b7e0cb9c mach_msg + 76 (mach_msg.c:119)
2   CoreFoundation                	0x0000000180ddb688 __CFRunLoopServiceMachPort + 372 (CFRunLoop.c:2646)
3   CoreFoundation                	0x0000000180ddf97c __CFRunLoopRun + 1212 (CFRunLoop.c:3000)
4   CoreFoundation                	0x0000000180df33b8 CFRunLoopRunSpecific + 600 (CFRunLoop.c:3268)
5   CoreFoundation                	0x0000000180e73a78 CFRunLoopRun + 64 (CFRunLoop.c:3293)
6   CoreMotion                    	0x000000018ddd3544 CLMotionCore::runMotionThread(void*) + 1204 (CLMotionCore.mm:370)
7   libsystem_pthread.dylib       	0x00000001f19f69a4 _pthread_start + 148 (pthread.c:891)
8   libsystem_pthread.dylib       	0x00000001f19f5ea0 thread_start + 8

Thread 6 name:
Thread 6:
0   libsystem_kernel.dylib        	0x00000001b7e0c504 mach_msg_trap + 8
1   libsystem_kernel.dylib        	0x00000001b7e0cb9c mach_msg + 76 (mach_msg.c:119)
2   CoreFoundation                	0x0000000180ddb688 __CFRunLoopServiceMachPort + 372 (CFRunLoop.c:2646)
3   CoreFoundation                	0x0000000180ddf97c __CFRunLoopRun + 1212 (CFRunLoop.c:3000)
4   CoreFoundation                	0x0000000180df33b8 CFRunLoopRunSpecific + 600 (CFRunLoop.c:3268)
5   CFNetwork                     	0x00000001818676a0 +[__CFN_CoreSchedulingSetRunnable _run:] + 464 (CoreSchedulingSet.mm:1372)
6   Foundation                    	0x000000018265e36c __NSThread__start__ + 808 (NSThread.m:972)
7   libsystem_pthread.dylib       	0x00000001f19f69a4 _pthread_start + 148 (pthread.c:891)
8   libsystem_pthread.dylib       	0x00000001f19f5ea0 thread_start + 8

Thread 7 name:
Thread 7:
0   libsystem_kernel.dylib        	0x00000001b7e0c504 mach_msg_trap + 8
1   libsystem_kernel.dylib        	0x00000001b7e0cb9c mach_msg + 76 (mach_msg.c:119)
2   CoreFoundation                	0x0000000180ddb688 __CFRunLoopServiceMachPort + 372 (CFRunLoop.c:2646)
3   CoreFoundation                	0x0000000180ddf97c __CFRunLoopRun + 1212 (CFRunLoop.c:3000)
4   CoreFoundation                	0x0000000180df33b8 CFRunLoopRunSpecific + 600 (CFRunLoop.c:3268)
5   AudioSession                  	0x000000018a187308 CADeprecated::GenericRunLoopThread::Entry(void*) + 164 (GenericRunLoopThread.h:95)
6   AudioSession                  	0x000000018a190d64 CADeprecated::CAPThread::Entry(CADeprecated::CAPThread*) + 92 (CAPThread.cpp:324)
7   libsystem_pthread.dylib       	0x00000001f19f69a4 _pthread_start + 148 (pthread.c:891)
8   libsystem_pthread.dylib       	0x00000001f19f5ea0 thread_start + 8

Thread 8 name:
Thread 8:
0   libsystem_kernel.dylib        	0x00000001b7e0c504 mach_msg_trap + 8
1   libsystem_kernel.dylib        	0x00000001b7e0cb9c mach_msg + 76 (mach_msg.c:119)
2   CoreFoundation                	0x0000000180ddb688 __CFRunLoopServiceMachPort + 372 (CFRunLoop.c:2646)
3   CoreFoundation                	0x0000000180ddf97c __CFRunLoopRun + 1212 (CFRunLoop.c:3000)
4   CoreFoundation                	0x0000000180df33b8 CFRunLoopRunSpecific + 600 (CFRunLoop.c:3268)
5   CoreFoundation                	0x0000000180edba70 _legacyStreamRunLoop_workThread + 300 (CFStream.c:1776)
6   libsystem_pthread.dylib       	0x00000001f19f69a4 _pthread_start + 148 (pthread.c:891)
7   libsystem_pthread.dylib       	0x00000001f19f5ea0 thread_start + 8

Thread 9:
0   libsystem_kernel.dylib        	0x00000001b7e0c504 mach_msg_trap + 8
1   libsystem_kernel.dylib        	0x00000001b7e0cb9c mach_msg + 76 (mach_msg.c:119)
2   CoreFoundation                	0x0000000180ddb688 __CFRunLoopServiceMachPort + 372 (CFRunLoop.c:2646)
3   CoreFoundation                	0x0000000180ddf97c __CFRunLoopRun + 1212 (CFRunLoop.c:3000)
4   CoreFoundation                	0x0000000180df33b8 CFRunLoopRunSpecific + 600 (CFRunLoop.c:3268)
5   Foundation                    	0x000000018260e354 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 236 (NSRunLoop.m:373)
6   GoogleCast                    	0x00000001069378ec 0x106818000 + 1177836
7   Foundation                    	0x000000018265e36c __NSThread__start__ + 808 (NSThread.m:972)
8   libsystem_pthread.dylib       	0x00000001f19f69a4 _pthread_start + 148 (pthread.c:891)
9   libsystem_pthread.dylib       	0x00000001f19f5ea0 thread_start + 8

Thread 10:
0   libsystem_pthread.dylib       	0x00000001f19f5e8c _pthread_cond_updateval + 260 (pthread_cond.c:992)

Thread 11:
0   libsystem_pthread.dylib       	0x00000001f19f5e8c _pthread_cond_updateval + 260 (pthread_cond.c:992)

Thread 12:
0   libsystem_pthread.dylib       	0x00000001f19f5e8c _pthread_cond_updateval + 260 (pthread_cond.c:992)

Thread 13 name:
Thread 13 Crashed:
0   libsystem_kernel.dylib        	0x00000001b7e12964 __pthread_kill + 8
1   libsystem_pthread.dylib       	0x00000001f19fc378 pthread_kill + 268 (pthread.c:1610)
2   libsystem_c.dylib             	0x000000018bd02420 __abort + 128 (abort.c:155)
3   libsystem_c.dylib             	0x000000018bcaaf5c abort + 176 (abort.c:126)
4   libc++abi.dylib               	0x00000001995e9bc4 abort_message + 132 (abort_message.cpp:78)
5   libc++abi.dylib               	0x00000001995dafd8 demangling_terminate_handler() + 332 (cxa_default_handlers.cpp:71)
6   libobjc.A.dylib               	0x00000001994e8064 _objc_terminate() + 144 (objc-exception.mm:701)
7   Test                         	0x00000001054d436c FIRCLSTerminateHandler() + 352
8   libc++abi.dylib               	0x00000001995e8f58 std::__terminate(void (*)()) + 20 (cxa_handlers.cpp:59)
9   libc++abi.dylib               	0x00000001995e8ef4 std::terminate() + 64 (cxa_handlers.cpp:88)
10  libdispatch.dylib             	0x0000000180adf674 _dispatch_client_callout + 40 (object.m:563)
11  libdispatch.dylib             	0x0000000180ae6de4 _dispatch_lane_serial_drain + 672 (inline_internal.h:2601)
12  libdispatch.dylib             	0x0000000180ae7958 _dispatch_lane_invoke + 392 (queue.c:3937)
13  libdispatch.dylib             	0x0000000180af21a8 _dispatch_workloop_worker_thread + 656 (queue.c:6727)
14  libsystem_pthread.dylib       	0x00000001f19f60f4 _pthread_wqthread + 288 (pthread.c:2541)
15  libsystem_pthread.dylib       	0x00000001f19f5e94 start_wqthread + 8

Thread 14 name:
Thread 14:
0   libsystem_kernel.dylib        	0x00000001b7e0c558 semaphore_timedwait_trap + 8
1   libdispatch.dylib             	0x0000000180adfc6c _dispatch_sema4_timedwait + 64 (lock.c:154)
2   libdispatch.dylib             	0x0000000180ae0270 _dispatch_semaphore_wait_slow + 76 (semaphore.c:116)
3   libdispatch.dylib             	0x0000000180af0ba4 _dispatch_worker_thread + 312 (queue.c:7040)
4   libsystem_pthread.dylib       	0x00000001f19f69a4 _pthread_start + 148 (pthread.c:891)
5   libsystem_pthread.dylib       	0x00000001f19f5ea0 thread_start + 8

Thread 15 name:
Thread 15:
0   libsystem_kernel.dylib        	0x00000001b7e0c558 semaphore_timedwait_trap + 8
1   libdispatch.dylib             	0x0000000180adfc6c _dispatch_sema4_timedwait + 64 (lock.c:154)
2   libdispatch.dylib             	0x0000000180ae0270 _dispatch_semaphore_wait_slow + 76 (semaphore.c:116)
3   libdispatch.dylib             	0x0000000180af0ba4 _dispatch_worker_thread + 312 (queue.c:7040)
4   libsystem_pthread.dylib       	0x00000001f19f69a4 _pthread_start + 148 (pthread.c:891)
5   libsystem_pthread.dylib       	0x00000001f19f5ea0 thread_start + 8

Thread 16:
0   libsystem_pthread.dylib       	0x00000001f19f5e8c _pthread_cond_updateval + 260 (pthread_cond.c:992)

Thread 17:
0   libsystem_pthread.dylib       	0x00000001f19f5e8c _pthread_cond_updateval + 260 (pthread_cond.c:992)

Thread 18:
0   libsystem_pthread.dylib       	0x00000001f19f5e8c _pthread_cond_updateval + 260 (pthread_cond.c:992)

Thread 19:
0   libsystem_pthread.dylib       	0x00000001f19f5e8c _pthread_cond_updateval + 260 (pthread_cond.c:992)

Thread 20:
0   libsystem_pthread.dylib       	0x00000001f19f5e8c _pthread_cond_updateval + 260 (pthread_cond.c:992)


Thread 13 crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000000   x1: 0x0000000000000000   x2: 0x0000000000000000   x3: 0x0000000000000000
    x4: 0x0000000000000000   x5: 0x0000000000989680   x6: 0x000000000000006e   x7: 0xffffffff00001600
    x8: 0xee074df83669a2fa   x9: 0xee074df95d0a92fa  x10: 0x00000000000003e8  x11: 0x000000000000000b
   x12: 0x00000000a323a00c  x13: 0x000000002323a000  x14: 0x0000000000000010  x15: 0x0000000000000002
   x16: 0x0000000000000148  x17: 0x000000016b633000  x18: 0x0000000000000000  x19: 0x0000000000000006
   x20: 0x000000000005435b  x21: 0x000000016b6330e0  x22: 0x0000000000000007  x23: 0x0000000105b0e5c3
   x24: 0x0000000000000001  x25: 0x0000000000000000  x26: 0x0000000000000114  x27: 0x0000000000000000
   x28: 0x00000002818109c0   fp: 0x000000016b632310   lr: 0x00000001f19fc378
    sp: 0x000000016b6322f0   pc: 0x00000001b7e12964 cpsr: 0x40001000
   esr: 0x56000080  Address size fault


Binary Images:
0x104a84000 - 0x105da7fff Test arm64  <f6f92cdf5b24351c95a4ad85952fa43f> /private/var/containers/Bundle/Application/95ADD6D4-4822-4899-A2C3-D8E360C3F3B6/Test.app/Test
0x106630000 - 0x106687fff dyld arm64e  <c21dba379df93fc7b286734030e18bb1> /usr/lib/dyld
0x106818000 - 0x106a5bfff GoogleCast arm64  <2a8035393d3c364ead7e318eb2f1896e> /private/var/containers/Bundle/Application/95ADD6D4-4822-4899-A2C3-D8E360C3F3B6/Test.app/Frameworks/GoogleCast.framework/GoogleCast
0x180adb000 - 0x180b21fff libdispatch.dylib arm64e  <a5cbaab3e3893548baacfab18411b94a> /usr/lib/system/libdispatch.dylib
0x180dd4000 - 0x181227fff CoreFoundation arm64e  <b2d21cfd378c36d5baf73f70599cfefc> /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
0x1815ed000 - 0x181ab1fff CFNetwork arm64e  <1f9e80ee1df136acbdfe22afb9a1b82e> /System/Library/Frameworks/CFNetwork.framework/CFNetwork
0x1825f6000 - 0x1828fbfff Foundation arm64e  <d59c69755af237bc93be43b80b4293a5> /System/Library/Frameworks/Foundation.framework/Foundation
0x18327a000 - 0x184afefff UIKitCore arm64e  <8388eb03002b3b35a78a6a022894292e> /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore
0x18a181000 - 0x18a1aafff AudioSession arm64e  <99ff741f34943edf82b7c03c916ebad3> /System/Library/PrivateFrameworks/AudioSession.framework/AudioSession
0x18bc8b000 - 0x18bd09fff libsystem_c.dylib arm64e  <30a1668a329d30009f747b42b21fe0fd> /usr/lib/system/libsystem_c.dylib
0x18bd62000 - 0x18d022fff JavaScriptCore arm64e  <488fd070baee3b55ac28cee0d299f2b2> /System/Library/Frameworks/JavaScriptCore.framework/JavaScriptCore
0x18ddc0000 - 0x18e0ccfff CoreMotion arm64e  <7464cd4b1ec7342392ce51becea40ca3> /System/Library/Frameworks/CoreMotion.framework/CoreMotion
0x1994cc000 - 0x199505fff libobjc.A.dylib arm64e  <10fa90c6dfe538aeb3dc2251181cc272> /usr/lib/libobjc.A.dylib
0x199572000 - 0x1995d5fff libc++.1.dylib arm64e  <255864c483d93bac8c7aad1b2d8a60cc> /usr/lib/libc++.1.dylib
0x1995d6000 - 0x1995effff libc++abi.dylib arm64e  <375cf7503f9339e8a6eb1c0d7181c64e> /usr/lib/libc++abi.dylib
0x19c782000 - 0x19c78afff GraphicsServices arm64e  <44e4515eb18737f18fe028e7b087daf5> /System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices
0x1a4a8a000 - 0x1a4af7fff Pegasus arm64e  <8c02d013a2fc3f8486ebbe03b5f4d219> /System/Library/PrivateFrameworks/Pegasus.framework/Pegasus
0x1b7e0b000 - 0x1b7e3efff libsystem_kernel.dylib arm64e  <b1b942de75903c61980a19d80ed4da37> /usr/lib/system/libsystem_kernel.dylib
0x1f19f5000 - 0x1f1a00fff libsystem_pthread.dylib arm64e  <1a4a45fd1bb639df84140590ce103717> /usr/lib/system/libsystem_pthread.dylib

EOF
Answered by DTS Engineer in 700787022

Do you have access to the source code referenced in the crash report? If so, what does the code around line 1240 of PGPictureInPictureProxy.m look like?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer

Do you have access to the source code referenced in the crash report? If so, what does the code around line 1240 of PGPictureInPictureProxy.m look like?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Unfortunately no.

Sorry, i misclicked the button mark as accepted answer there.

Sorry, i misclicked the button mark as accepted answer there.

No worries; I don’t pay any attention to that flag (-:

Unfortunately no.

Hmmm, that makes it hard.

First up, note frame 7 of thread 13:

7 Test … FIRCLSTerminateHandler() + 352

This suggests you have some sort of third-party crash reporter in play. Given that, it’s hard to be sure how much to trust the rest of the crash report. For more background on this, see Implementing Your Own Crash Reporter.

So, assuming that the third-party crash reporter didn’t mess things up too badly, the app crashed because it threw an unhandled language exception. The backtrace looks like this:

0 CoreFoundation     … __exceptionPreprocess + 220 (NSException.m:200)
1 libobjc.A.dylib    … objc_exception_throw + 60 (objc-exception.mm:565)
2 CoreFoundation     … -[NSObject(NSObject) doesNotRecognizeSelector:] + 144 (NSObject.m:147)
3 CoreFoundation     … ___forwarding___ + 1728 (NSForwarding.m:3577)
4 CoreFoundation     … _CF_forwarding_prep_0 + 96
5 Pegasus            … __58-[PGPictureInPictureProxy __cleanupWithCompletionHandler:]_block_invoke + 272 (PGPictureInPictureProxy.m:1240)
6 libdispatch.dylib  … _dispatch_call_block_and_release + 32 (init.c:1517)

Frame 6 and higher are Dispatch goo indicating that someone dispatched a block to a queue. Frame 5 is the block that was scheduled, namely a block within the -[PGPictureInPictureProxy __cleanupWithCompletionHandler:] method. Finally, frames 4 through 0 are the usual stuff you see if you call a method on an object of the wrong type. Based on the exception message you posted, it looks like that object was an instance of _NSXPCDistantObject, which is a private class within Foundation that’s involved in proxying XPC requests.

As to what’s causing this, it’s hard to say. Normally crashes like this are commonly caused by memory management issues, but the XPC proxying thing suggests that there might be something else in play. Two suggestions:

  • Run your app with the standard memory debugging tools, and especially zombies. If this a memory management issue, those tools might make the problem more reproducible.

  • Talk with the author of -[PGPictureInPictureProxy __cleanupWithCompletionHandler:] to find out what’s going on at line 1240 of PGPictureInPictureProxy.m.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Talk with the author of -[PGPictureInPictureProxy __cleanupWithCompletionHandler:] to find out what’s going on at line 1240 of PGPictureInPictureProxy.m.

A colleague pointed out something I missed, namely this line in the crash report:

0x1a4a8a000 - 0x1a4af7fff Pegasus arm64e  <8c02d013a2fc3f8486ebbe03b5f4d219> /System/Library/PrivateFrameworks/Pegasus.framework/Pegasus

The path makes it clear that this is an Apple framework. D’oh! That explains why you don’t have the source code (-:

Unfortunately this is outside of my area of expertise (obviously!) and so I don’t have any input as to what’s going on here. What I can say is that this crash seems to be affecting lots of different apps, including some built-in ones like Safari, so I doubt that this is your fault.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I see, so it's confirmed that there's nothing we can do to resolve this issue in my side for now beside waiting for the fix to be published on the next iOS update by Apple (even though we are not sure when and on which version).

Thanks for clarifying that for me, Quinn. Really appreciate your help ! Please do send my thanks to your colleague for pointing out one of crucial part in this investigation. XD

Have a nice day, both of you !

Hi, Did you raise a bug report for this issue? We would like to track any fixes (or raise one ourselves)

FB9999117

Thanks for filing that.

I had a quick look and it seems to be heading in the right direction. However, as you only filed it recently, there’s not much other info I can provide. Honestly, I was hoping that some of the folks from earlier in the thread would be able to provide the number for an older bug, one that’s had more time for analysis.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

mark and follow, any update is appreciated.

I filed a bug on this issue about 7 months ago: FB9716285

Any info about possible workarounds or when we could expect a fix would be greatly appreciated.

hi, is there any updates that can be shared from the Apple side regarding this ?

like maybe it will be fixed in the upcoming iOS 16 ?

For… well… reasons… I can’t share anything definitive here. However, if you continue to see this in iOS 16 beta please add that info to your bug report and then lemme know which bug that was here in this thread.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

If i understand it correctly, you mean if it still occurs in iOS 16, I should submit a new bug report and mentioned about the existing one there (which is FB9839142) and also let you know again both of the bug report numbers here, right ?

If i understand it correctly …

Correct.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Noted, thanks. Will do that later.

Hi, I've checked again after iOS 16 beta released and found out that the similar crash still exists but this time the stack trace pointed to different suspect but still about unrecognized selector issue with stack trace that pointed to none of our internal project code.

I've filed a new bug report that contains crash reports in it too with number FB11204498 and also already included the previous bug report number (FB9839142).

Looking forward to your update on this.

Crash on iOS 15 devices happens mostly in background
 
 
Q