mhoeher / opentodolist

A simple Todo and task management application - Mirror of https://gitlab.com/rpdev/opentodolist
https://opentodolist.rpdev.net
GNU General Public License v3.0
161 stars 12 forks source link

Automatic Sync stops after running in the background for a while #93

Closed DoraTrix closed 8 months ago

DoraTrix commented 9 months ago

New user of the app, it's great so far, thanks!

One pain-point: I am using the app on two separate Windows boxes, plus my Android phone, with Dropbox as the sync medium. On all of these devices, after the app has been running for some amount of time (by the logs, ~29 hrs on PC, ~46 on Android), automatic syncing stops. There's no failure in the log, it just stops triggering? On both platforms, this can be resolved (once noticed) by closing (force-closing, on Android) the app and restarting it.

Version:

OS:

Things I'm not sure are relevant:

mhoeher commented 9 months ago

Hi @DoraTrix,

first of all: Sorry for the late reply. I am currently on a business trip in India and hence barely found time looking into any updates on the "private side" of life 😉

Regarding the issue you describe: This sounds strange. Basically, the background sync is done by triggering periodically in the background a sync on each library. I also have to admit I didn't notice such symptoms recently, but then, I personally use the app on another set of devices (macOS and iOS; mainly).

If possible:

  1. Could you try to extract logs on both devices and send them to me?
  2. On Android, this would have to be done by using add, if possible.
  3. On Windows, you would have to quit the app and start it again from a command prompt using the option --enable-console - this will cause the app to write any logs to standard output (from where you could copy it or redirect it to a file).
  4. In both cases, make sure the logs don't contain anything you don't want to expose (in particular, file paths...). In doubt, send such information by mail (martin AT rpdev DOT net).
  5. On Android, the app should start up automatically (it already listens for BOOT_COMPLETED). So this shouldn't be an issue.
  6. On Windows, as you stated, by adding the app to auto start, it should start up after build as well. If you can see the tray icon after restart, this should have worked.
  7. About rate limiting when using DropBox: The app already handles this, so this should not cause issues (in theory...).

Thanks a lot in advance!

DoraTrix commented 9 months ago

No worries, I have no strong expectations for response times on free projects!

When I went and checked, the Android app had in fact stopped again after I tweaked the background/power settings for it, so that didn't help. Here is a c/p of the sync log from there - https://pastebin.com/raw/wWcW6pqt. I'm not clear on what you mean by "done by using add, if possible".

I've left it running in the "not syncing" state if there's anything that can help there, a memdump or whatnot?

I'll change the startup for the PC installs to a sub-call from a command window and get those logs in here once it happens again.

DoraTrix commented 9 months ago

Is the --enable-console switch actually making it log to stdout? I tried using a >> to dump to a log file, and it's not and still showing in the command window, which I've never run into before.

Anyway, here's just a snip from the cmd window, after a successful sync, but maybe relevant?

OpenTodoList.BackgroundService: Debug: Checking connectivity for account DropboxAccount(REDACTED) (:0, )
OpenTodoList.DropboxAccount: Debug: Access token of QUuid("{REDACTED}") is recent enough - try to connect with it. (:0, )
OpenTodoList.DropboxAccount: Debug: Account QUuid("{REDACTED}") finished connectivity check with false (:0, )
OpenTodoList.DropboxAccount: Debug: SynqClient::JobError::NetworkRequestFailed : "Error transferring https://api.dropboxapi.com/2/files/list_folder - server replied: Bad Request" (:0, )
DoraTrix commented 9 months ago

Ok - after it stops syncing, it's just regular repetitions of this, with no success messages. There are two different QUuid's being referenced if that makes a difference, but possibly Account and Library are supposed to be different?

OpenTodoList.BackgroundService: Debug: Library QSharedPointer(Library(0x22ecf96e5a0)) "Main Dropbox" has not been synced
 for more than 15min, starting sync now (:0, )
OpenTodoList.BackgroundService: Debug: Sync of library with uid QUuid("{REDACTED UID #1}") requested (:0, )
OpenTodoList.BackgroundService: Debug: Account QUuid("{REDACTED UID #2}") still busy checking connectivity... (:0, )
OpenTodoList.BackgroundService: Debug: Library QSharedPointer(Library(0x22ecf96e860)) "Main Dropbox" has not been synced for more than 15min, starting sync now (:0, )
OpenTodoList.BackgroundService: Debug: Sync of library with uid QUuid("{REDACTED UID #1}") requested (:0, )
OpenTodoList.BackgroundService: Debug: Account QUuid("{REDACTED UID #2}") still busy checking connectivity... (:0, )
OpenTodoList.BackgroundService: Debug: Library QSharedPointer(Library(0x22ecf96df70)) "Main Dropbox" has not been synced for more than 15min, starting sync now (:0, )
OpenTodoList.BackgroundService: Debug: Sync of library with uid QUuid("{REDACTED UID #1}") requested (:0, )
OpenTodoList.BackgroundService: Debug: Account QUuid("{REDACTED UID #2}") still busy checking connectivity... (:0, )
OpenTodoList.BackgroundService: Debug: Account QUuid("{REDACTED UID #2}") still busy checking connectivity... (:0, )
OpenTodoList.BackgroundService: Debug: Library QSharedPointer(Library(0x22ecf96df70)) "Main Dropbox" has not been synced for more than 15min, starting sync now (:0, )
OpenTodoList.BackgroundService: Debug: Sync of library with uid QUuid("{REDACTED UID #1}") requested (:0, )
OpenTodoList.BackgroundService: Debug: Account QUuid("{REDACTED UID #2}") still busy checking connectivity... (:0, )
OpenTodoList.BackgroundService: Debug: Library QSharedPointer(Library(0x22ecf96e650)) "Main Dropbox" has not been synced for more than 15min, starting sync now (:0, )
OpenTodoList.BackgroundService: Debug: Sync of library with uid QUuid("{REDACTED UID #1}") requested (:0, )
OpenTodoList.BackgroundService: Debug: Account QUuid("{REDACTED UID #2}") still busy checking connectivity... (:0, )
OpenTodoList.BackgroundService: Debug: Library QSharedPointer(Library(0x22ecf96d470)) "Main Dropbox" has not been synced for more than 15min, starting sync now (:0, )
OpenTodoList.BackgroundService: Debug: Sync of library with uid QUuid("{REDACTED UID #1}") requested (:0, )
OpenTodoList.BackgroundService: Debug: Account QUuid("{REDACTED UID #2}") still busy checking connectivity... (:0, )
OpenTodoList.main: Debug: Application state changed to Qt::ApplicationActive (:0, )
OpenTodoList.main: Debug: Application state changed to Qt::ApplicationInactive (:0, )
OpenTodoList.main: Debug: Application state changed to Qt::ApplicationActive (:0, )
OpenTodoList.BackgroundService: Debug: Account QUuid("{REDACTED UID #2}") still busy checking connectivity... (:0, )
OpenTodoList.BackgroundService: Debug: Library QSharedPointer(Library(0x22ecf965540)) "Main Dropbox" has not been synced for more than 15min, starting sync now (:0, )
OpenTodoList.BackgroundService: Debug: Sync of library with uid QUuid("{REDACTED UID #1}") requested (:0, )
OpenTodoList.BackgroundService: Debug: Account QUuid("{REDACTED UID #2}") still busy checking connectivity... (:0, )
qml: Debug: Manually started syncing Main Dropbox (qrc:/Menues/LibraryPageActions.qml:40, expression for onTriggered)
OpenTodoList.BackgroundService: Debug: Sync of library with uid QUuid("{REDACTED UID #1}") requested (:0, )
OpenTodoList.BackgroundService: Debug: Account QUuid("{REDACTED UID #2}") still busy checking connectivity... (:0, )
mhoeher commented 8 months ago

Hi @DoraTrix,

sorry again for the long days of silence, the last few days were quite busy plus I caught a bad cold on top 🤧

Thanks for gathering the logs. It looks a little bit, like the Dropbox token refresh somehow "hangs". Some words of explanation here:

Dropbox uses OAuth for authenticating clients towards the server. When you set up a Dropbox account in the app, a long living token is generated and stored locally. In addition, the app needs to generate a short lived token (for which the long lived one can be used) to run any queries against the REST API of Dropbox. This "refresh" of the short lived token happens in the connectivity check mentioned in the logs. For whatever reason, it seems the last network request in the refresh still is pending. I'll try to have a look into this, maybe some kind of timeout already would help to solve this issue.

For your reference, this is the ticket over on GitLab to track development of a fix: https://gitlab.com/rpdev/opentodolist/-/issues/641

DoraTrix commented 8 months ago

Yeah, maybe when a sync trigger encounters a refresh that is still pending, rather than continuing to wait, something that just does a fallback to a state reset of the Dropbox auth and then an immediate retry? Since a complete restart of the app itself does always resolve it, something like that ought to cover it too.

I tried to set up a Windows dev environment to see if I could catch it in a debugger, but I couldn't get a clean build, I'll keep poking at that so maybe I can pitch in.

On Sun, Oct 22, 2023, 7:04 AM Martin Höher @.***> wrote:

Hi @DoraTrix https://github.com/DoraTrix,

sorry again for the long days of silence, the last few days were quite busy plus I caught a bad cold on top 🤧

Thanks for gathering the logs. It looks a little bit, like the Dropbox token refresh somehow "hangs". Some words of explanation here:

Dropbox uses OAuth for authenticating clients towards the server. When you set up a Dropbox account in the app, a long living token is generated and stored locally. In addition, the app needs to generate a short lived token (for which the long lived one can be used) to run any queries against the REST API of Dropbox. This "refresh" of the short lived token happens in the connectivity check mentioned in the logs. For whatever reason, it seems the last network request in the refresh still is pending. I'll try to have a look into this, maybe some kind of timeout already would help to solve this issue.

For your reference, this is the ticket over on GitLab to track development of a fix: https://gitlab.com/rpdev/opentodolist/-/issues/641

— Reply to this email directly, view it on GitHub https://github.com/mhoeher/opentodolist/issues/93#issuecomment-1774063388, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOAHWNHEIWAVKX7BPQGDTKTYAT4UNAVCNFSM6AAAAAA5V5OONKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZUGA3DGMZYHA . You are receiving this because you were mentioned.Message ID: @.***>

mhoeher commented 8 months ago

Hi @DoraTrix,

I tried to implement a fix for the sync issue. If possible, could you please try to download a pre-built version from this pipeline over on GitLab and see if the problem still occurs?

Basically, I added a watchdog timer which - after a minute - stops the online check (so it would be restarted eventually, instead of letting the app run into a dead end).

If you're interested, here's the actual change: https://gitlab.com/rpdev/opentodolist/-/merge_requests/399/diffs

Thanks a lot in advance!

DoraTrix commented 8 months ago

Ok, I've got those running on windows and Android, I'll report back in a couple days to see if they've kept going!

On Wed, Oct 25, 2023 at 3:58 PM Martin Höher @.***> wrote:

Hi @DoraTrix https://github.com/DoraTrix,

I tried to implement a fix for the sync issue. If possible, could you please try to download a pre-built version from this pipeline over on GitLab https://gitlab.com/rpdev/opentodolist/-/pipelines/1049532003 and see if the problem still occurs?

Basically, I added a watchdog timer which - after a minute - stops the online check (so it would be restarted eventually, instead of letting the app run into a dead end).

If you're interested, here's the actual change: https://gitlab.com/rpdev/opentodolist/-/merge_requests/399/diffs

Thanks a lot in advance!

— Reply to this email directly, view it on GitHub https://github.com/mhoeher/opentodolist/issues/93#issuecomment-1779961960, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOAHWNF4R2SFG6IAWDKTMVLYBFVNZAVCNFSM6AAAAAA5V5OONKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZZHE3DCOJWGA . You are receiving this because you were mentioned.Message ID: @.***>

DoraTrix commented 8 months ago

So far so good! The watchdog is kicking in and it's still syncing on both Windows and Android.

mhoeher commented 8 months ago

Thanks for testing! That’s good news, I’ll go ahead and merge the change now.

It’ll be part of the next release.

If you encounter further issues with the sync, please let me know 😉

On 30. Oct 2023, at 08:58, DoraTrix @.***> wrote:

So far so good! The watchdog is kicking in and it's still syncing on both Windows and Android.

— Reply to this email directly, view it on GitHub https://github.com/mhoeher/opentodolist/issues/93#issuecomment-1784658741, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOSSX2QZVGDSE6QNUJPQ5DYB5MYZAVCNFSM6AAAAAA5V5OONKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBUGY2TQNZUGE. You are receiving this because you commented.