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 ?

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