firebase / FirebaseUI-Android

Optimized UI components for Firebase
https://firebaseopensource.com/projects/firebase/firebaseui-android/
Apache License 2.0
4.64k stars 1.84k forks source link

Leak detected with LeakCanary #1938

Open ArcherEmiya05 opened 3 years ago

ArcherEmiya05 commented 3 years ago

Step 1: Are you in the right place?

Yes

Step 2: Describe your environment

Step 3: Describe the problem:

When closing the app this leak shows frequently even though there is no listener at all

Steps to reproduce:

  1. Add LeakCanary to app
  2. Implement Firebase Auth UI (PhoneAuth)
  3. Try to test it by logging in then open and close the app

Observed Results:

04-29 02:24:27.780 12111-12111/com.myapp.com D/LeakCanary: ​
    ┬───
    │ GC Root: Global variable in native code
    │
    ├─ com.google.firebase.auth.api.fallback.service.zza instance
    │    Leaking: UNKNOWN
    │    Retaining 506 B in 11 objects
    │    zza instance of com.google.firebase.auth.api.fallback.service.FirebaseAuthFallbackService
    │    ↓ zza.zza
    │          ~~~
    ╰→ com.google.firebase.auth.api.fallback.service.FirebaseAuthFallbackService instance
    ​     Leaking: YES (ObjectWatcher was watching this because com.google.firebase.auth.api.fallback.service.
    ​     FirebaseAuthFallbackService received Service#onDestroy() callback and Service not held by ActivityThread)
    ​     Retaining 478 B in 10 objects
    ​     key = ac038340-ead9-4df3-856e-d554d8a60d6b
    ​     watchDurationMillis = 5224
    ​     retainedDurationMillis = 219
    ​     mApplication instance of com.myapp.com.App
    ​     mBase instance of android.app.ContextImpl

    METADATA

    Build.VERSION.SDK_INT: 21
    Build.MANUFACTURER: Xiaomi
    LeakCanary version: 2.7
    App process name: com.myapp.com
    Stats: LruCache[maxSize=3000,hits=122,misses=123181,hitRate=0%]
    RandomAccess[bytes=11632648,reads=123181,travel=39030419727,range=42073912,size=55116410]
    Heap dump reason: 1 retained objects, app is not visible
    Analysis duration: 30287 ms

Expected Results:

No leak

Relevant Code:


private fun checkAuthStatus() {
        if (FirebaseAuth.getInstance().currentUser == null)
            startActivityForResult(authRequest(), authRequestCode)
        else
            startMain()
    }

  private fun authRequest(): Intent {
        val builder = AuthUI.getInstance().createSignInIntentBuilder()
            .setTheme(R.style.AuthStyle)
            .setLogo(R.mipmap.ic_launcher)
            .setIsSmartLockEnabled(true)
            .setAvailableProviders(getProviderList())
        builder.setTosAndPrivacyPolicyUrls(
            "https://firebase.google.com/terms/",
            "https://firebase.google.com/policies/analytics"
        )
        return builder.build()
    }

    private fun getProviderList() : List<IdpConfig>{
        val providers: MutableList<IdpConfig> = ArrayList()

        providers.add(PhoneBuilder().build())
        return providers
    }
yuchenshi commented 3 years ago

Hi, thanks for filing this issue! We are unable to promise any timeline for this, but if others also have this issue, adding a +1 on this issue can help us prioritize adding this to the roadmap.

(Googler-only internal tracking bug: b/187073530)

JamshedAlamQaderi commented 1 year ago

I am also having this issue

JamshedAlamQaderi commented 1 year ago

+1