Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

[iOS 13]: Fatal Exception: NSInvalidArgumentException Can't add self as subview ([NSCache init])

I've seen similar issues/questions on Stack Overflow, but they didn't help.

I built the app with Xcode 11 and iOS 13 SDK. The problem is that I get all these crashes only on iOS 13+, even though my app supports iOS 10+ and there are ~50% iOS 12 users among all. Also, I cannot debug or reproduce it.

From this info I inferred the issue must be specific to iOS 13. Has anyone come across the same issue recently? Possible causes, solutions?

Here is the stack trace from Crashlytics:

Fatal Exception: NSInvalidArgumentException
0  CoreFoundation                 0x1c25e1c30 __exceptionPreprocess
1  libobjc.A.dylib                0x1c22fc0c8 objc_exception_throw
2  CoreFoundation                 0x1c24d13ac -[NSCache init]
3  UIKitCore                      0x1c6b189a8 -[UIView(Internal) _addSubview:positioned:relativeTo:]
4  UIKitCore                      0x1c6078bb4 __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke_2
5  UIKitCore                      0x1c6b11f60 +[UIView(Animation) performWithoutAnimation:]
6  UIKitCore                      0x1c6078630 __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke
7  UIKitCore                      0x1c6b1784c +[UIView(Internal) _performBlockDelayingTriggeringResponderEvents:forScene:]
8  UIKitCore                      0x1c6078088 -[_UINavigationParallaxTransition animateTransition:]
9  UIKitCore                      0x1c606e2b0 ___UIViewControllerTransitioningRunCustomTransition_block_invoke_2
10 UIKitCore                      0x1c61822f8 +[UIInputResponderController _pinInputViewsForInputResponderController:onBehalfOfResponder:duringBlock:]
11 UIKitCore                      0x1c606e238 ___UIViewControllerTransitioningRunCustomTransition_block_invoke.648
12 UIKitCore                      0x1c6b11c0c +[UIView(Animation) _setAlongsideAnimations:toRunByEndOfBlock:]
13 UIKitCore                      0x1c606e088 _UIViewControllerTransitioningRunCustomTransition
14 UIKitCore                      0x1c5f9d77c -[UINavigationController _startCustomTransition:]
15 UIKitCore                      0x1c5fb0c18 -[UINavigationController _startDeferredTransitionIfNeeded:]
16 UIKitCore                      0x1c5fb20f8 -[UINavigationController __viewWillLayoutSubviews]
17 UIKitCore                      0x1c5f954e0 -[UILayoutContainerView layoutSubviews]
18 UIKitCore                      0x1c6b1fabc -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
19 libobjc.A.dylib                0x1c22f7af0 -[NSObject performSelector:withObject:]
20 QuartzCore                     0x1c90be0f4 -[CALayer layoutSublayers]
21 QuartzCore                     0x1c90be3fc CA::Layer::layout_if_needed(CA::Transaction*)
22 QuartzCore                     0x1c90d1964 CA::Layer::layout_and_display_if_needed(CA::Transaction*)
23 QuartzCore                     0x1c9016c1c CA::Context::commit_transaction(CA::Transaction*, double)
24 QuartzCore                     0x1c9041bd8 CA::Transaction::commit()
25 QuartzCore                     0x1c90427ac CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*)
26 CoreFoundation                 0x1c255c67c __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
27 CoreFoundation                 0x1c255731c __CFRunLoopDoObservers
28 CoreFoundation                 0x1c25578cc __CFRunLoopRun
29 CoreFoundation                 0x1c2557098 CFRunLoopRunSpecific
30 GraphicsServices               0x1cc6c1534 GSEventRunModal
31 UIKitCore                      0x1c66777ac UIApplicationMain

Update 1: The issue is relevant to all iPhones running iOS 13, not only iPhone X(S,R) line.

Update 2: The issue is relevant to iOS 12 as well, but crashes happen rarely in comparison to iOS 13. My guess is that the issue is related to building the project with iOS 13 SDK, because the same code built with iOS 12 SDK didn't emit such crashes and the navigation logic wasn't updated.

like image 655
Aleksandr Honcharov Avatar asked Oct 10 '19 11:10

Aleksandr Honcharov


1 Answers

The app built with Xcode 11.3 & iOS SDK 13.3 doesn't have this crash anymore. I guess it was solved on the iOS SDK side.

UPDATE: 18.06.2020

For those, who continue having the issue, I'd recommend updating to the new Firebase Crashlytics from the old Fabric Crashlytics. The guide is here: https://firebase.google.com/docs/crashlytics/upgrade-sdk?platform=ios

Moreover, I got an email from Firebase about the old SDK deprecation:

We are writing to let you know that the Fabric Crashlytics SDK is now deprecated and will continue reporting your app's crashes until November 15, 2020. After this date, the Fabric Crashlytics SDK and beta versions of the Firebase Crashlytics SDK will stop sending crash reports for your app.

like image 95
Aleksandr Honcharov Avatar answered Oct 22 '22 23:10

Aleksandr Honcharov