-
Notifications
You must be signed in to change notification settings - Fork 117
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
CredentialStoreClient$loadCredentials$2$1.invoke java.lang.IllegalStateException - Already resumed #2368
Comments
@eeatonaws any update as I am getting lots of this error for my production customer. I cannot reproduce it locally but my production user getting this error which I am getting from crashlytics. |
Hi @androidcodehunter thank you for reporting this. I am actively looking into this and will respond with an answer/fix once I have had the chance to dig deep into why this is happening. |
@androidcodehunter can you enable logging in the application class by adding the following line BEFORE your auth plugin addition and please paste your logs when the exception occurs. This will help us understand the flow from where the problem is potentially occurring from and fix it since we are unable to reproduce it locally.
|
@gpanshu The issue is I am not able to reproduce it locally. Only this is happening for production user. Could you suggest to add any specific log in my crash analytics library before the described code execution. |
I have the same issue and this happens in the production environment in my case that's happen after 5-6 days the users start using the app
|
@gpanshu I am also collecting data from background worker. Very few user getting this issue. Could you help me what logs I could collect before this crash happening. I might add some breadcumb or logs. |
@androidcodehunter @minaairsupport I see version 2.4.0 mentioned, but is it possible these crashes are being observed on devices running older versions of the application (possibly running older versions of Amplify?) |
@tylerjroach Thank you for quick update. I am using amplify version Operating systems Device states Devices Looking at the stats, it's looks like this issue mostly happening when user in background state. |
@androidcodehunter Had you previously deployed your app running Amplify v2.0.0? I understand that the current version of your app is running Amplify v2.4.0, but curious if that is also the version you are seeing in your crash reports, or if these reports could be coming from customers that may not have updated to newer versions of your application. |
@tylerjroach yes I did deployed old amplify version as well but I think both versions have this same issue. This crash is happening to v2.4.0 as well. I updated the Amplify hoping for it would be fixed but I think the latest version have the same issue. |
@tylerjroach @gpanshu Looking at the Amplify source code, couldn't we use
I don't have much idea about the internal amplify code but with suspendCancellableCoroutine we could check if the continuation is active or not. Because with frequent callback, this function could call again until it finishes. As a result it would give crash. |
listenForResult should only ever call it's onSuccess or onError 1 single time. As a result, the continuation should only be called 1 time. While we can further mitigate the continuation being fired twice, it would only be masking the actual problem. We're still looking at all paths to determine what might be causing the continuation to fire a second time. |
Hello, |
@reisfernanda Thank you for your report, especially around the details of the crash happening within the first 2 seconds of the users session. With the other reports happening while the user is in the background, I'm wondering if its possible these crashes are happening with the application is being recreated, running through the app's onCreate, and calling Amplify.configure. @minaairsupport I know you have mentioned the crash is being seen 5-6 days after launch, but is it possible the app is being re-launched in the background, rather than a single continuous session? There is a but that I worked on in Amplify v2.8.x that seems unrelated at first glance, but may resolve this issue. #2402 Here, It is possible that There's a migration process to migrate credentials from v1 -> v2 of Amplify that happens upon each Amplify.configure call. If fetchAuthSession (or a similar call is made while configuration is in process), it may be possible that in rare scenarios, both processes hit our CredentialStore state machine at the same time, causing multiple fires into the continuation. While we will continue investigating and searching for a root cause, it may be beneficial to upgrade to the latest version of Amplify to see if the crash was resolved with the linked bug fix. |
@tylerjroach thank you for the update. When the app is in background, android OS could kill app and restart if there are any memory constraints. We don't know what actually happening in the user end but kill app could happen anytime. I am going to update the library and will let you know the results. |
@androidcodehunter Thank you, will be keeping an eye on the thread for updates. |
@tylerjroach thanks for the reply I am using 2.5.0 I have I have a part of my code also will try upgrading the lib to the latest and see |
Hello, |
@reisfernanda Thank you for letting us know. We will continue looking to find the root cause. |
@tylerjroach I have updated the library and rolled out the release. Looks like the issue still persists. |
Recently updated to (an admittedly far from latest) |
Hi, Crashlytics didn't report that error till after the update. We have around 5k daily users and in the last 7 days, 84 users had this crash 95 times. Crashlytics also reported that 55% of them were in the background and 80% of those crashes happened in the first 3 seconds after app launch. Couldn't reproduce it locally as everyone unfortunately but just thought the extra input might be helpful. |
@Gesraha101 Thank you for the additional info. Any info helps here. If 80% are in the first 3 seconds after app launch, and 55% are in the background, I'm assuming you have some background process that are waking up the application? |
@tylerjroach you might be on to something. To answer your question, the app should not be doing anything in the background. But you know, your comment just reminded me of a strange behavior that I ignored a while ago. I noticed that when I kill the app, it launches again in the background in the next 10 seconds or so and keeps running for about 5 mins. At first, I thought it might be something done in the background by amplify and that it is normal. However, seeing your observation made me take a second look by copying Amplify's module to a new project and checking the same behavior and surely enough, it didn't happen in the new project so that might explain why 55% of them crash in the background. Will probably need to look for any memory leaks or other libraries that cause that behavior. That's one mystery down for me :) |
Hello @tylerjroach, do you have any update on this issue? Thank you! |
I've taken some time today to diagnose and should have a PR up today, and once merged, a fix should go out in the next release. |
Nice, that would help us a lot. Thank you. |
This bug should be fixed in the latest release (2.11.2). Thanks everyone for your reports! |
|
Before opening, please confirm:
Language and Async Model
Kotlin
Amplify Categories
Authentication
Gradle script dependencies
com.amplifyframework:aws-auth-cognito:2.4.0
Environment information
Please include any relevant guides or documentation you're referencing
No response
Describe the bug
I am using Amplify Authentication library. I am trying to call this function multiple times in the background when it return false,
But sometimes I found there are some crash happening in the Amplify library. Here is the crash output,
I went to check the library code to see where this crash happening. I found it is happening in below code where continuation gets called multiple time,
Could you tell me what to do to prevent this error happening as it crashing my app.
Reproduction steps (if applicable)
No response
Code Snippet
// Put your code below this line.
Log output
amplifyconfiguration.json
No response
GraphQL Schema
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: