fython / BiometricPromptCompat

A Thrid-party BiometricPrompt compat library.
Apache License 2.0
263 stars 23 forks source link

Leaked window DecorView #2

Open andrewpmoore opened 6 years ago

andrewpmoore commented 6 years ago

I'm getting this error:

2018-06-27 16:03:38.323 27998-27998/com.mypossibleself.app E/WindowManager: android.view.WindowLeaked: Activity com.example.SecurityEntryActivity has leaked window DecorView@1635e7a[Security] that was originally added here
        at android.view.ViewRootImpl.<init>(ViewRootImpl.java:572)
        at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:331)
        at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:97)
        at android.app.Dialog.show(Dialog.java:419)
        at moe.feng.support.biometricprompt.BiometricPromptApi23Impl.authenticate(BiometricPromptApi23Impl.java:133)
        at moe.feng.support.biometricprompt.BiometricPromptCompat.authenticate(BiometricPromptCompat.java:107)

It's triggering when trying to call biometricPrompt.authenticate.

It's only on some phones and only occasionally.

fython commented 6 years ago

Dialog will be created once when building BiomtericPromptCompat(Api23Impl).

Could it prevent from causing this error if build BiometricPromptCompat every time you want to call authenticate method?

andrewpmoore commented 6 years ago

That is what I'm doing, I've a bioDialog method which has the following in it:

            BiometricPromptCompat biometricPrompt;
            biometricPrompt = new BiometricPromptCompat.Builder(SecurityEntryActivity.this).setTitle(getString(R.string.securityPrompt)).setNegativeButton(getString(R.string.use_password), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    pinDialog();
                }
            }).build();

            cancellationSignal = new CancellationSignal();
            biometricPrompt.authenticate(cancellationSignal, SecurityEntryActivity.this);

I know it would deviate away from the bioPrompt api, but maybe a way to make a call to dismiss the dialog would help. From reading it may be that when the activity pauses I've got the activity finishing and I've read that the error can happen if your calling finish with a dialog still open.

fython commented 6 years ago

Thanks for your suggestion. After finishing what I am busy these days, I will fix it.

Sorry for inconvenience. BTW, I am building AbstractBiometricPromptDialogFragment which can keep dialog states for pre-P devices although it's completely not Compat-like (I am thinking how to improve its usage.).