urbanairship / ios-library

Urban Airship iOS SDK
http://urbanairship.com
Apache License 2.0
478 stars 265 forks source link

Crash on didReceiveNotificationResponse(response:completionHandler:) #379

Closed Palbrevik closed 1 year ago

Palbrevik commented 1 year ago

What Airship dependencies are you using?

AIRSHIP IOS SDK 17.4.0

What are the versions of any relevant development tools you are using?

XCode Version 15.0

Report

What unexpected behavior are you seeing?

8.6 K crashes opening app from push.

Crash at: DefaultAppIntegrationDelegate.didReceiveNotificationResponse(response:completionHandler:) + 196 (DefaultAppIntegrationDelegate.swift:176)

See attached files for crash log and push payload.

What is the expected behavior?

No crash.

What are the steps to reproduce the unexpected behavior?

Receive push with payload as attached.

Crash_push.zip

rlepinski commented 1 year ago

Hi few questions:

Palbrevik commented 1 year ago

HI! On your questions:

Yes, with the attached push payload, I always get the crash.

Yes.

No.

I will give it a try after the weekend.

Thanks for your quick response! If there is more data I can provide you with, let me know.

Best regards Pål

On Fri, Oct 6, 2023 at 4:45 PM Ryan Lepinski @.***> wrote:

Hi few questions:

  • Are you able to reproduce this always?
  • Do you have a NotificationCenter delegate implemented?
  • Do you have any other plugins that might be swizzling push hooks?
  • If you can reproduce it, any chance you can provide a minimal sample that reproduces this?

— Reply to this email directly, view it on GitHub https://github.com/urbanairship/ios-library/issues/379#issuecomment-1750805204, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQBLP5KZ3VYP5V246PATCTX6AKSFAVCNFSM6AAAAAA5VXEOEOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONJQHAYDKMRQGQ . You are receiving this because you authored the thread.Message ID: @.***>

rlepinski commented 1 year ago

Could you send me your NotificationCenter delegate? Also, maybe try to reproduce without it to see what happens?

rlepinski commented 1 year ago

I was able to reproduce the crash if I call the completionHandler twice:

    public func receivedNotificationResponse(
        _ notificationResponse: UNNotificationResponse,
        completionHandler: @escaping () -> Void
    ) {
        completionHandler()
        completionHandler()
    }

It gives me the exact same stack trace:

Thread 0 Crashed:
0   libdispatch.dylib                      0x1801796c4 dispatch_group_leave.cold.1 + 36
1   libdispatch.dylib                      0x180144a48 dispatch_group_leave + 112
2   AirshipCore                            0x106412180 closure #2 in DefaultAppIntegrationDelegate.didReceiveNotificationResponse(response:completionHandler:) + 196 (DefaultAppIntegrationDelegate.swift:176)
3   AirshipCore                            0x106414f65 partial apply for closure #2 in DefaultAppIntegrationDelegate.didReceiveNotificationResponse(response:completionHandler:) + 1
4   AirshipCore                            0x1062b8811 thunk for @escaping @callee_guaranteed @Sendable @async () -> (@out A) + 1
5   AirshipCore                            0x1062b897d partial apply for thunk for @escaping @callee_guaranteed @Sendable @async () -> (@out A) + 1
6   libswift_Concurrency.dylib             0x1b6a539c5 completeTaskWithClosure(swift::AsyncContext*, swift::SwiftError*) + 1

The code you sent me makes a call through some other delegate method handleOpenNotification with the completionHandler. Could you try passing in an empty block there and making a single call to the completion handler to see if the issue is that method?

Palbrevik commented 1 year ago

Best Ryan. You nailed it. We did call completion handler twice for this specific payload. Thanks for excellent help. It is all on our side. Hence, I will close this issue. Best regards, Pål

rlepinski commented 1 year ago

Glad its solved! Thanks for the update.