amplify-swift: Crash: "SWIFT TASK CONTINUATION MISUSE" in ShowHostedUISign[In/Out].execute
Describe the bug
We are receiving numerous crash logs in production related to the Amplify hosted UI. We are unable to reproduce the issue, however we believe it is similar to an Auth0 issue (see Steps To Reproduce).
_Concurrency/CheckedContinuation.swift > Fatal error > SWIFT TASK CONTINUATION MISUSE: execute(withDispatcher:environment:) tried to resume its continuation more than once, throwing cancelled!
OS Version: iOS 16.1.2 (20B110)
Report Version: 104
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Crashed Thread: 0
Application Specific Information:
_Concurrency/CheckedContinuation.swift > Fatal error
Thread 0 Crashed:
0 libswiftCore.dylib 0x30cc81d7c _assertionFailure
1 libswift_Concurrency.dylib 0x32d69d55c CheckedContinuation.resume
2 App 0x1058f36bc [inlined] CheckedContinuation.resume<T>
3 App 0x1058f36bc ShowHostedUISignIn.execute (ShowHostedUISignIn.swift:59)
4 App 0x105b00d4c HostedUIASWebAuthenticationSession.showHostedUI (HostedUIASWebAuthenticationSession.swift:43)
5 App 0x105b0192c thunk for closure
6 AuthenticationServices 0x3e26b5540 <redacted>
7 SafariServices 0x3525b43bc <redacted>
8 SafariServices 0x352663020 <redacted>
9 SafariServices 0x35263b2f4 <redacted>
10 CoreFoundation 0x31901c700 __invoking___
11 CoreFoundation 0x318fc8b68 -[NSInvocation invoke]
12 libdispatch.dylib 0x327b57fd8 _dispatch_client_callout
13 libdispatch.dylib 0x327b5ba58 _dispatch_block_invoke_direct
14 FrontBoardServices 0x3448053ac __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__
15 FrontBoardServices 0x344804f48 -[FBSSerialQueue _targetQueue_performNextIfPossible]
16 FrontBoardServices 0x344807728 -[FBSSerialQueue _performNextFromRunLoopSource]
17 CoreFoundation 0x31907df50 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
18 CoreFoundation 0x31908a328 __CFRunLoopDoSource0
19 CoreFoundation 0x31900e20c __CFRunLoopDoSources0
20 CoreFoundation 0x319023ba4 __CFRunLoopRun
21 CoreFoundation 0x319028ed0 CFRunLoopRunSpecific
22 GraphicsServices 0x38b6ab364 GSEventRunModal
23 UIKitCore 0x31d6c43cc -[UIApplication _run]
24 UIKitCore 0x31d6c4030 UIApplicationMain
25 SwiftUI 0x3204af010 OUTLINED_FUNCTION_895
26 SwiftUI 0x320410168 block_copy_helper.1
27 SwiftUI 0x3203f94b8 OUTLINED_FUNCTION_901
28 <redacted> 0x202da44e0 [inlined] <redacted>App.$main
29 <redacted> 0x202da44e0 main
30 <unknown> 0x1b0908960 <redacted>
Note that we are using async/await APIs in our app to interact with Amplify Swift.
Steps To Reproduce
We are unable to reproduce the issue, however we believe it may be similar to an issue discovered in the Auth0 SDK:
https://github.com/auth0/Auth0.swift/issues/729
Expected behavior
The CheckedContinuation instance in the ShowHostedUISignIn.execute and ShowHostedUISignOut.execute functions should not be resumed twice. This may be a bug in ASWebAuthenticationSession, however it is causing production crashes so may need to be worked around within the Amplify Swift SDK.
Amplify Framework Version
2.21.3 and previous versions
Amplify Categories
Auth
Dependency manager
Swift PM
Swift version
5.7
CLI version
None
Xcode version
15.0.1 (15A507)
Relevant log output
No response
Is this a regression?
No
Regression additional context
No response
Platforms
iOS
OS Version
iOS16+ and iOS17+
Device
Various iOS devices
Specific to simulators
No response
Additional context
No response
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Comments: 15 (9 by maintainers)
The issue ticket is now closed as the fix has been released in the latest version 2.25.0. If you continue to encounter the problem, please don’t hesitate to reopen the ticket.
@maxchuquimia We’ve released a new version (2.25.4) with the potential fix. Please reopen the issue if you have more questions. Thanks for your patience.
Thanks for letting us know and for the crash logs. We’re investigating and will provide an update when we can.
@maxchuquimia I will work on drafting a release. Amplify is due to release sometime later next week. I will post an update on the issue when that happens.
@maxchuquimia Thanks for providing more details… I am still not able to get this crash locally…
Nevertheless, I have made a small fix in #3363 … Is it possible if you can test the branch in the PR (
fix/hosted-ui-crash) and let me know if it resolves the issue.