Quickstart-android: Memory leak with PhoneAuthProvider

Created on 23 Aug 2017  路  9Comments  路  Source: firebase/quickstart-android

Step 1: Are you in the right place?

Issues related to the code in this repository.

Step 2: Describe your environment

  • Android device: Nexus 5X / Moto G5 Plus
  • Android OS version: 7.1.2 / 7.0.0
  • Google Play Services version: 11.2.0
  • Firebase/Play Services SDK version: 11.2.0

Step 3: Describe the problem:

PhoneAuthActivity is leaking. I believe, it might be OnVerificationStateChangedCallbacks, which we are sending on call to verifyPhoneNumber.

Steps to reproduce:

  1. Launch the app
  2. Select "PhoneAuthActivity" for phone based authentication
  3. Sign in.
  4. Click back.

Observed Results:

  • Memory leak is coming on hprof reports.

Leak track 1:

com.google.firebase.quickstart.auth.PhoneAuthActivity@317662720 (0x12ef2600)
--- (leak) zwbWR in com.google.android.gms.internal.jw@314986400 (0x12c64fa0)
------- (leak) zzbXd com.google.android.gms.internal.kl@314953312 (0x12c5ce60)
----------- (leak) zwbWR in com.google.android.gms.internal.jw@314986400 (0x12c64fa0)
------- com.google.android.gms.internal.jb@314960960 (0x12c5ec40)
--- android.support.v7.widget.AppCompatTextView@317902848 (0x12f
--- com.google.android.gms.internal.jb@314960960 (0x12c5ec40)
--- android.support.v7.widget.AppCompatTextView@317902848 (0x12f2d000)
--- android.app.ContextImpl@317160464 (0x12e77c10)
--- android.support.v7.widget.AppCompatEditText@317910016 (0x12f2ec00)
--- com.android.internal.policy.PhoneLayoutInflater@317202288 (0x12e81f70)

Leak track 2:
com.google.android.gms.internal.zzdjv@721758912 (0x2b052ac0)
--- (leak) zzlie in com.google.android.gms.internal.zzdkk@722195072 (0x2b0bd280)
------ zzlhl in com.google.android.gms.internal.zzdjv@721758912 (0x2b052ac0)
------ java.lang.ref.FinalizerReference@722192712 (0x2b0bc948)
--- zzhlc in com.google.android.gms.internal.zzdja@722095152 (0x2b0a4c30)
------ zzlhq in com.google.android.gms.internal.zzdjv@721758912 (0x2b052ac0)
------ (leak) zzlie in com.google.android.gms.internal.zzdkk@722195072 (0x2b0bd280)
------ com.google.android.gms.internal.zzdja@722095152 (0x2b0a4c30)

Expected Results:

  • It shouldn't leak the activity.

Relevant Code:

```
It is happening with the provided sample PhoneAuthActivity.

I think, It is leaking at below class
`package com.google.android.gms.internal;

import android.os.RemoteException;
import com.google.android.gms.common.internal.zzbp;
import com.google.android.gms.internal.zzdki;
import com.google.android.gms.internal.zzdle;
import com.google.firebase.auth.PhoneAuthProvider.OnVerificationStateChangedCallbacks;

final class zzdjv extends zzdki {
private final zzdle zzlhf;

public zzdjv(zzdle var1) {
    super(8);
    this.zzlhf = (zzdle)zzbp.zzu(var1);
}

public final void dispatch() throws RemoteException {
    this.zzlhn.zza(this.zzlhf, this.zzlhl);
}

public final void zzbof() {
}

}
`
```

auth internal-bug-filed bug

Most helpful comment

is the memory leak solved?

All 9 comments

@jyothiasapu thanks for reporting this memory leak! I will investigate and let you know if I find anything interesting.

is the memory leak solved?

@samtstern It is leaking activity instances. I am using version 16.1.0. Can you please provide the solution?

I am getting the same issue what @kagile mentioned with 16.1.0. Any new updates on this issue?

Hey all. Apologies for not getting back to this sooner but I have brought this to the attention of the team that makes the Firebase Auth SDK. We'll see what we can find!

In the documentation, there is another method using TaskExecutor.MAIN_THREAD instead of an Activity. I've tried this and no more leak detected.

Passing an executor instead of the activity worked for me:

import com.google.android.gms.common.util.concurrent.HandlerExecutor

phoneAuth.verifyPhoneNumber(phone, 60, TimeUnit.SECONDS, HandlerExecutor(mainLooper), onVerificationStateChangedCallbacks)

Is this issue solved?
I think we need a proper method to detach the onVerificationStateChangedCallbacks, because it causes memory leak in case the Activity is destroyed before verification process is completed!! Any suggestions?

still nothing?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rahuldevanavar91 picture rahuldevanavar91  路  5Comments

shivamsriva31093 picture shivamsriva31093  路  3Comments

udaysrinath picture udaysrinath  路  5Comments

tekinarslan picture tekinarslan  路  5Comments

aselims picture aselims  路  6Comments