smstuebe / xamarin-fingerprint

Xamarin and MvvMCross plugin for authenticate a user via fingerprint sensor
Microsoft Public License
491 stars 116 forks source link

onSaveInstanceState exeption #29

Closed ronpf closed 6 years ago

ronpf commented 7 years ago

I'm seeing this on my Samsung S5 but it's difficult to reproduce. After a successful result the dialog disappears as well as the app and then it crashes. Tends to happen after an unsuccessful or canceled action but not always...

Android Unhandled exception: Java.Lang.IllegalStateException: Can not perform this action after onSaveInstanceState at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3819/c1d1c79c/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x000a7] in /Users/builder/data/lanes/3819/c1d1c79c/source/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:12083 at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00068] in /Users/builder/data/lanes/3819/c1d1c79c/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:31 at Android.App.DialogFragment.Dismiss () [0x00000] in /Users/builder/data/lanes/3819/c1d1c79c/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Android.App.DialogFragment.cs:243 at Plugin.Fingerprint.Dialog.FingerprintDialogFragment+d20.MoveNext () [0x00098] in C:\Projekte\xamarin-fingerprint\src\Plugin.Fingerprint.Android\Dialog\FingerprintDialogFragment.cs:128 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3819/c1d1c79c/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 at System.Runtime.CompilerServices.AsyncMethodBuilderCore.m0 (System.Object state) [0x00000] in /Users/builder/data/lanes/3819/c1d1c79c/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1018 at Android.App.SyncContext+cAnonStorey0.<>m0 () [0x00000] in /Users/builder/data/lanes/3819/c1d1c79c/source/xamarin-android/src/Mono.Android/Android.App/SyncContext.cs:18 at Java.Lang.Thread+RunnableImplementor.Run () [0x0000b] in /Users/builder/data/lanes/3819/c1d1c79c/source/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:36 at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in /Users/builder/data/lanes/3819/c1d1c79c/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Java.Lang.IRunnable.cs:81 at (wrapper dynamic-method) System.Object:de2042cc-35ca-4fd5-b8c6-97b660a4057e (intptr,intptr) --- End of managed Java.Lang.IllegalStateException stack trace ---

[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: Java.Lang.IllegalStateException: Can not perform this action after onSaveInstanceState [mono-rt] --- End of managed Java.Lang.IllegalStateException stack trace --- [mono-rt] java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState [mono-rt] at android.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1428) [mono-rt] at android.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1446) [mono-rt] at android.app.BackStackRecord.commitInternal(BackStackRecord.java:687) [mono-rt] at android.app.BackStackRecord.commit(BackStackRecord.java:663) [mono-rt] at android.app.DialogFragment.dismissInternal(DialogFragment.java:301) [mono-rt] at android.app.DialogFragment.dismiss(DialogFragment.java:267) [mono-rt] at md54832021a7e88cfc4565df97a94342004.TaskAnimationListener.n_onAnimationEnd(Native Method) [mono-rt] at md54832021a7e88cfc4565df97a94342004.TaskAnimationListener.onAnimationEnd(TaskAnimationListener.java:41) [mono-rt] at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1239) [mono-rt] at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:766) [mono-rt] at android.animation.ValueAnimator$AnimationHandler$1.run(ValueAnimator.java:801) [mono-rt] at android.view.Choreographer$CallbackRecord.run(Choreographer.java:920) [mono-rt] at android.view.Choreographer.doCallbacks(Choreographer.java:695) [mono-rt] at android.view.Choreographer.doFrame(Choreographer.java:628) [mono-rt] at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:906) [mono-rt] at android.os.Handler.handleCallback(Handler.java:739) [mono-rt] at android.os.Handler.dispatchMessage(Handler.java:95) [mono-rt] at android.os.Looper.loop(Looper.java:158) [mono-rt] at android.app.ActivityThread.main(ActivityThread.java:7224) [mono-rt] at java.lang.reflect.Method.invoke(Native Method) [mono-rt] at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) [mono-rt] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) [mono-rt]

hvaughan3 commented 7 years ago

I got this issue also. I thought it was because I tried assigning a custom FingerprintDialogFragment that attempted to remove the fallback button within OnCreateView but it sounds like maybe that was not the cause. Pretty sure the issue happened on a LGE Nexus 5X running Android 7 (my project is targeting API 24).

Do you know of any way to catch that exception in the meantime?

jmro20 commented 7 years ago

Maybe this could help http://motzcod.es/post/153758887292/xamarinforms-javalangillegalstateexception

hvaughan3 commented 7 years ago

@jmro20 Hey nice find and thanks. I have definitely had to add some Task.Delay()s before but never understood why. I will give this a try.

ronpf commented 7 years ago

@jmro20 thanks! Added a 100ms delay and got it to fail with the onSaveInstanceState error: ... var result = await CrossFingerprint.Current.AuthenticateAsync() await Task.Delay(100); ...

Bumped it to 200ms and I haven't been able to make it fail yet... I am still seeing intermittently the app minimizing after the dialog is dismissed...but at least it's not crashing like it was.

JMarson commented 7 years ago

This issue is still present - for a reliable exception, just sleep your device while the dialog is on screen. No custom dialog built, just using the default. Any idea on a fix? Or a workaround? Thanks!

smstuebe commented 7 years ago

@JMarson what do you mean with sleep? I tired to force the sleep state of the app, but had no success. Have you tested on a Samsung device or something different?

PavelLeonenko commented 7 years ago

@smstuebe I have this issue on Nexus 5X. Steps to reproduce:

Now I'm trying to find a workaround for it, but it would be great if it was fixed inside the plugin.

JMarson commented 7 years ago

@smstuebe - sorry I meant the same as @PavelLeonenko - lock the device (press power button) and then after about 3 seconds the exception fires. I'm running on a Pixel XL.

smstuebe commented 7 years ago

ok. I'll try to reproduce it at the weekend. Oh... CS:GO major... maybe in between the matches :P

pavel-leonenko commented 7 years ago

Hi @smstuebe, any updates on this issue? I hope CO:GO was not too exciting :)

smstuebe commented 7 years ago

CS:GO major was too exciting and I spent some time on the BLE plugin... -> no progress, yet.

smstuebe commented 7 years ago

Ok. Investigated it and found the issue. Fixing it, is not that easy, because there are some race conditions, Stay tuned...

smstuebe commented 7 years ago

Maybe easier to solve than I thought -> beta release tomorrow.

smstuebe commented 7 years ago

now in 1.4.6-beta1. Would be cool, if you can test. Try to crash it with some creative lifecycle events :)

JMarson commented 7 years ago

That's the fix! Thanks @smstuebe!

pavel-leonenko commented 7 years ago

@smstuebe thank you! It works :)

ghost commented 6 years ago

Hi @smstuebe For me, nothing works! I tried 1.4.7 and 1.4.6-beta1 versions. Tested on "Xiaomi Redmi Note 4" device.

On the start of the Android application, I have Activity splash screen which opens the Main activity with a login screen. On the login page, I'm calling fingerprint service on appearance. When a device is unlocked then everything works fine. If I lock device after the click on an application, I get crash. Could you please help me?

shivanimangla13 commented 5 years ago

I am also using 1.4.7 version.But the issue still persists. Please help. I am using Samsung Galaxy A7.

.call the fingerprint dialog .lock the device .when the device is unlocked, the application crashes with the same stacktrace as above.

SumitSingh2407 commented 5 years ago

I am also using 1.4.7 version.But the issue still persists. Please help. I am using Samsung Phones and 1plus 5,

Also in Nexus phones it shows different scenario like: After unlocking the device instead of crash the fingerprint popup dissapears.