Possible memory leak during authentication
jbsohn opened this issue · 2 comments
jbsohn commented
Checklist
- The issue can be reproduced in the Auth0.Android sample app (or N/A).
- I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
- I have looked into the API documentation and have not found a suitable solution or answer.
- I have searched the issues and have not found a suitable solution or answer.
- I have searched the Auth0 Community forums and have not found a suitable solution or answer.
- I agree to the terms within the Auth0 Code of Conduct.
Description
After the Auth0 login is shown LeakCanary is logging a small memory leak. I have recreated the issue in a small sample app. I have included the MainActivity in the Reproduction field below. The leak-canary.log attached to this issue has the details. If we roll back to version 2.8.1 we are not seeing the issue.
Reproduction
I created a new Android app from template with this code in the MainActivity:
package com.example.auth0memtest
import android.os.Bundle
import android.view.View
import android.widget.Button
import androidx.appcompat.app.AppCompatActivity
import com.auth0.android.Auth0
import com.auth0.android.authentication.AuthenticationException
import com.auth0.android.callback.Callback
import com.auth0.android.provider.WebAuthProvider
import com.auth0.android.result.Credentials
class MainActivity : AppCompatActivity() {
private lateinit var account: Auth0
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
account = Auth0(
"TODO",
"TODO"
)
setContentView(R.layout.activity_main)
val button = findViewById<View>(R.id.button) as Button
button.setOnClickListener { loginWithBrowser() }
}
private fun loginWithBrowser() {
// Setup the WebAuthProvider, using the custom scheme and scope.
WebAuthProvider.login(account)
.withAudience("TODO")
.withScheme("TODO")
.withScope("openid profile email offline_access")
// Launch the authentication passing the callback where the results will be received
.start(this.applicationContext, object : Callback<Credentials, AuthenticationException> {
// Called when there is an authentication failure
override fun onFailure(exception: AuthenticationException) {
// Something went wrong!
}
// Called when authentication completed successfully
override fun onSuccess(credentials: Credentials) {
// Get the access token from the credentials object.
// This can be used to call APIs
val accessToken = credentials.accessToken
}
})
}
}
The loginWithBrowser method was copied from the Auth0 quick start.
Additional context
I suspect the issue is in AuthenticationActivity or the Google library which Auth0 is using.
Auth0.Android version
2.10.1
Android version(s)
7.0 and 13.0
poovamraj commented