xamarin-fingerprint
xamarin-fingerprint copied to clipboard
Crash when restore instance state Android
Currently we encounter a NullReferenceException when Android restores an activity when a FingerprintDialogFragment is visible.
I can reproduce the same issue using the Sample app of this project with the following steps:
Steps to reproduce
-
In Android developer options on your device, enable "Don't keep activities". This will enforce that activities will be destroyed when navigating away from an activity (for example when your app goes to the background).
-
Open the app and call this to get the fragment dialog in an Activity:
var authConfig = new AuthenticationRequestConfiguration (AlternativeAuthenticationTypeText) {
CancelTitle = "Cancel"
};
var result = await CrossFingerprint.Current.AuthenticateAsync (authConfig, cancellationTokenSource.Token);
-
The FingerprintDialogFragment will show up
-
Move the app to the background
-
Move the app to the foreground
Expected behavior
I would expect that I still see the FingerprintDialogFragment visible
Actual behavior
Crash of the app.
Like I said, I can reproduce the issue in the sample app by doing the above steps. I think the _implementation variable is null in method StartAuthenticationAsync() of the FingerprintDialogFragment.cs class
Crashlog
[MonoDroid] UNHANDLED EXCEPTION: [MonoDroid] System.NullReferenceException: Object reference not set to an instance of an object. [MonoDroid] at Plugin.Fingerprint.Dialog.FingerprintDialogFragment.StartAuthenticationAsync () [0x00023] in C:\Projekte\xamarin-fingerprint\src\Plugin.Fingerprint.Android\Dialog\FingerprintDialogFragment.cs:190 [MonoDroid] at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) [0x00000] in <58604b4522f748968296166e317b04b4>:0 [MonoDroid] at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () [0x00000] in /Users/builder/jenkins/workspace/monodroid-multibranch_d16-0/monodroid/external/xamarin-android/src/Mono.Android/Android.App/SyncContext.cs:35 [MonoDroid] at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in /Users/builder/jenkins/workspace/monodroid-multibranch_d16-0/monodroid/external/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:36 [MonoDroid] at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in /Users/builder/jenkins/workspace/monodroid-multibranch_d16-0/monodroid/external/xamarin-android/src/Mono.Android/obj/Release/android-28/mcw/Java.Lang.IRunnable.cs:81 [MonoDroid] at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.32(intptr,intptr) [Mono] Loading reference 2 of HockeySDK.AndroidBindings.dll asmctx DEFAULT, looking for System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e [Mono] Assembly Ref addref HockeySDK.AndroidBindings[0x7858a60680] -> System[0x7858b77900]: 22 [zygote64] JNI RegisterNativeMethods: attempt to register 0 native methods for android.runtime.JavaProxyThrowable
Configuration
Version of the Plugin: 1.4.9
Platform: found on Android 8.0 (probably on every Android version).
Device: Samsung Galaxy S7
Hi @stefan89,
I'm the friendly issue checker. Thanks for using the issue template :star2: I appreciate it very much. I'm sure, the maintainers of this repository will answer, soon.
I have also seen this. I know that different people has had this crash. Meaning i think this also happens when mobile is left in background for a while.
Additional information: Ive recorded 4 devices: Samsung galaxy s7 (HeroLte) Samsung galaxy s7 Edge (hero2Lte) Samsung galaxy s8 (DreamLte) Samsung galaxy s9+ (Star2Lte)
It's generally when it tries to lock in the background ... I usually lock on suspend and then disable the lock timer if you are using one
We are experiencing this as well:
FingerprintDialogFragment.OnResume () Fragment.n_OnResume (System.IntPtr jnienv, System.IntPtr native__this) (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.27(intptr,intptr)
Affected OSs to date:
- 7.0
- 8.1.0
- 9
Affected devices to date:
- LG Stylo 4
- LG K20 Plus
- Galaxy S10+
Can you guys have a look at, pls: https://github.com/smstuebe/xamarin-fingerprint/issues/151 These stupid crashes should be fixed, because the fragment is now the official one from google :D
Will do! Thanks for the quick response!