sentry-cocoa: Crash when initialising a view controller with performance tracking enabled

Environment

How do you use Sentry? Sentry SaaS (sentry.io)

Which SDK and version? sentry-cocoa 7.3.0

Steps to Reproduce

  1. iOS 15
  2. Sentry 7.3.0
  3. As a workaround we disabled the network performance tracking as mentioned in: https://github.com/getsentry/sentry-cocoa/issues/1346
  4. In the SDK initialisation:
SentrySDK.start { options in
    // Temporary workaround to avoid memory crashes
    // See: https://github.com/getsentry/sentry-cocoa/issues/1346
    // Disable network tracking integration:
    options.integrations = options.integrations?.filter { $0 != "SentryNetworkTrackingIntegration" }
}

Expected Result

Sentry would work with deactivated network performance tracking

Actual Result

Sentry crashing quite often, when initialisation ViewControllers.


Sentry issue message:

NSInternalInconsistencyException
UIViewController is missing its initial trait collection populated during initialization. This is a serious bug, likely caused by accessing properties or methods on the view controller before calling a UIViewController initializer. View controller: <MyViewController: 0x10101a000>

Stack trace from a reproduced crash via TestFlight.

Sentry-Crash-iOS15


Raw Crash log, retrieved from Sentry:

sentry-crash-log.txt


Seem like the swizzling of VCs is giving problems in iOS 15, regarding the non-intialized trait collection(s)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 19 (11 by maintainers)

Most upvoted comments

We released a version with 7.3.0 but with the performance tracking disabled and this has fixed the crashes. Haven’t added any @objc or other workarounds than just deactivating the performance tracking.

Thanks, I’m gonna investigate more into it.

thanks for digging into this, that crashlog you posted on the apple forums looks very similar to the one i was experiencing. what seems strange is that the crash disappeared once i downgraded my sentry version.

i’m releasing a TestFlight later today, i’ll add @objc to my initializer, and re-upgrade to 7.4.0 and see if i still experience a crash

oh yeah! my VC in question totally has a custom initializer

init(tapped: @escaping (WardrobeItem) -> Void, deselect: @escaping (CharacterCatalogModel.Page) -> Void, onPrefetch: @escaping () -> Void) {
    // ...
    super.init(nibName: nil, bundle: nil)
}

that might be it

in my case, why it doesn’t crash on the first init of that VC confuses me