sjhoeksma / cordova-plugin-keychain-touch-id

Touch ID plugin with saving password in keychain for IOS and android
87 stars 160 forks source link

Android: Crash on Authentication-Dialog #16

Open y-marion opened 7 years ago

y-marion commented 7 years ago

I am using your plugin and some of my users are reporting random crashes on Android with the following error message:

java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at android.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1434)
at android.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1452)
at android.app.BackStackRecord.commitInternal(BackStackRecord.java:707)
at android.app.BackStackRecord.commit(BackStackRecord.java:671)
at android.app.DialogFragment.show(DialogFragment.java:231)
at com.cordova.plugin.android.fingerprintauth.FingerprintAuth$1.run(FingerprintAuth.java:405)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6247)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)

I have not been able to replicate this exception exactly, so i was wondering if someone here had some insight on what could be going on. In the repository, on which the Android part is based on, a similar error has been recorded and fixed, although i'm unsure if this is applicable here: https://github.com/mjwheatley/cordova-plugin-android-fingerprint-auth/issues/46

see https://github.com/y-marion/cordova-plugin-keychain-touch-id/commit/2617e487cffa63e2e49a5aa12c6cc5589ceed677 for the implementation which fixes this bug for me

MoemenMostafa commented 6 years ago

I am facing the same issue were the application crashes with exactly the same exception.

In my case the crash happens when the plugin is called while the application is running in the back ground (not active in the foreground). It is happening a lot in my application because I have a timeout that triggers the application to logout the user and display the login screen where the plugin is called there.

In that login page I am using the following code:

 this.keychainTouchId.isAvailable()
      .then( ()=> {
        this.keychainTouchId.verify("PIN", "SmartPass")
          .then ((password) => {
          // some code ...
        });
      });
MoemenMostafa commented 6 years ago

I had fixed the issue in the above commit https://github.com/MoemenMostafa/cordova-plugin-keychain-touch-id/commit/a472a56a92814fcfdd197daaa670383cb82f9d9b and I had created a pull request

malwatte commented 6 years ago

Thanks @MoemenMostafa , Is there going to be a new version release for the fix?

MoemenMostafa commented 6 years ago

@malwatte, you can use my branch until @sjhoeksma merge my pull request.

You can install it as follows:

cordova plugin add https://github.com/MoemenMostafa/cordova-plugin-keychain-touch-id