Syncing fails on Android when the app is not in foreground
On Android, when syncing a project, the app needs to be in foreground. If it goes background or the phone screen is off, it will most probably fail randomly leaving the project locked server-side. Users need to wait 5-10 minutes for the locks being cleared to make another attempt to sync the project.
Related tickets: #585 #586 #1684 #2470
duplicate of https://github.com/MerginMaps/mobile/issues/2470 duplicate of https://github.com/MerginMaps/mobile/issues/1684
Steps to reproduce:
- Turn off wifi (it seems to resume syncing normally when on wifi) - we are trying to reproduce the problem as a user in the field
- Modify a project on your mobile - possibly add some heavy files so syncing would need some time to complete
- Start syncing (Other users can't sync from now on)
- Receive a phone call or start using another app for a few minutes -> syncing fails
- Turning your mobile screen off would result in a failure either
An excerpt from a log file when another app was used (from 12:03:48) during syncing - it fails after about 10 minutes at 12:11:03 when user switched back to MM app.
2023-11-30T12:03:48.119Z push support/test_sync_background: Uploading item: https://public.cloudmergin.com//v1/project/push/chunk/2e21452b-2810-45ed-a53b-0b22d931439a/9cfa9ec8-3855-4ab0-813e-d5d0857b7d52
2023-11-30T12:03:48.350Z push support/test_sync_background: Uploaded successfully: 9cfa9ec8-3855-4ab0-813e-d5d0857b7d52
2023-11-30T12:03:48.351Z push support/test_sync_background: Uploading item: https://public.cloudmergin.com//v1/project/push/chunk/2e21452b-2810-45ed-a53b-0b22d931439a/7ead37d0-e10f-4452-a291-c7555212339e
2023-11-30T12:03:48.483Z Input: "Application changed state to:" Qt::ApplicationSuspended
2023-11-30T12:11:02.913Z push support/test_sync_background: Uploaded successfully: 7ead37d0-e10f-4452-a291-c7555212339e
2023-11-30T12:11:02.916Z push support/test_sync_background: Uploading item: https://public.cloudmergin.com//v1/project/push/chunk/2e21452b-2810-45ed-a53b-0b22d931439a/5d558770-6638-456c-bb57-56ec18733db9
2023-11-30T12:11:02.994Z Input: "Application changed state to:" Qt::ApplicationActive
2023-11-30T12:11:03.597Z push support/test_sync_background: FAILED - Error transferring https://public.cloudmergin.com//v1/project/push/chunk/2e21452b-2810-45ed-a53b-0b22d931439a/5d558770-6638-456c-bb57-56ec18733db9 - server replied: NOT FOUND. The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
2023-11-30T12:11:03.658Z sync support/test_sync_background: ### FAILED ###