-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Amplify Auth calls no longer fire after screen orientation change #2964
Comments
Thank you for providing details for us to replicate. We will look into this. As a way to unblock yourself, I would also look into using a MVVM pattern where |
Thanks, we did also put in some caching for the value to avoid having to call |
@cHunter791 I don't doubt that you are running into a lockup, as we had a very similar case that was previously fixed #2822. I am, however, unable to replicate it with the description you have given.
After each rotation, I am seeing I also want to make sure that you are initializing Amplify within the extended Application class, not the Activity. Can you confirm this? |
@tylerjroach we are initializing Amplify in the extended Application class yes. I will need to see if I can get some time to put together a sample app. I'll look into doing this. One thing we are doing differently that your code snippet is injecting the
Could this potentially cause an issue? |
That should not cause an issue. We will be on the lookout for a sample app! |
@tylerjroach I have spent this afternoon attempting to recreate in a sample application with no success. Like you, after performing screen rotations the Amplify calls complete successfully. Here is some other information for how we are using Amplify in our application, in case you can spot anything that might odd Originally we would call We are moving towards using the Kotlin Amplify functions for Coroutine support, existing Amplify functions in the app are using the Callbacks approach. I noticed in the Application we are using We are requesting the access token in the following places when we perform a screen rotation change. Could we be accessing Amplify too many times? I checked logs and we are accessing Amplify 9 times after screen rotation for If there is nothing that comes to mind we can close this issue as we cannot reproduce and we have a workaround |
All that you have just stated sounds fine. I am not sure what scenario is resulting in a lockup, but if you have a sufficient workaround and we are not able to replicate, you can close the issue if you are no longer concerned. If anything changes, please let us know |
Will do, thanks again for your time and help! |
This issue is now closed. Comments on closed issues are hard for our team to see. |
Before opening, please confirm:
Language and Async Model
Kotlin - Coroutines
Amplify Categories
Authentication
Gradle script dependencies
Environment information
Please include any relevant guides or documentation you're referencing
https://docs.amplify.aws/android/build-a-backend/auth/set-up-auth/
Describe the bug
We have code in our MainActivity on activity create to check a user's auth status using Amplify (
fetchAuthSession
) to decide where to navigate them initially. This works on initial app open and returning from the background. The MainActivity is locked to portrait orientation however we have a video player in the app that will force the MainActivity into landscape mode. Doing this destroys and recreates the MainActivity.We noticed that after a user navigates to the video player and then back to the original screen, when we attempt to check their auth status to navigate them to correct page the
fetchAuthSession
call to Amplify never completes. Digging into theAWSCognitoAuthPlugin
code we see thefetchAuthSession
coroutine being added to thequeueChannel
but then it never gets consumed.Reproduction steps (if applicable)
No response
Code Snippet
MainActivity
UserAuthStateRepository
Log output
amplifyconfiguration.json
No response
GraphQL Schema
Additional information and screenshots
As a workaround we specify the configuration changes we will handle ourselves for the MainActivity to include orientation change. This means that the activity will not be destroyed and recreated and we no longer run into this issue. However I do not believe we should have to do this to get around this issue. Amplify calls should continue to be ran even if the Activity is destroyed and recreated
The text was updated successfully, but these errors were encountered: