amplify-swift icon indicating copy to clipboard operation
amplify-swift copied to clipboard

Amplify.Auth.getCurrentAuthUser() called from init() causes Preview to crash in XCode

Open Eumag opened this issue 2 years ago • 3 comments

Describe the bug

Hello,

Amplify.Auth.getCurrentAuthUser() called from init() causes Preview to crash in XCode. Github repo indicating this error: https://github.com/Eumag/app4.

AWS video link (2year old now) indicates the use of this api from init(). At 24:20, sessionManager.getCurrentAuthUser() is added AuthenticatedApp.init(). This statement is needed to ensure app lands into proper state on first run.

The code builds and gets executed fine on real device but causes Preview to crash. This crash indicates a problem in launching process. With this statement commented out there is no crash observed. This api works fine from other places (as shown/used in video). Can you check upon it.

Thanks

Steps To Reproduce

Steps to reproduce the behavior:
1. Call Amplify.Auth.getCurrentAuthUser() from init() in file app4App.swift under function app4App.init(). This line is presently commented out in codebase. 
2. Click on any View (say loginBySMSView)
2. Click on Resume for Previews on right side panel of any view

Expected behavior

No crash should happen during Preview of View screen when Amplify.Auth.getCurrentAuthUser() is called from init().

Amplify Framework Version

1.28.0

Amplify Categories

Auth

Dependency manager

Cocoapods

Swift version

5.0

CLI version

9.2.1

Xcode version

13.4 (13F17a)

Relevant log output

<details>
<summary>Log Messages</summary>


MessageSendFailure: Message send failure for relaunch
|  RemoteHumanReadableError: The operation couldn’t be completed. Transaction failed. Process failed to launch. (process launch failed)
```

Is this a regression?

Yes

Regression additional context

Reason I say this is regression, is because this did not show any problem in the video. If there is an option of "Don't Know", I would prefer that because I have not been using this Amplify.Auth.getCurrentAuthUser() for a long time. 6. Device (Model and whether it is Simulator or real device) with IOS version: IPhone-11 , iOS 15.6.1, ModelNo: MHDD3HN/A, RealDevice

Device

iPhone11 - Real Device (ModelNo: MHDD3HN/A)

iOS Version

iOS 15.6.1

Specific to simulators

No response

Additional context

No response

Eumag avatar Sep 20 '22 12:09 Eumag

Hey @Eumag, thanks for opening this issue. This has been fixed in https://github.com/aws-amplify/amplify-ios/pull/2317 and https://github.com/aws-amplify/amplify-ios/pull/2318. We're going release with these fixes in the next few days. I'll update you here once that release is complete. If you'd like to use these changes in the meantime, you can target Amplify 1.28.2-unstable.2. If you choose to do so, we strongly recommend changing back to a stable version once the release is complete.

atierian avatar Sep 20 '22 13:09 atierian

Duplicate of https://github.com/aws-amplify/amplify-ios/issues/2308 and https://github.com/aws-amplify/amplify-ios/issues/1874. Linking for reference.

atierian avatar Sep 20 '22 13:09 atierian

Awesome atierian! Did a quick check and Amplify 1.28.2-unstable.2 did seem to solve the issue at hand. Though, to avoid dependency problem between Amplify and AWSCognitoAuthPlugin, I had to change versions for AmplifyPlugins/AWSCognitoAuthPlugin and AmplifyPlugins/AWSAPIPlugin as well. I am sure dependency issues will taken care of at release time.

Eumag avatar Sep 20 '22 14:09 Eumag

We released this as 1.28.2, closing this issue. Feel free to reach us if you have more questions.

royjit avatar Oct 27 '22 18:10 royjit