Mobile-SDK-Android icon indicating copy to clipboard operation
Mobile-SDK-Android copied to clipboard

Crash due to UserAccountManager.getInstance

Open jeryini opened this issue 3 years ago • 4 comments

Hello!

In my production app I'm currently seeing the following crash that happens sporadically for some users:

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference
       at dji.midware.util.hgf.fdd()
       at dji.midware.util.hgf.fdd()
       at dji.internal.useraccount.nbb.ghu(:12)
       at dji.internal.useraccount.nbb.nhf(:4)
       at dji.sdk.useraccount.UserAccountManager.updateInternalUserAccountState(:8)
       at dji.sdk.useraccount.UserAccountManager.<init>(:3)
       at dji.sdk.useraccount.UserAccountManager.getInstance(:9)
       at dji.ux.beta.core.widget.useraccount.UserAccountLoginWidgetModel.inSetup(UserAccountLoginWidgetModel.java:77)
       at dji.ux.beta.core.base.WidgetModel.setup(WidgetModel.java:103)
       at dji.ux.beta.core.widget.useraccount.UserAccountLoginWidget.onAttachedToWindow(UserAccountLoginWidget.java:131)
       at android.view.View.dispatchAttachedToWindow(View.java:20535)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3489)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3496)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3496)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3496)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3496)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3496)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3496)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3496)
       at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2563)
       at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2066)
       at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8417)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:972)
       at android.view.Choreographer.doCallbacks(Choreographer.java:796)
       at android.view.Choreographer.doFrame(Choreographer.java:731)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:957)
       at android.os.Handler.handleCallback(Handler.java:938)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:250)
       at android.app.ActivityThread.main(ActivityThread.java:7806)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958)

I've discovered this gets triggered when calling UserAccountManager.getInstance. Someone already mentioned similar issue here (https://github.com/dji-sdk/Mobile-SDK-Android/issues/925), where it was answered that:

I also encountered this. You must first call registerApp and then logIntoDJIUserAccount, otherwise it will crash.

But first this is not due to logIntoDJIUserAccount, but it happens already when calling UserAccountManager.getInstance. Secondly I've made sure that registerApp is successful before user can enter GCS and trigger a call to UserAccountManager.getInstance, but I'm still seeing this issue pop up randomly for some users. As mentioned already for issue (https://github.com/dji-sdk/Mobile-SDK-Android/issues/1050) , as internal sdk call triggers null pointer exception it should therefore probably be fixed internally.

jeryini avatar Nov 02 '21 07:11 jeryini

Agent comment from DJI SDK in Zendesk ticket #55591:

尊敬的开发者,感谢您联系DJI 大疆创新 由于github不是我们主要的咨询渠道,您的问题可能跟进不及时。我们建议您通过填写表单( https://djisdksupport.zendesk.com/hc/zh-cn/requests/new )向我们反馈问题。或者您也可以在论坛发帖,与其它开发者交流。论坛链接:https://djisdksupport.zendesk.com/hc/zh-cn/community/topics

Dear developer, thank you for contacting DJI. Since github is not our main consultation channel, your questions may not be followed up in time. We recommend that you fill in the form (https://djisdksupport.zendesk.com/hc/en-us/requests/new) to report problems to us. Or you can post in the forum to communicate with other developers. Forum link: https://djisdksupport.zendesk.com/hc/zh-cn/community/topics

°°°

dji-dev avatar Nov 02 '21 07:11 dji-dev

This is weird, registerApp will make sure the application context is passed through. This bug is happened due to application context is null. We has fixed this bug and merged the fix in 4.16.

DJI-William avatar Nov 02 '21 13:11 DJI-William

Hello @DJI-William !

Awesome! Thank you for fast response and looking forward to version 4.16!

jeryini avatar Nov 02 '21 15:11 jeryini

@jeryini Should be released before 2022.

DJI-William avatar Nov 03 '21 02:11 DJI-William