status-im / status-mobile

a free (libre) open source, mobile OS for Ethereum
https://status.app
Mozilla Public License 2.0
3.91k stars 984 forks source link

App shows the setup screen when already setup #20930

Closed fryorcraken closed 2 weeks ago

fryorcraken commented 3 months ago

Bug Report

Problem

Sometimes, the app shows the setup screen despite being already setup.

Not sure what makes it happens, I would chat with someone, then go to another app and back, and I get the setup screen.

If I force kill the app in android, and reopen it, it goes back to normal and prompt password for my profile.

Screenshot_20240731-140530

Additional Information

fryorcraken commented 3 months ago

More and more frequent with latest PR version. Force kill is not enough and need to clear cache. See version below.

Screenshot_20240808-200928_1.png

fryorcraken commented 3 months ago

Version cab8ee1d8b4fbc70b722f5798ca238cba56d60ba

churik commented 3 months ago

@fryorcraken I believe you have push notifications enabled on your device?

upd: yes, PN service is enabled, which means it keeps app awake (no re-login required after a background)

Parveshdhull commented 3 months ago

Hi @fryorcraken, thank you very much for reporting this issue. Next time this problem occurs, please also share logs of that session.

fryorcraken commented 3 months ago

Hi @fryorcraken, thank you very much for reporting this issue. Next time this problem occurs, please also share logs of that session.

Can you clarify how I can share the logs?

Parveshdhull commented 3 months ago

Hi @fryorcraken, thank you very much for reporting this issue. Next time this problem occurs, please also share logs of that session.

Can you clarify how I can share the logs?

Hi, shake the device to see the error report screen. You can email logs to your email and then attach them to the issue.

churik commented 3 months ago

@Parveshdhull check out https://github.com/status-im/status-mobile/issues/21034, I think it is duplicate, but you might find some useful info there

Parveshdhull commented 3 months ago
  1. From the logs shared by @pavlo

    status-im.contexts.centralized-metrics.events:25] - tracking event {:metric {:eventName "navigation", :platform "android", :appVersion "2.30.0 (20240809095428)", :eventValue {:viewId "onboarding.intro"}}}

    we are opening the intro root instead of the profiles.

  2. We do that when (seq profiles-overview) is not true

  3. In https://github.com/status-im/status-mobile/commit/0a0591f67a8, we migrated from openAccounts to initializeApplication https://github.com/status-im/status-mobile/blob/75280c4db673a43c84d999e2e11c88ae01a02879/src/status_im/contexts/profile/events.cljs#L32

@cammellos since when you are facing this issue? Do you think this migration might be causing empty account list somehow? cc @flexsurfer

Parveshdhull commented 3 months ago

Probably random, but a way to reproduce the issue: https://discord.com/channels/1210237582470807632/1217173176086302821/1273265933795721349

Parveshdhull commented 3 months ago

This doesn't UI issue, its probably status-go issue. For some reason we are losing access to accounts list. accounts.sql file in /data/user/0/im.status.ethereum.debug/no_backup is empty (or I am checking wrong file for accounts list)

flexsurfer commented 3 months ago

i think I had both PR and release builds installed on my device is important, I believe all who faced this issue had a few versions of the app installed

flexsurfer commented 3 months ago

also this If I force kill the app in android, and reopen it, it goes back to normal and prompt password for my profile. so this happens only when app is in background

flexsurfer commented 3 months ago

i would say we need to look at the code when app-state-change event happens

Parveshdhull commented 3 months ago

also this If I force kill the app in android, and reopen it, it goes back to normal and prompt password for my profile. so this happens only when app is in background

This is very interesting. I was able to reproduce this issue again, and force kill fixed the bug. But before force kill profile/get-profiles-overview-success had no accounts

https://github.com/user-attachments/assets/7f8e91ca-69f5-4835-aa19-5bf0d902d869

flexsurfer commented 3 months ago

false value is weird, at least it should be nil, so something is off

flexsurfer commented 3 months ago

hm and also why is it initializeApplication native method?

cammellos commented 3 months ago

hm and also why is it initializeApplication native method?

I can probably answer that question, but what else do you think it could be? you mean an RPC?

flexsurfer commented 3 months ago

hm and also why is it initializeApplication native method?

I can probably answer that question, but what else do you think it could be? you mean an RPC?

i mean it's just misleading, in cljs it's :profile/get-profiles-overview , most interesting to know in what case it returns false

fryorcraken commented 2 months ago

I uninstall all status app and reinstall fresh from play store. Will see if it happens again and will sahre logs.

fryorcraken commented 1 month ago

Happened again. This time I only have the play store version installed for a while.

type: logcat
osVersion: google/panther/panther:14/AP2A.240905.003/2024092900:user/release-keys
packageName: im.status.ethereum:2024082617
buffers: main,system,crash,events,kernel
level: verbose

--------- beginning of crash
10-10 08:18:03.791  3306  3306 E AndroidRuntime: FATAL EXCEPTION: main
10-10 08:18:03.791  3306  3306 E AndroidRuntime: Process: im.status.ethereum, PID: 3306
10-10 08:18:03.791  3306  3306 E AndroidRuntime: java.lang.RuntimeException: Unable to start service im.status.ethereum.pushnotifications.ForegroundService@c65e810 with Intent { cmp=im.status.ethereum/.pushnotifications.ForegroundService }: android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service im.status.ethereum/.pushnotifications.ForegroundService
10-10 08:18:03.791  3306  3306 E AndroidRuntime:    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:5126)
10-10 08:18:03.791  3306  3306 E AndroidRuntime:    at android.app.ActivityThread.-$$Nest$mhandleServiceArgs(Unknown Source:0)
10-10 08:18:03.791  3306  3306 E AndroidRuntime:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2439)
10-10 08:18:03.791  3306  3306 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:107)
10-10 08:18:03.791  3306  3306 E AndroidRuntime:    at android.os.Looper.loopOnce(Looper.java:232)
10-10 08:18:03.791  3306  3306 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:317)
10-10 08:18:03.791  3306  3306 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:8623)
10-10 08:18:03.791  3306  3306 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
10-10 08:18:03.791  3306  3306 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
10-10 08:18:03.791  3306  3306 E AndroidRuntime:    at com.android.internal.os.ExecInit.main(ExecInit.java:50)
10-10 08:18:03.791  3306  3306 E AndroidRuntime:    at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
10-10 08:18:03.791  3306  3306 E AndroidRuntime:    at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:369)
10-10 08:18:03.791  3306  3306 E AndroidRuntime: Caused by: android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service im.status.ethereum/.pushnotifications.ForegroundService
10-10 08:18:03.791  3306  3306 E AndroidRuntime:    at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:54)
10-10 08:18:03.791  3306  3306 E AndroidRuntime:    at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:50)
10-10 08:18:03.791  3306  3306 E AndroidRuntime:    at android.os.Parcel.readParcelableInternal(Parcel.java:5036)
10-10 08:18:03.791  3306  3306 E AndroidRuntime:    at android.os.Parcel.readParcelable(Parcel.java:5018)
10-10 08:18:03.791  3306  3306 E AndroidRuntime:    at android.os.Parcel.createExceptionOrNull(Parcel.java:3187)
10-10 08:18:03.791  3306  3306 E AndroidRuntime:    at android.os.Parcel.createException(Parcel.java:3176)
10-10 08:18:03.791  3306  3306 E AndroidRuntime:    at android.os.Parcel.readException(Parcel.java:3152)
10-10 08:18:03.791  3306  3306 E AndroidRuntime:    at android.os.Parcel.readException(Parcel.java:3094)
10-10 08:18:03.791  3306  3306 E AndroidRuntime:    at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:6998)
10-10 08:18:03.791  3306  3306 E AndroidRuntime:    at android.app.Service.startForeground(Service.java:879)
10-10 08:18:03.791  3306  3306 E AndroidRuntime:    at im.status.ethereum.pushnotifications.ForegroundService$$ExternalSyntheticApiModelOutline2.m(SourceFile:0)
10-10 08:18:03.791  3306  3306 E AndroidRuntime:    at im.status.ethereum.pushnotifications.ForegroundService.onStartCommand(Unknown Source:225)
10-10 08:18:03.791  3306  3306 E AndroidRuntime:    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:5108)
10-10 08:18:03.791  3306  3306 E AndroidRuntime:    ... 11 more
10-10 10:05:43.583 17431 17431 E AndroidRuntime: FATAL EXCEPTION: main
10-10 10:05:43.583 17431 17431 E AndroidRuntime: Process: im.status.ethereum, PID: 17431
10-10 10:05:43.583 17431 17431 E AndroidRuntime: java.lang.RuntimeException: Unable to start service im.status.ethereum.pushnotifications.ForegroundService@e9037d5 with Intent { cmp=im.status.ethereum/.pushnotifications.ForegroundService }: android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service im.status.ethereum/.pushnotifications.ForegroundService
10-10 10:05:43.583 17431 17431 E AndroidRuntime:    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:5126)
10-10 10:05:43.583 17431 17431 E AndroidRuntime:    at android.app.ActivityThread.-$$Nest$mhandleServiceArgs(Unknown Source:0)
10-10 10:05:43.583 17431 17431 E AndroidRuntime:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2439)
10-10 10:05:43.583 17431 17431 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:107)
10-10 10:05:43.583 17431 17431 E AndroidRuntime:    at android.os.Looper.loopOnce(Looper.java:232)
10-10 10:05:43.583 17431 17431 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:317)
10-10 10:05:43.583 17431 17431 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:8623)
10-10 10:05:43.583 17431 17431 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
10-10 10:05:43.583 17431 17431 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
10-10 10:05:43.583 17431 17431 E AndroidRuntime:    at com.android.internal.os.ExecInit.main(ExecInit.java:50)
10-10 10:05:43.583 17431 17431 E AndroidRuntime:    at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
10-10 10:05:43.583 17431 17431 E AndroidRuntime:    at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:369)
10-10 10:05:43.583 17431 17431 E AndroidRuntime: Caused by: android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service im.status.ethereum/.pushnotifications.ForegroundService
10-10 10:05:43.583 17431 17431 E AndroidRuntime:    at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:54)
10-10 10:05:43.583 17431 17431 E AndroidRuntime:    at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:50)
10-10 10:05:43.583 17431 17431 E AndroidRuntime:    at android.os.Parcel.readParcelableInternal(Parcel.java:5036)
10-10 10:05:43.583 17431 17431 E AndroidRuntime:    at android.os.Parcel.readParcelable(Parcel.java:5018)
10-10 10:05:43.583 17431 17431 E AndroidRuntime:    at android.os.Parcel.createExceptionOrNull(Parcel.java:3187)
10-10 10:05:43.583 17431 17431 E AndroidRuntime:    at android.os.Parcel.createException(Parcel.java:3176)
10-10 10:05:43.583 17431 17431 E AndroidRuntime:    at android.os.Parcel.readException(Parcel.java:3152)
10-10 10:05:43.583 17431 17431 E AndroidRuntime:    at android.os.Parcel.readException(Parcel.java:3094)
10-10 10:05:43.583 17431 17431 E AndroidRuntime:    at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:6998)
10-10 10:05:43.583 17431 17431 E AndroidRuntime:    at android.app.Service.startForeground(Service.java:879)
10-10 10:05:43.583 17431 17431 E AndroidRuntime:    at im.status.ethereum.pushnotifications.ForegroundService$$ExternalSyntheticApiModelOutline2.m(SourceFile:0)
10-10 10:05:43.583 17431 17431 E AndroidRuntime:    at im.status.ethereum.pushnotifications.ForegroundService.onStartCommand(Unknown Source:225)
10-10 10:05:43.583 17431 17431 E AndroidRuntime:    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:5108)
10-10 10:05:43.583 17431 17431 E AndroidRuntime:    ... 11 more
--------- beginning of events
10-15 08:42:26.879 25240 25240 I wm_on_restart_called: [Token=40512448,Component Name=im.status.ethereum.MainActivity,Reason=performRestart,time=0ms]
10-15 08:42:26.890 25240 25240 I wm_on_start_called: [Token=40512448,Component Name=im.status.ethereum.MainActivity,Reason=handleStartActivity,time=10ms]
--------- beginning of main
10-15 08:42:26.891 25240 25240 W WindowOnBackDispatcher: OnBackInvokedCallback is not enabled for the application.
10-15 08:42:26.891 25240 25240 W WindowOnBackDispatcher: Set 'android:enableOnBackInvokedCallback="true"' in the application manifest.
--------- switch to events
10-15 08:42:26.935 25240 25240 I wm_on_resume_called: [Token=40512448,Component Name=im.status.ethereum.MainActivity,Reason=RESUME_ACTIVITY,time=32ms]
10-15 08:42:26.935 25240 25240 I wm_on_top_resumed_gained_called: [Token=40512448,Component Name=im.status.ethereum.MainActivity,Reason=topWhenResuming]
--------- switch to main
10-15 08:42:26.949 25240 25780 D ReactNativeJS: 2024-10-15T08:42:26.943Z DEBUG [native-module.core:330] - [native-module] app-state-change
10-15 08:42:26.951 25240 25780 D ReactNativeJS: 2024-10-15T08:42:26.950Z DEBUG [status-im.common.keychain.events:35] - [keychain] can-save-user-password?
10-15 08:42:26.952 25240 25781 D StatusModule: AppStateChange: active
--------- switch to events
10-15 08:42:26.978 25240 25240 I viewroot_draw_event: [window=VRI[MainActivity],event=Start draw after previous draw not visible]
--------- switch to main
10-15 08:42:26.995 25240 25530 E GoLog   : WARN [10-15|08:42:26.972] messenger nil, not reporting app state change
--------- switch to events
10-15 08:42:26.995 25240 25240 I viewroot_draw_event: [window=VRI[MainActivity],event=reportDrawFinished seqId=0]
--------- switch to main
10-15 08:42:26.996 25240 25781 D RNKeychainManager: Probe cipher storage: CipherStorageFacebookConceal
10-15 08:42:26.997 25240 25781 D RNKeychainManager: Probe cipher storage: CipherStorageKeystoreAesCbc
10-15 08:42:26.997 25240 25781 D RNKeychainManager: Probe cipher storage: CipherStorageKeystoreRsaEcb
10-15 08:42:26.997 25240 25781 D RNKeychainManager: Selected storage: CipherStorageKeystoreAesCbc
10-15 08:42:26.998 25240 25780 D ReactNativeJS: 2024-10-15T08:42:26.997Z DEBUG [native-module.core:375] - [native-module] rooted-device?
--------- switch to events
10-15 08:42:27.504 25240 25240 I wm_on_top_resumed_lost_called: [Token=40512448,Component Name=im.status.ethereum.MainActivity,Reason=topStateChangedWhenResumed]
10-15 08:42:27.560 25240 25240 I view_enqueue_input_event: [eventType=Motion - Cancel,action=im.status.ethereum/im.status.ethereum.MainActivity]
10-15 08:42:29.438 25240 25240 I wm_on_paused_called: [Token=40512448,Component Name=im.status.ethereum.MainActivity,Reason=performPause,time=5ms]
--------- switch to main
10-15 08:42:29.446 25240 25780 D ReactNativeJS: 2024-10-15T08:42:29.441Z DEBUG [native-module.core:330] - [native-module] app-state-change
10-15 08:42:29.446 25240 25781 D StatusModule: AppStateChange: background
10-15 08:42:29.447 25240 25530 E GoLog   : WARN [10-15|08:42:29.446] messenger nil, not reporting app state change
10-15 08:42:29.823 25240 25240 D VRI[MainActivity]: visibilityChanged oldVisibility=true newVisibility=false
--------- switch to events
10-15 08:42:29.841 25240 25240 I viewroot_draw_event: [window=VRI[MainActivity],event=Not drawing due to not visible]
10-15 08:42:30.859 25240 25240 I wm_on_stop_called: [Token=40512448,Component Name=im.status.ethereum.MainActivity,Reason=STOP_ACTIVITY_ITEM,time=0ms]
fryorcraken commented 1 month ago

Happened twice in a row now. Force kill and clear cache seem to help so far.

Parveshdhull commented 3 weeks ago

Update:

So when we start the app, we call the Statusgo.initializeApplication function with the help of executeRunnableStatusGoMethod, which uses the checkAvailability function to check if currentActivity is available. If not, it returns false, and the statusGo function never gets called.

So the activity is being killed, probably due to https://github.com/status-im/status-mobile/issues/20985 and causing this issue. To fix this issue, we have to make sure the activity doesn't get killed/or is relaunched properly. (probably related, will explore further).

Parveshdhull commented 2 weeks ago

to check if currentActivity is available. If not, it https://github.com/status-im/status-mobile/issues/20930#issuecomment-2290649002 returns false

Currently, currentActivity is null, meaning the statusGo function isn't called. This may be due to the crash/error in this GitHub issue, which causes the react-native-status module to lose its reference to currentActivity. Other React Native issues also report null references: issue 37518, issue 8694. This could relate to the activity lifecycle or a crash, which might be expected behavior.

For more on the crash, see: Stack Overflow - Android 12 Foreground Service Exception, Stack Overflow - Benefits of Using Context.startForegroundServiceIntent, and the Android Developer documentation.

Based on this information, it seems that in the file PushNotificationHelper.java, using context.startForegroundService instead of context.startService should resolve the issue.

Parveshdhull commented 2 weeks ago

I created a pull request https://github.com/status-im/status-mobile/pull/21553 to properly initialize the push notification service, and I hope this will resolve the issue.

Losing reference to the current activity in a React Native module is rare, but it can still happen.

If this occurs again, instead of alarming the user with a setup screen, we should display a non-dismissible popup informing them that the app has started in an unusual state and prompting them to force close and restart the app.

Without the current activity reference, users will not only be unable to see their accounts, but the app will also become unusable, as they will not be able to create a new account.

Wdyt? cc @ilmotta @flexsurfer

Parveshdhull commented 1 week ago

If this occurs again, instead of alarming the user with a setup screen, we should display a non-dismissible popup informing them that the app has started in an unusual state and prompting them to force close and restart the app.

Created a follow-up issue https://github.com/status-im/status-mobile/issues/21585