-
Notifications
You must be signed in to change notification settings - Fork 221
Description
Describe the bug
I'm receiving crash reports from Firebase that Amplify is crashing during app launch.
Steps To Reproduce
Steps to reproduce the behavior:
1. UIWindowSceneDelegate.scene(: willConnectTo: options:) invokes Amplify.add(plugin: AWSCognitoAuthPlugin()) and Amplify.configure() successfully.
2. Some time later UIApplicationDelegate.application(: didRegisterForRemoteNotificationsWithDeviceToken:) is called and through Combine and intermediate steps invokes Amplify.Auth.fetchAuthSession() to retrieve the AWSAuthCognitoSession and query the `cognitoTokensResult`
3. At some point in step 2 the crash occurs.
Expected behavior
Authentication and push token registration complete without crashing.
Amplify Framework Version
1.31.0
Amplify Categories
Auth
Dependency manager
Swift PM
Swift version
"Swift 5" in Xcode build settings corresponding to Swift 5.0
CLI version
12.14.4
Xcode version
16.2
Relevant log output
<details>
<summary>Log Messages</summary>
Crashed: com.apple.main-thread
0 RedactedAppName 0x276f78 AuthCategory.fetchAuthSession(options:listener:) + 99 (AuthCategory+ClientBehavior.swift:99)
1 RedactedAppName 0x747e0 specialized Authentication.getTokens() + 272 (Authentication.swift:272)
2 RedactedAppName 0x74128 protocol witness for AuthenticationProvider.getLatestToken() in conformance Authentication + 4376445224 (<compiler-generated>:4376445224)
3 RedactedAppName 0x1f5394 Client.setUserPushToken(data:) + 65 (Client+Authentication.swift:65)
4 RedactedAppName 0x49d20 specialized AppDelegate.application(_:didRegisterForRemoteNotificationsWithDeviceToken:) + 198 (AppDelegate.swift:198)
5 RedactedAppName 0x4896c @objc AppDelegate.application(_:didRegisterForRemoteNotificationsWithDeviceToken:) + 4376267116 (<compiler-generated>:4376267116)
6 UIKitCore 0x4bd18c __63-[UIApplication pushRegistry:didUpdatePushCredentials:forType:]_block_invoke + 96
7 libdispatch.dylib 0x2248 _dispatch_call_block_and_release + 32
8 libdispatch.dylib 0x3fa8 _dispatch_client_callout + 20
9 libdispatch.dylib 0x12a34 _dispatch_main_queue_drain + 984
10 libdispatch.dylib 0x1264c _dispatch_main_queue_callback_4CF + 44
11 CoreFoundation 0x79bcc __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
12 CoreFoundation 0x761c0 __CFRunLoopRun + 1996
13 CoreFoundation 0xc8284 CFRunLoopRunSpecific + 588
14 GraphicsServices 0x14c0 GSEventRunModal + 164
15 UIKitCore 0x3ee674 -[UIApplication _run] + 816
16 UIKitCore 0x14e88 UIApplicationMain + 340
17 RedactedAppName 0x48c58 main + 21 (AppDelegate.swift:21)
18 ??? 0x1c316dde8 (Missing)
</details>
Is this a regression?
Yes
Regression additional context
No response
Platforms
iOS
OS Version
iOS 14 to iOS 18
Device
iPhone XS to iPhone 16, all models
Specific to simulators
No
Additional context
This is using a suite of Cognito and AWS lambdas to provide the rest of authentication. I wasn't able to open this issue without selecting a a value for "Amplify Categories". Is this a new requirement? I don't think my project is using any categories because it is a custom Cognito implementation.
This seems very similar to an earlier crash report, and the last suggestion there was to ensure that Amplify.add(plugin: AWSCognitoAuthPlugin())
is only called once. I tried invoking add(plugin:) twice (by duplicating the function call on the next line) but was not able to cause a crash. Link: #1639
This crash is affecting a subset of customers and I have not been able to reproduce it.