Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UINavigationController subclass crashes #1356

Closed
abear247 opened this issue Jun 30, 2023 · 2 comments
Closed

UINavigationController subclass crashes #1356

abear247 opened this issue Jun 30, 2023 · 2 comments
Assignees
Labels
crash SDK crashes

Comments

@abear247
Copy link

The crash

objc[75872]: Cannot form weak reference to instance (0x14f032000) of class Top_Hat.TestNav. It is possible that this object was over-released, or is in the process of deallocation.

Crash log from our setup.
Screenshot 2023-06-30 at 12 18 34 PM

Digging into it we found that the simplest reproducible was

class TestNav: UINavigationController {}

// triggered from a button
func buttonPressed() {
    let hostingViewController = UIHostingController(rootView: EmptyView())
    let navigationController = TestNav(rootViewController: hostingViewController)
    present(navigationController, animated: true)
}

This was caught during QA when we were trying to add in Datadog RUM.

RUM setup code

    private func initializeDatadog(config: Config) {
        let ddConfig = Datadog.Configuration.builderUsing(
            rumApplicationID: config.rumApplicationID,
            clientToken: config.clientToken,
            environment: config.environment
        )
        .set(serviceName: config.serviceName)
        .set(endpoint: .us1)
        .trackUIKitRUMViews()
        .trackUIKitRUMActions()
        .enableTracing(true)
        .build()

        Datadog.initialize(
            appContext: .init(), trackingConsent: .granted, configuration: ddConfig
        )
        Global.rum = RUMMonitor.initialize()
    }

There is a workaround that does not crash. So this seems particularly related to the default predicate.

class CustomPredicate: UIKitRUMViewsPredicate {
    func rumView(for viewController: UIViewController) -> RUMView? {
        return .init(name: "\(type(of: viewController))")
    }
}

Datadog SDK versions:

1.20.0

Last stable Datadog SDK version:

None, we haven't shipped this yet

Volume:

Easily reproducible within <5 swipes to close presented view

OS version:

iOS 16.2

Deployment Target:

14.0, iPhone and iPad

Device version:

iPhone 11

Environment:

N/A

@abear247 abear247 added the crash SDK crashes label Jun 30, 2023
@ncreated ncreated self-assigned this Jul 6, 2023
@ncreated
Copy link
Member

ncreated commented Jul 6, 2023

Hello @abear247 👋. I confirm, we can reproduce the problem and we added it to our backlog. Stay tuned for updates.

💡 Regarding mitigation (nice you discovered it ⭐), you can make it more specific by only applying it to the modal view controller and forwarding all other calls to our default predicate.

PS. Thanks a million for perfect information and isolating the reproduction steps to bare minimum. That helps a lot!

@ncreated
Copy link
Member

This problem was fixed in #1533 and deployed in 2.5.0. I'm closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash SDK crashes
Projects
None yet
Development

No branches or pull requests

2 participants