smstuebe / xamarin-fingerprint

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

`NullReferenceException` in `FingerprintDialogFragment.OnCreateView` #67

Closed kspearrin closed 2 years ago

kspearrin commented 7 years ago

Steps to reproduce

I don't have any clear reproduction steps since I am unable to reproduce this myself on an emulator. This appears to be only affecting a subset of users since many are not reporting any issues with it. I only know this is an issue because of HockeyApp crash logs.

Project repo can be found here: https://github.com/bitwarden/mobile

Relevant line?: https://github.com/bitwarden/mobile/blob/master/src/App/Pages/Lock/LockFingerprintPage.cs#L95

Expected behavior

No crash

Actual behavior

Crashing with NullReferenceException in FingerprintDialogFragment.OnCreateView

Crashlog

Xamarin caused by: android.runtime.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object
  at Plugin.Fingerprint.Dialog.FingerprintDialogFragment.OnCreateView (Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Android.OS.Bundle savedInstanceState) [0x0001e] in <0df64593c67c4112ad97c08edc0e5f4c>:0 
  at Android.App.Fragment.n_OnCreateView_Landroid_view_LayoutInflater_Landroid_view_ViewGroup_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_inflater, System.IntPtr native_container, System.IntPtr native_savedInstanceState) [0x00020] in <79ee33873335414f9e2acd23c2a8a4c8>:0 
  at (wrapper dynamic-method) System.Object:916e2d60-bc47-4a57-91d0-d931b8692bb3 (intptr,intptr,intptr,intptr,intptr)
    at md525b98c9e7858a0d16b65a6f8fc5afe38.FingerprintDialogFragment.n_onCreateView(Native Method)
    at md525b98c9e7858a0d16b65a6f8fc5afe38.FingerprintDialogFragment.onCreateView(FingerprintDialogFragment.java:76)
    at android.app.Fragment.performCreateView(Fragment.java:2353)
    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:995)
    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1171)
    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1153)
    at android.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:2039)
    at android.app.FragmentController.dispatchActivityCreated(FragmentController.java:176)
    at android.app.Activity.performCreateCommon(Activity.java:6676)
    at android.app.Activity.performCreate(Activity.java:6684)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2619)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2727)
    at android.app.ActivityThread.-wrap12(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6121)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)

Configuration

Version of the Plugin: 1.4.4

Platform: Multiple Android. I have crash logs for 6.0 all the way to 7.1.2.

Device: Multiple. Nexus 5X, SM-G930F, Pixel, ONEPLUS A3003, etc

smsissuechecker commented 7 years ago

Hi @kspearrin,

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.

kspearrin commented 7 years ago

Any idea what is causing this? I am having a lot crash reports in our latest production app from this. If you don't have the time at the moment I can try to take a stab at it since it's somewhat urgent for us.

Stack trace points here: https://github.com/smstuebe/xamarin-fingerprint/blob/master/src/Plugin.Fingerprint.Android/Dialog/FingerprintDialogFragment.cs#L151

Seems the only null reference possibilities are:

smstuebe commented 7 years ago

Hi, no idea. I see the same possible null reference causes. Or it hast something to do with the time you trigger the authentication in your App (OnAppearing). I tried to reproduce with the sample app and my Nexus 5x, but it did not crash :/

kspearrin commented 7 years ago

Before this problem I had been using the old v1.2.4 and was not experiencing any crashes. Implemented the same way. All I did was update the lib and adjust to the breaking changes.

Looking at the v1.2.0 tag it seems to be like the only new possibility for a null ref is Configuration.Reason. https://github.com/smstuebe/xamarin-fingerprint/blob/v1.2.0/src/Plugin.Fingerprint.Android/Dialog/FingerprintDialogFragment.cs#L49

Not sure how could be null in my implementation though.

smstuebe commented 7 years ago

Hmm do you think it's happening after coming back from a tombstoned state?

kspearrin commented 7 years ago

Maybe. I only have an emulator to test with so my test cases are somewhat limited. Are you able to test that scenario?

smstuebe commented 7 years ago

I can try to do so. But I wonder if the dialog should just close itself when going into tombstoned mode. Because: where will it return? The task will not be awaited anymore because the activity has been tombstoned, too and it's button click await state machine doesn't exist anymore (I guess). hmmm 🤔

kspearrin commented 7 years ago

I just tested it on my emulator with the fingerprint dialog open, then backgrounded overnight. Opened it this morning and no crash.

kspearrin commented 6 years ago

Still seeing this crash daily in our HockeyApp crash reports. It seems to log the crash in large counts on a single device, which is odd. I have never seen any other crash report this way.

For example, a single device will report 10-30 of the same crash report (above) in the timespan of a few seconds.