Closed hossamghareeb closed 4 years ago
hi @hossamghareeb what version of the Google SDK are you trying to use? I believe the Google SDK needs an update to fix some off the issues [#1993] we have seen with iOS13 and just want to make sure this isn't related to that issue as well.
Hey @kneekey23, I'm using GoogleSignIn 4.4. I think the issue is in version 5.0 right?
Also let me understand one thing, I'm using hosted UI option so what I understand is that the login will be done in SFSafariViewController
and it has nothing to do with Google SDK
Seeing the same issue using AWS Cognito login as well.
I am able to reproduce this one without using either a Google Authentication option (simply using the standard AWS Cognito Login) and not a hosted UI.
I have a similar issue in my iOS app. AWSCognitoService.client.getTokens
completion doesn't get called even though AWSCognitoService.client.isSignedIn
is true.
The AWSCognitoService.client referred above is AWSMobileClient provided by the SDK that initialised with my aws pool configuration.
static let client = AWSMobileClient(configuration: awsConfiguration)
We have set the token expiry to one day and when I launch the iOS app after a day, the completion doesnt get called.
The SDK version that Im using is as below. The issue can be reproduced on both iOS12 and 13.
- AWSAuthCore (2.12.1):
- AWSCore (= 2.12.1)
- AWSCognitoIdentityProvider (2.12.1):
- AWSCognitoIdentityProviderASF (= 1.0.1)
- AWSCore (= 2.12.1)
- AWSCognitoIdentityProviderASF (1.0.1)
- AWSCore (2.12.1)
- AWSMobileClient (2.12.1):
- AWSAuthCore (= 2.12.1)
- AWSCognitoIdentityProvider (= 2.12.1)
We're facing with this issue too.
Ok, I think I found what is the problem. I did some intensive debugging in what is happing inside awsClient.getTokens
and I found that there is some logic is being sent to be executed in the main queue while I'm already blocking the main queue to get the new token synchronously. So when I removed the code of using DispatchGroup
, the function returns as expected without locking. I don't remember what is this called, maybe deadlock
:).
This should be documented somewhere by the AWS iOS team as I spent too much time to figure out this issue.
@hossamghareeb I tried moving awsClient.getTokens
to background thread and Im still not getting the call back. Do you know anything else that would help? Some details here
@hossamghareeb Could you please provide some code sample that fixed your issue.
Ideally getToken request should not happen in main thread. When the session expires, getToken will wait for the user to be signed in again to return with a result. You have to listen to signIn event by adding yourself as a listener :
AWSMobileClient.default().addUserStateListener(self) { (state, dict) in
}
When you get the state as signedOut, call AWSMobileClient.default().signIn
to authenticate the user again and the getToken
will return.
@hossamghareeb We use the main queue for certain activities using the Drop-in UI [edit: and Hosted UI], so if you're blocking the main thread on a request, that could cause issues. In general a best practice is to perform these kinds of activities asynchronously and invoke callbacks when you receive a response, so you don't block your working thread. That said, if you have encountered a use case where you must block the main thread (for example, the SDK requires you to invoke something on the main thread and blocks until complete) we'd love to know about that since we definitely don't want to build that potential deadlock into the SDK.
@palpatim my use case was that the project i'm working on is assuming that the token is loaded synchronously as it was not a JWT token. When I moved to Cognito, fetching the token is done async which required me to do some refactoring in many places so I decided to block the thread till I fetch the token, it worked at the beginning but not with hosted UI as you see. I used now URLProtocol
and it helped me fix the problem without refactoring.
@hossamghareeb Thanks for the clarification. It sounds like everything is working as designed--the asynchronous parts are asynchronous as designed, and invoking sign in UI methods on the main thread. I'm going to close this issue, but please feel free to open a new one if you encounter other problems.
Describe the bug I login with Google via hosted UI and all goes well. Then I call
getTokens
to get the access token to use it to hit our services and also all goes well. Then next time I open the app, when I callgetTokens
again, it never returns and keeps stuck inside. When I callinitialize
the state returned is corrected and it sayssignedIn
. I don't see anything/errors in logSetting up Cognito:
Login with Google:
Getting Token:
To Reproduce Steps to reproduce the behavior:
getTokens
and it will never returnExpected behavior completion block to be called and get the tokens again.
Environment(please complete the following information):
Device Information (please complete the following information):