aws-amplify/aws-sdk-ios

Delay on AWSMobileClient initialize method

lendk-dua opened this issue · 2 comments

Describe the bug
We have recently updated our SDK to the latest version 2.36.3. We noticed that the initialize method is causing significant hanging on our app. This is significant for us as it is part of our logic in which we check if the user is logged in or not - in which we redirect the user either on our welcome screen or our main home screen. Note that the previous used version was a older version of this sdk 2.17.0. We have also tried to check this user state via currentUserState but the sdk must initialize before we can access this value. Similiar to this we also encounter speed changes to AWSMobileClient getTokens method.

To Reproduce
Steps to reproduce the behavior:

  • Update SDK Version from 2.17.0 to 2.36.3
  • Initialize mobileClient on didFinishLaunching(with options)

Observed Behavior

  • There is a 4-5 sec delay when the app is launched

Expected Behavior

  • The app should launch as soon as the LaunchScreen is dismissed

Code Snippet

let mobileClient = AWSMobileClient(configuration: APIConstants.AWSCredentials.mobileClientEndpoint)

func initializeUser(completion: @escaping GenericClosure) {

        DispatchQueue.global(qos: .userInitiated).async {
            mobileClient.initialize { (userState, _) in
                if let userState = userState {
                    switch userState {
                    case .signedIn:
                        
                        completion(true, "Success", nil)
                        
                    default:
                        completion(false, "Failed", nil)
                    }
                } else {
                    completion(false, "Failed", nil)
                }
            }
        }
    }

Areas of the SDK you are using (AWSMobileClient, Cognito, Pinpoint, IoT, etc)?

  • AWSMobileClient

Screenshots
If applicable, add screenshots to help explain your problem.

Environment(please complete the following information):

  • SDK Version: 2.36.3
  • Dependency Manager: CocoaPods
  • Swift Version : 4.0
  • Xcode Version: 15.4

Device Information (please complete the following information):

  • Device: iPhone 14 Plus
  • iOS Version: 17.5.1
  • Specific to simulators:
  • All devices are being effected

Thank you for posting the issue - could you please share verbose logs with sensitive information removed and reproduction steps? Have you made any changes to your backend resources recently? Which region is the cognito resource located in and from which region is it accessed?