apps-android-commons: Logout doesn't immediately log users out

Summary: When I logout of the app, I see a “Please wait” loading dialog. After the dialog disappears, I expect to see the log-in page but it doesn’t show up. The dialog just disappears and I’m able to use the app as if nothing happened. I’m not able to upload images, though. When I close the app and re-open it I see the login page.

Steps to reproduce:

  1. Open the app
  2. Log in to the app
  3. Log out using the “Log out” option in the side bar menu

I expect to see the log-in screen after that.

System logs: I’m not sure if they are of any use but here are the logs I could get:

V/ActivityThread(26553): updateVisibility : ActivityRecord{1bb6898c token=android.os.BinderProxy@3bbe2786 {fr.free.nrw.commons/fr.free.nrw.commons.contributions.MainActivity}} show : false
D/ActivityManager(  754):  Launching fr.free.nrw.commons, updated priority
D/LocationManagerService(  754): request 3fea43f4 network Request[POWER_LOW network requested=+12s0ms fastest=+12s0ms] from fr.free.nrw.commons(10578)
D/LocationManagerService(  754): request 3fea43f4 gps Request[ACCURACY_FINE gps requested=+12s0ms fastest=+12s0ms] from fr.free.nrw.commons(10578)
E/ContributionsFragment(26553): onFragmentResumed fr.free.nrw.commons.contributions.ContributionsListFragment
E/BufferQueueCore(  188): [fr.free.nrw.commons/fr.free.nrw.commons.contributions.MainActivity] setDefaultMaxBufferCount: setting count to 3, previous is 2
D/StatusBarManagerService(  754): manageDisableList userId=0 what=0x0 pkg=Window{f81301a u0 d0 fr.free.nrw.commons/fr.free.nrw.commons.contributions.MainActivity}
V/WindowStateAnimator(  754): Finishing drawing window Window{f81301a u0 d0 fr.free.nrw.commons/fr.free.nrw.commons.contributions.MainActivity}: mDrawState=DRAW_PENDING
I/Timeline(  754): Timeline: Activity_windows_visible id: ActivityRecord{853b999 u0 fr.free.nrw.commons/.contributions.MainActivity t39860} time:129081857
V/WindowManager(  754): not Base app: Adding window Window{3fccd2bf u0 d0 fr.free.nrw.commons/fr.free.nrw.commons.contributions.MainActivity} at 10 of 14
D/StatusBarManagerService(  754): manageDisableList userId=0 what=0x0 pkg=Window{3fccd2bf u0 d0 fr.free.nrw.commons/fr.free.nrw.commons.contributions.MainActivity}
E/BufferQueueCore(  188): [fr.free.nrw.commons/fr.free.nrw.commons.contributions.MainActivity] setDefaultMaxBufferCount: setting count to 3, previous is 2
V/WindowStateAnimator(  754): Finishing drawing window Window{3fccd2bf u0 d0 fr.free.nrw.commons/fr.free.nrw.commons.contributions.MainActivity}: mDrawState=DRAW_PENDING
V/WindowStateAnimator(  754): Finishing drawing window Window{3fccd2bf u0 d0 fr.free.nrw.commons/fr.free.nrw.commons.contributions.MainActivity}: mDrawState=HAS_DRAWN
V/WindowManager(  754): not Base app: Adding window Window{3205dbdb u0 d0 fr.free.nrw.commons/fr.free.nrw.commons.contributions.MainActivity} at 11 of 15
W/System.err(26553): remove failed: ENOENT (No such file or directory) : /data/data/fr.free.nrw.commons/cache/okhttp-cache/99ec56b47be5d8d13a33c691c3ef9da3.0
W/System.err(26553): remove failed: ENOENT (No such file or directory) : /data/data/fr.free.nrw.commons/cache/okhttp-cache/99ec56b47be5d8d13a33c691c3ef9da3.1
E/BufferQueueCore(  188): [fr.free.nrw.commons/fr.free.nrw.commons.contributions.MainActivity] setDefaultMaxBufferCount: setting count to 3, previous is 2
V/WindowStateAnimator(  754): Finishing drawing window Window{3205dbdb u0 d0 fr.free.nrw.commons/fr.free.nrw.commons.contributions.MainActivity}: mDrawState=DRAW_PENDING
V/WindowStateAnimator(  754): Finishing drawing window Window{3205dbdb u0 d0 fr.free.nrw.commons/fr.free.nrw.commons.contributions.MainActivity}: mDrawState=HAS_DRAWN
W/System.err(26553): remove failed: ENOENT (No such file or directory) : /data/data/fr.free.nrw.commons/cache/okhttp-cache/99ec56b47be5d8d13a33c691c3ef9da3.0
W/System.err(26553): remove failed: ENOENT (No such file or directory) : /data/data/fr.free.nrw.commons/cache/okhttp-cache/99ec56b47be5d8d13a33c691c3ef9da3.1
D/StatusBarManagerService(  754): manageDisableList userId=0 what=0x0 pkg=Window{f81301a u0 d0 fr.free.nrw.commons/fr.free.nrw.commons.contributions.MainActivity}
I/ActivityManager(  754): Start proc 31146:fr.free.nrw.commons:auth/u0a578 for service fr.free.nrw.commons/.auth.WikiAccountAuthenticatorService
W/ResourcesManager(31146): getTopLevelResources: /data/app/fr.free.nrw.commons-1/base.apk / 1.0 running in fr.free.nrw.commons rsrc of package null
I/ACRA    (31146): ACRA is enabled for fr.free.nrw.commons, initializing...
W/System.err(31146): remove failed: ENOENT (No such file or directory) : /data/data/fr.free.nrw.commons/shared_prefs/fr.free.nrw.commons_preferences.xml.bak
W/System.err(31146): remove failed: ENOENT (No such file or directory) : /data/data/fr.free.nrw.commons/shared_prefs/MapboxSharedPreferences.xml.bak
D/SoLoader(31146): adding application source: com.facebook.soloader.DirectorySoSource[root = /data/app/fr.free.nrw.commons-1/lib/arm flags = 0]
D/SoLoader(31146): adding backup source from : com.facebook.soloader.ApkSoSource[root = /data/data/fr.free.nrw.commons/lib-main flags = 1]
D/SoLoader(31146): Preparing SO source: com.facebook.soloader.DirectorySoSource[root = /data/app/fr.free.nrw.commons-1/lib/arm flags = 0]
D/SoLoader(31146): Preparing SO source: com.facebook.soloader.ApkSoSource[root = /data/data/fr.free.nrw.commons/lib-main flags = 1]
V/fb-UnpackingSoSource(31146): locked dso store /data/data/fr.free.nrw.commons/lib-main
V/fb-UnpackingSoSource(31146): releasing dso store lock for /data/data/fr.free.nrw.commons/lib-main (from syncer thread)
V/fb-UnpackingSoSource(31146): not releasing dso store lock for /data/data/fr.free.nrw.commons/lib-main (syncer thread started)
D/SoLoader(31146): libmapbox-gl.so not found on /data/data/fr.free.nrw.commons/lib-main
D/SoLoader(31146): libmapbox-gl.so found on /data/app/fr.free.nrw.commons-1/lib/arm
V/AlarmManagerEXT(  754): <AccPackages> fr.free.nrw.commons
E/SQLiteLog(26553): (28) file unlinked while open: /data/data/fr.free.nrw.commons/databases/commons.db
W/System.err(26553): remove failed: ENOENT (No such file or directory) : /data/data/fr.free.nrw.commons/cache/image_cache/v2.ols100.1

Device and Android version: Samsung SM-J111F, Android 5.1.1

Commons app version: 2.12.3.623

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 31 (15 by maintainers)

Commits related to this issue

Most upvoted comments

@sivaraam @macgills What I found out that particularly updateAllDatabases(); in

sessionManager.logout()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(() -> {
                    Timber.d("All accounts have been removed");
                    clearImageCache();
                    //TODO: fix preference manager
                    defaultPrefs.clearAll();
                    defaultPrefs.putBoolean("firstrun", false);
                    updateAllDatabases();
                    logoutListener.onLogoutComplete();
                });

is responsible for the delay!

The reason seems to be due to this Exception - Cannot access database on the main thread since it may potentially lock the UI for a long period of time.

Thanks for pointing me to this issue, should be fixed by #3649 .

Let me know if you need more information. I’m able to reproduce the issue reliably. It happens for me all the time.

 .observeOn(AndroidSchedulers.mainThread())

In English “everything below this line runs on the main thread”

If we don’t execute the above code still it doesn’t go back to the LoginActivity.

@gouri-panda It does redirect to LoginActivity for me if I comment out that particular line.

It works on the background thread. Does this affect the UI? correct me if I am wrong:)

Ideally, it should but I got this exception while debugging.

@gouri-panda Thanks for the update. I’m unassigning the issue for now. Let us know if you get any leads, I’ll assign it back 😃

@gouri-panda Sure but before implementation please discuss your approach and the root cause of the delay.

Just to mention that this issue is similar to #2764

I’m not sure if this is a duplicate of that for the following reason: In my case, I actually don’t see the login page at all after I logout. I waited for around 2 minutes and still didn’t see the logout screen. 🤷‍♂ As mentioned in the description, I’m even able to go to other places such as Nearby, Explore etc.

One of the processes in logout is causing the delay, I remember trying to find out the root cause of it but stopped working on it after a few days. This issue is subjective to the user, for me I can log out instantly but sometimes I face the same issue.

Just to mention that this issue is similar to #2764

I’m not sure if this is a duplicate of that for the following reason: In my case, I actually don’t see the login page at all after I logout. I waited for around 2 minutes and still didn’t see the logout screen. 🤷‍♂ As mentioned in the description, I’m even able to go to other places such as Nearby, Explore etc.