emansih / FireflyMobile

Mobile Application for Firefly III written in Kotlin
GNU General Public License v3.0
318 stars 46 forks source link

Apps hangs permanently on first auth setup, then crashes on startup #206

Open carranzamarioagustin opened 2 years ago

carranzamarioagustin commented 2 years ago

Firefly III Server Version: 5.6.14 Firefly III Mobile Version: 5.0.6 Android Version:
12 Device Information:

Current Behavior

My setup is as follows:

After the first successful authentication, the app hangs permanently, either in "Almost there!" with PAT, or the permanent spinning circle in OAuth. After closing the app (either clearing cache or not), the app crashes on startup, until all data in storage is removed.

Steps to Reproduce

Try to setup the first user authentication.

REPORT_ID=2f385eff-4992-4d6d-8751-dfef5993f4ef APP_VERSION_NAME=5.0.6 PHONE_MODEL=SM-G975F BRAND=samsung PRODUCT=beyond2ltexx ANDROID_VERSION=12 BUILD_CONFIG= STACK_TRACE=java.util.NoSuchElementException: Char sequence is empty. at xyz.hisname.fireflyiii.ui.HomeActivity.$r8$lambda$m5_BfCzbKopEcr4W8HSTQOYhFWo(HomeActivity.kt:15) at xyz.hisname.fireflyiii.ui.HomeActivity$$ExternalSyntheticLambda5.onChanged(Unknown Source:10) at androidx.lifecycle.LiveData.considerNotify(LiveData.java:6) at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:8) at androidx.lifecycle.LiveData.setValue(LiveData.java:4) at androidx.lifecycle.MutableLiveData.setValue(MutableLiveData.java:1) at androidx.lifecycle.LiveData$1.run(LiveData.java:5) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at android.app.ActivityThread.main(ActivityThread.java:8633) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1133)

LOGCAT=--------- beginning of main 02-11 14:35:51.971 I/ViewRootImpl@8a76befAuthActivity: stopped(true) old=false 02-11 14:35:51.981 I/MSHandlerLifeCycle(15429): isMultiSplitHandlerRequested: windowingMode=1 isFullscreen=true isPopOver=false isHidden=false skipActivityType=false isHandlerType=true this: DecorView@89b3ebe[] 02-11 14:35:51.981 I/MSHandlerLifeCycle(15429): removeMultiSplitHandler: no exist. decor=DecorView@89b3ebe[] 02-11 14:35:57.110 D/OpenGLRenderer(15429): setSurface called with nullptr 02-11 14:35:57.112 D/OpenGLRenderer(15429): setSurface called with nullptr 02-11 14:35:57.113 D/OpenGLRenderer(15429): setSurface called with nullptr 02-11 14:36:35.373 I/ViewRootImpl@8a76befAuthActivity: handleAppVisibility mAppVisible=false visible=true 02-11 14:36:35.383 D/OpenGLRenderer(15429): setSurface called with nullptr 02-11 14:36:35.386 I/ViewRootImpl@8a76befAuthActivity: Relayout returned: old=(0,0,720,1520) new=(0,0,720,1520) req=(720,1520)4 dur=3 res=0x1 s={false 0} ch=false fn=-1 02-11 14:36:35.386 I/ViewRootImpl@8a76befAuthActivity: stopped(false) old=true 02-11 14:36:35.388 I/MSHandlerLifeCycle(15429): isMultiSplitHandlerRequested: windowingMode=1 isFullscreen=true isPopOver=false isHidden=false skipActivityType=false isHandlerType=true this: DecorView@89b3ebe[] 02-11 14:36:35.388 I/MSHandlerLifeCycle(15429): removeMultiSplitHandler: no exist. decor=DecorView@89b3ebe[] 02-11 14:36:35.388 I/ViewRootImpl@8a76befAuthActivity: stopped(false) old=false 02-11 14:36:35.391 I/MSHandlerLifeCycle(15429): isMultiSplitHandlerRequested: windowingMode=1 isFullscreen=true isPopOver=false isHidden=false skipActivityType=false isHandlerType=true this: DecorView@89b3ebe[] 02-11 14:36:35.391 I/MSHandlerLifeCycle(15429): removeMultiSplitHandler: no exist. decor=DecorView@89b3ebe[] 02-11 14:36:35.403 D/OpenGLRenderer(15429): setSurface called with nullptr 02-11 14:36:35.411 I/ViewRootImpl@8a76befAuthActivity: Relayout returned: old=(0,0,720,1520) new=(0,0,720,1520) req=(720,1520)0 dur=5 res=0x7 s={true 532098878576} ch=true fn=-1 02-11 14:36:35.411 I/ViewRootImpl@8a76befAuthActivity: [DP] dp(1) 1 android.view.ViewRootImpl.reportNextDraw:11261 android.view.ViewRootImpl.performTraversals:4088 android.view.ViewRootImpl.doTraversal:2832 02-11 14:36:35.412 D/OpenGLRenderer(15429): eglCreateWindowSurface 02-11 14:36:35.434 I/ViewRootImpl@8a76befAuthActivity: [DP] pdf(0) 1 android.view.ViewRootImpl.lambda$createFrameCompleteCallback$3$ViewRootImpl:4846 android.view.ViewRootImpl$$ExternalSyntheticLambda15.run:6 android.os.Handler.handleCallback:938 02-11 14:36:35.434 I/ViewRootImpl@8a76befAuthActivity: [DP] rdf() 02-11 14:36:35.434 D/ViewRootImpl@8a76befAuthActivity: reportDrawFinished (fn: -1) 02-11 14:36:35.467 I/ViewRootImpl@8a76befAuthActivity: MSG_WINDOW_FOCUS_CHANGED 1 1 02-11 14:36:35.494 D/InputMethodManager(15429): startInputInner - Id : 0 02-11 14:36:35.494 I/InputMethodManager(15429): startInputInner - mService.startInputOrWindowGainedFocus 02-11 14:36:50.992 I/ViewRootImpl@8a76befAuthActivity: ViewPostIme pointer 0 02-11 14:36:51.036 I/ViewRootImpl@8a76befAuthActivity: ViewPostIme pointer 1 02-11 14:36:57.346 I/ViewRootImpl@8a76befAuthActivity: ViewPostIme pointer 0 02-11 14:36:57.428 I/ViewRootImpl@8a76befAuthActivity: ViewPostIme pointer 1 02-11 14:36:57.520 I/ViewRootImpl@8a76befAuthActivity: ViewPostIme pointer 0 02-11 14:36:57.603 I/ViewRootImpl@8a76befAuthActivity: ViewPostIme pointer 1 02-11 14:36:57.746 I/ViewRootImpl@8a76befAuthActivity: ViewPostIme pointer 0 02-11 14:36:57.795 I/ViewRootImpl@8a76befAuthActivity: ViewPostIme pointer 1 02-11 14:36:57.979 I/ViewRootImpl@8a76befAuthActivity: ViewPostIme pointer 0 02-11 14:36:58.012 I/ViewRootImpl@8a76befAuthActivity: ViewPostIme pointer 1 02-11 14:36:58.205 I/ViewRootImpl@8a76befAuthActivity: ViewPostIme pointer 0 02-11 14:36:58.253 I/ViewRootImpl@8a76befAuthActivity: ViewPostIme pointer 1 02-11 14:36:58.413 I/ViewRootImpl@8a76befAuthActivity: ViewPostIme pointer 0 02-11 14:36:58.453 I/ViewRootImpl@8a76befAuthActivity: ViewPostIme pointer 1 02-11 14:36:58.621 I/ViewRootImpl@8a76befAuthActivity: ViewPostIme pointer 0 02-11 14:36:58.662 I/ViewRootImpl@8a76befAuthActivity: ViewPostIme pointer 1 02-11 14:36:58.821 I/ViewRootImpl@8a76befAuthActivity: ViewPostIme pointer 0 02-11 14:36:58.878 I/ViewRootImpl@8a76befAuthActivity: ViewPostIme pointer 1 02-11 14:36:59.012 I/ViewRootImpl@8a76befAuthActivity: ViewPostIme pointer 0 02-11 14:36:59.062 I/ViewRootImpl@8a76befAuthActivity: ViewPostIme pointer 1 02-11 14:36:59.196 I/ViewRootImpl@8a76befAuthActivity: ViewPostIme pointer 0 02-11 14:36:59.254 I/ViewRootImpl@8a76befAuthActivity: ViewPostIme pointer 1 02-11 14:36:59.403 I/ViewRootImpl@8a76befAuthActivity: ViewPostIme pointer 0 02-11 14:36:59.454 I/ViewRootImpl@8a76befAuthActivity: ViewPostIme pointer 1 02-11 14:36:59.605 I/ViewRootImpl@8a76befAuthActivity: ViewPostIme pointer 0 02-11 14:36:59.678 I/ViewRootImpl@8a76befAuthActivity: ViewPostIme pointer 1 02-11 14:36:59.846 I/ViewRootImpl@8a76befAuthActivity: ViewPostIme pointer 0 02-11 14:36:59.895 I/ViewRootImpl@8a76befAuthActivity: ViewPostIme pointer 1 02-11 14:37:01.002 I/ViewRootImpl@8a76befAuthActivity: MSG_WINDOW_FOCUS_CHANGED 0 1 02-11 14:37:01.386 I/ViewRootImpl@8a76befAuthActivity: handleAppVisibility mAppVisible=true visible=false 02-11 14:37:01.402 D/OpenGLRenderer(15429): setSurface called with nullptr 02-11 14:37:01.402 D/OpenGLRenderer(15429): setSurface() destroyed EGLSurface 02-11 14:37:01.402 D/OpenGLRenderer(15429): destroyEglSurface 02-11 14:37:01.406 I/ViewRootImpl@8a76befAuthActivity: Relayout returned: old=(0,0,720,1520) new=(0,0,720,1520) req=(720,1520)8 dur=3 res=0x5 s={false 0} ch=true fn=1547 02-11 14:37:01.406 I/ViewRootImpl@8a76befAuthActivity: stopped(true) old=false 02-11 14:37:01.409 I/MSHandlerLifeCycle(15429): isMultiSplitHandlerRequested: windowingMode=1 isFullscreen=true isPopOver=false isHidden=false skipActivityType=false isHandlerType=true this: DecorView@89b3ebe[] 02-11 14:37:01.409 I/MSHandlerLifeCycle(15429): removeMultiSplitHandler: no exist. decor=DecorView@89b3ebe[] 02-11 14:37:01.412 D/InputTransport(15429): Input channel destroyed: 'ClientS', fd=116 02-11 14:37:05.015 E/name.fireflyii(17295): Not starting debugger since process cannot load the jdwp agent. 02-11 14:37:05.018 E/USNET (17295): USNET: appName: xyz.hisname.fireflyiii 02-11 14:37:05.020 D/ProcessState(17295): Binder ioctl to enable oneway spam detection failed: Invalid argument 02-11 14:37:05.025 D/ActivityThread(17295): setConscryptValidator 02-11 14:37:05.026 D/ActivityThread(17295): setConscryptValidator - put --------- beginning of system 02-11 14:37:05.035 D/ActivityThread(17295): handleBindApplication()++ app=xyz.hisname.fireflyiii 02-11 14:37:05.037 D/CompatibilityChangeReporter(17295): Compat change id reported: 171979766; UID 10436; state: DISABLED 02-11 14:37:05.054 W/name.fireflyii(17295): Entry not found 02-11 14:37:05.057 W/name.fireflyii(17295): JIT profile information will not be recorded: profile file does not exist. 02-11 14:37:05.064 V/GraphicsEnvironment(17295): ANGLE Developer option for 'xyz.hisname.fireflyiii' set to: 'default' 02-11 14:37:05.064 V/GraphicsEnvironment(17295): App is not on the allowlist for updatable production driver. 02-11 14:37:05.066 D/LoadedApk(17295): LoadedApk::makeApplication() appContext.mOpPackageName=xyz.hisname.fireflyiii appContext.mBasePackageName=xyz.hisname.fireflyiii 02-11 14:37:05.066 D/NetworkSecurityConfig(17295): Using Network Security Config from resource network_security_config debugBuild: false 02-11 14:37:05.072 D/NetworkSecurityConfig(17295): Using Network Security Config from resource network_security_config debugBuild: false 02-11 14:37:05.075 D/WM-WrkMgrInitializer(17295): Initializing WorkManager with default configuration. 02-11 14:37:05.076 W/name.fireflyii(17295): Accessing hidden field Ljava/util/Collections$SynchronizedCollection;->mutex:Ljava/lang/Object; (max-target-o, reflection, denied) 02-11 14:37:05.076 W/name.fireflyii(17295): Accessing hidden method Ljava/util/Collections$SynchronizedSet;->(Ljava/util/Set;Ljava/lang/Object;)V (max-target-o, reflection, denied) 02-11 14:37:05.076 W/name.fireflyii(17295): Accessing hidden method Ljava/util/Collections$SynchronizedCollection;->(Ljava/util/Collection;Ljava/lang/Object;)V (max-target-o, reflection, denied) 02-11 14:37:05.082 D/ActivityThread(17295): handleBindApplication() -- 02-11 14:37:05.095 D/CompatibilityChangeReporter(17295): Compat change id reported: 160794467; UID 10436; state: DISABLED 02-11 14:37:05.101 I/ACRA (17295): ACRA is enabled for xyz.hisname.fireflyiii, initializing... 02-11 14:37:14.460 D/OpenGLRenderer(17295): RenderThread::requireGlContext() 02-11 14:37:14.470 D/OpenGLRenderer(17295): RenderThread::setGrContext() 02-11 14:37:14.509 I/DecorView(17295): [INFO] isPopOver=false, config=true 02-11 14:37:14.509 I/DecorView(17295): updateCaptionType >> DecorView@1c31165[], isFloating=false, isApplication=true, hasWindowControllerCallback=true, hasWindowDecorCaption=false 02-11 14:37:14.509 D/DecorView(17295): setCaptionType = 0, this = DecorView@1c31165[] 02-11 14:37:14.510 I/DecorView(17295): getCurrentDensityDpi: from real metrics. densityDpi=280 msg=resources_loaded 02-11 14:37:14.552 D/CompatibilityChangeReporter(17295): Compat change id reported: 171228096; UID 10436; state: ENABLED 02-11 14:37:14.590 I/MSHandlerLifeCycle(17295): isMultiSplitHandlerRequested: ignored. pkg=xyz.hisname.fireflyiii parent=null callers=com.android.internal.policy.DecorView.setVisibility:4224 android.app.ActivityThread.handleResumeActivity:5294 android.app.servertransaction.ResumeActivityItem.execute:54 android.app.servertransaction.ActivityTransactionItem.execute:45 android.app.servertransaction.TransactionExecutor.executeLifecycleState:176 02-11 14:37:14.590 I/MSHandlerLifeCycle(17295): removeMultiSplitHandler: no exist. decor=DecorView@1c31165[] 02-11 14:37:14.599 I/ViewRootImpl@fab5006HomeActivity: setView = com.android.internal.policy.DecorView@1c31165 TM=true 02-11 14:37:14.600 I/MSHandlerLifeCycle(17295): isMultiSplitHandlerRequested: windowingMode=1 isFullscreen=true isPopOver=false isHidden=false skipActivityType=false isHandlerType=true this: DecorView@1c31165[HomeActivity] 02-11 14:37:14.600 I/MSHandlerLifeCycle(17295): removeMultiSplitHandler: no exist. decor=DecorView@1c31165[HomeActivity] 02-11 14:37:14.604 I/ActivityThread(17295): Schedule relaunch activity: xyz.hisname.fireflyiii.ui.HomeActivity 02-11 14:37:14.604 D/AndroidRuntime(17295): Shutting down VM --------- beginning of crash 02-11 14:37:14.605 E/AndroidRuntime(17295): FATAL EXCEPTION: main 02-11 14:37:14.605 E/AndroidRuntime(17295): Process: xyz.hisname.fireflyiii, PID: 17295 02-11 14:37:14.605 E/AndroidRuntime(17295): java.util.NoSuchElementException: Char sequence is empty. 02-11 14:37:14.605 E/AndroidRuntime(17295): at xyz.hisname.fireflyiii.ui.HomeActivity.$r8$lambda$m5_BfCzbKopEcr4W8HSTQOYhFWo(HomeActivity.kt:15) 02-11 14:37:14.605 E/AndroidRuntime(17295): at xyz.hisname.fireflyiii.ui.HomeActivity$$ExternalSyntheticLambda5.onChanged(Unknown Source:10) 02-11 14:37:14.605 E/AndroidRuntime(17295): at androidx.lifecycle.LiveData.considerNotify(LiveData.java:6) 02-11 14:37:14.605 E/AndroidRuntime(17295): at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:8) 02-11 14:37:14.605 E/AndroidRuntime(17295): at androidx.lifecycle.LiveData.setValue(LiveData.java:4) 02-11 14:37:14.605 E/AndroidRuntime(17295): at androidx.lifecycle.MutableLiveData.setValue(MutableLiveData.java:1) 02-11 14:37:14.605 E/AndroidRuntime(17295): at androidx.lifecycle.LiveData$1.run(LiveData.java:5) 02-11 14:37:14.605 E/AndroidRuntime(17295): at android.os.Handler.handleCallback(Handler.java:938) 02-11 14:37:14.605 E/AndroidRuntime(17295): at android.os.Handler.dispatchMessage(Handler.java:99) 02-11 14:37:14.605 E/AndroidRuntime(17295): at android.os.Looper.loopOnce(Looper.java:226) 02-11 14:37:14.605 E/AndroidRuntime(17295): at android.os.Looper.loop(Looper.java:313) 02-11 14:37:14.605 E/AndroidRuntime(17295): at android.app.ActivityThread.main(ActivityThread.java:8633) 02-11 14:37:14.605 E/AndroidRuntime(17295): at java.lang.reflect.Method.invoke(Native Method) 02-11 14:37:14.605 E/AndroidRuntime(17295): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567) 02-11 14:37:14.605 E/AndroidRuntime(17295): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1133) 02-11 14:37:14.605 E/ACRA (17295): ACRA caught a NoSuchElementException for xyz.hisname.fireflyiii 02-11 14:37:14.605 E/ACRA (17295): java.util.NoSuchElementException: Char sequence is empty. 02-11 14:37:14.605 E/ACRA (17295): at xyz.hisname.fireflyiii.ui.HomeActivity.$r8$lambda$m5_BfCzbKopEcr4W8HSTQOYhFWo(HomeActivity.kt:15) 02-11 14:37:14.605 E/ACRA (17295): at xyz.hisname.fireflyiii.ui.HomeActivity$$ExternalSyntheticLambda5.onChanged(Unknown Source:10) 02-11 14:37:14.605 E/ACRA (17295): at androidx.lifecycle.LiveData.considerNotify(LiveData.java:6) 02-11 14:37:14.605 E/ACRA (17295): at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:8) 02-11 14:37:14.605 E/ACRA (17295): at androidx.lifecycle.LiveData.setValue(LiveData.java:4) 02-11 14:37:14.605 E/ACRA (17295): at androidx.lifecycle.MutableLiveData.setValue(MutableLiveData.java:1) 02-11 14:37:14.605 E/ACRA (17295): at androidx.lifecycle.LiveData$1.run(LiveData.java:5) 02-11 14:37:14.605 E/ACRA (17295): at android.os.Handler.handleCallback(Handler.java:938) 02-11 14:37:14.605 E/ACRA (17295): at android.os.Handler.dispatchMessage(Handler.java:99) 02-11 14:37:14.605 E/ACRA (17295): at android.os.Looper.loopOnce(Looper.java:226) 02-11 14:37:14.605 E/ACRA (17295): at android.os.Looper.loop(Looper.java:313) 02-11 14:37:14.605 E/ACRA (17295): at android.app.ActivityThread.main(ActivityThread.java:8633) 02-11 14:37:14.605 E/ACRA (17295): at java.lang.reflect.Method.invoke(Native Method) 02-11 14:37:14.605 E/ACRA (17295): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567) 02-11 14:37:14.605 E/ACRA (17295): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1133)

IS_SILENT=false USER_CRASH_DATE=2022-02-11T14:37:14.608+01:00

teldosas commented 2 years ago

I get the same when installing from Play Store or F-Droid. Interestingly, I don't get the error when building the 5.0.6 on my own and installing the debug version.

EDIT: After, clearing the app data and trying to authenticate again I got the error with a more helpful stacktrace:

02-26 22:10:55.228 26591 26591 E AndroidRuntime: java.util.NoSuchElementException: Char sequence is empty.
02-26 22:10:55.228 26591 26591 E AndroidRuntime:    at kotlin.text.StringsKt___StringsKt.first(_Strings.kt:71)
02-26 22:10:55.228 26591 26591 E AndroidRuntime:    at xyz.hisname.fireflyiii.ui.HomeActivity.setUpHeader$lambda-9(HomeActivity.kt:175)
...

It seems that it tries to get the first letter from the user email to render the logo and the email is empty.

After deleting any Photorius accounts from the Android Settings and authenticating again there was no error.

EDIT2: Actually the problem seems to be that if one authentication attempt fails, an Android Account has been created for the device, but the activeUserEmail has not been set for that account hash. So when the user tries to authenticate again and they succeed, a new Android Account is created but the app tries to render all accounts in the drawer using the first letter of their email and since it can't find an email for the previous account it fails.

emansih commented 2 years ago

@teldosas nice investigation! This issue has been bugging me for some time and I could not replicate it. I am more than happy to take a PR.

teldosas commented 2 years ago

@emansih Nice! Would it make sense to move the creation of the account after the authentication succeeds?

EDIT: or I could just remove any accounts that don't have an email set

carranzamarioagustin commented 2 years ago

Thanks for the help, and I'm glad the creator of the app is here, and this long issue can be fixed and solved in the Play Store App.

I wish I had some more experience in Kotlin, so I could help.

Please let me know whatever kind of help is needed, I am happy to test a new version whenever these fixes are done :)

nourthe commented 2 years ago

Same here!

I fixed it deleting all my app-related android accounts. (And seting up again)

I had aprox. 5 android accounts... Maybe because I failed attempting to add my server a lot of times.