Assigned
Status Update
Comments
gu...@gmail.com <gu...@gmail.com> #2
Automated by Blunderbuss job android-credential-manager-autoassigner for config android_credman_config for component 1301097.
gu...@gmail.com <gu...@gmail.com> #3
Comment has been deleted.
gu...@gmail.com <gu...@gmail.com> #4
Comment has been deleted.
bl...@google.com <bl...@google.com> #6
Automated by Blunderbuss job android-credential-manager-autoassigner for component 1301097.
en...@gmail.com <en...@gmail.com> #7
The main problem is the API, having an API like credentialManager.getCredentialAsync(.., callback ...) does not allow to maintain state across activity recreation. so even if the leak gets fixed, the Credential activity would stay open, and there would be no way to pass the result to the requesting activity.
For instance, the previous Google Auth API was fine, the newest Identity.getAuthorizationClient/authorization API is also fine because it passes the result to requesting activity using registerForActivityResult/ActivityResult API.
me...@gmail.com <me...@gmail.com> #8
I understand that this may not be considered a serious leak for app developers since it only occurs in the authentication flow, a flow most users will go through once or twice. However, it has been two years since the first report. Is there anything we can do to fix it?
Description
Version used:
implementation "com.google.android.libraries.identity.googleid:googleid:1.1.0"
implementation("androidx.credentials:credentials:1.3.0-alpha01")
implementation("androidx.credentials:credentials-play-services-auth:1.3.0-alpha01")
Devices/Android versions reproduced on: Pixle4 Android13
I get the result and send it to the server, but then I destroy the login activity and LeakCanary tells me about the memory leak
fun googleLogin(){
val mCredentialManager = CredentialManager.create(this)
val googleIdOption: GetGoogleIdOption = GetGoogleIdOption.Builder()
.setFilterByAuthorizedAccounts(false)
.setServerClientId(appContext.getString(R.string.google_web_id))
.build()
val request: androidx.credentials.GetCredentialRequest = androidx.credentials.GetCredentialRequest.Builder()
.addCredentialOption(googleIdOption)
.build()
val ioCoroutineScope = CoroutineScope(Dispatchers.IO)
ioCoroutineScope.launch {
try {
val result = mCredentialManager.getCredential(this@LoginActivity, request)
withContext(Dispatchers.Main) {
if (result != null) {
//Omit the step of sending data to the server
finish()
} else {
}
}
} catch (e: GetCredentialException) {
makeToast(e.toJson())
}
ioCoroutineScope.cancel()
}
}
Attach logs and screen recorders