Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Photo / files sync is not working automatically in background #2022

Open
henricazottes opened this issue May 25, 2020 · 7 comments
Open

Photo / files sync is not working automatically in background #2022

henricazottes opened this issue May 25, 2020 · 7 comments

Comments

@henricazottes
Copy link

Hi, I've been using Cozy drive for the past few weeks, and every time I go checking my photos on the website, last ones are not synchronized.
Then I open the Cozy Drive Android app, and synchronization starts.

My main usage of cozy is for photo backup, in case I get my phone stolen or broken. I'd love to have the same behaviour as Google photo, so I don't have to worry about it.

So is this the normal behaviour? Could something be done about it?


App specs:

  • platform: Android
  • version: 1.19.0
  • wifi only: off

Phone specs:

  • model: Samsung S10e
  • background authorization: true
@Crash--
Copy link
Contributor

Crash-- commented May 26, 2020

We can't do nothing about it. We can enhance the first sync process (starting to sync 10k photos is not the best choice), we can send you daily notification to sync your photos in order to do less but more frequently, but background usage starts to be very difficult even on Android.

Since Android 8, lot of work have been done by the Android Team to work on background task / job scheduler.

https://developer.android.com/about/versions/oreo/background

We can be better at it, but I don't know if there is a silver bullet for that.

Do you use other sync app on Android?

@henricazottes
Copy link
Author

Nope, so far I was just using Google photos, which didn't need to sync manually.

Daily report with the number of files needing synchronization as a reminder, or a report triggered when X files have not been sync, could be a start :)

I'll check your link for a better understanding of the limitations, thanks for pointing it out!

@Crash--
Copy link
Contributor

Crash-- commented May 26, 2020

Nope, so far I was just using Google photos, which didn't need to sync manually.

So every-time you take a photo, the photo is synced? It seems we can listen to the broacasted message to upload it. So this is something we can certainly do also. This solution is great for the new photos, but for the old ones, we still need to sync them "once". I'm wondering how Google Photos is handling that (ie If you delete all the photos stored on your google photo account and start to use the app again... :D)

@henricazottes
Copy link
Author

So every-time you take a photo, the photo is synced?

Yup, that was the behavior.

What I don't understand without reading the article is if you can check every so often in background, like every hours, why can't you detect and upload new files at this moment?

Is there a diagram somewhere that explains how the cozy sync works? I can check for Google photo.

@Crash--
Copy link
Contributor

Crash-- commented May 26, 2020

New files are not the issue. We know we can do a lot of stuff to make the synchronization smoother (subscribe to broadcasted message or schedule a job to check new photos. This is something we can do (not done yet, but possible).

The sync mainly works like that ATM. When you start the app, we check the photos and upload the not yet synched photo. The thing that is not displayed in this schema, is the "background service registration and launch". But when the app goes to the background we dispatch this background service to continue the sync as much as we can

const backgroundService = () =>

and we try to wake up it a few times
window.JSBackgroundService.setRepeating(repeatingPeriod, err => {

(this schema is for iOS, but works mainly the same way on Android)
Capture d’écran 2020-05-26 à 10 42 49

This part of Drive is pretty old and its based on the cordova plugin https://github.com/cozy/cordova-plugin-list-library-items

We have a few discussions internally to rewrite this sync process to use the latest android and ios APIs, but it's too much work for us ATM.

If you want to take the subject on Android and try a few things, I can help you ;)

@henricazottes
Copy link
Author

Thanks for the in depth answer!

Do you mean updating the Android part of the Cordova plugin? I can try to have a look, must find some time. But don't expect to much, my android and cordova skills are old for the first and null for the second.

Still don't get why it's not working if the diagram shown here is executed periodically in the background. I need to dig a little into it.

Should I ask my future questions here or do you use a forum for development?

@Crash--
Copy link
Contributor

Crash-- commented May 26, 2020

Still don't get why it's not working if the diagram shown here is executed periodically in the background. I need to dig a little into it.

I think the method we use to execute periodically is not good enough. We have developed few years ago this stuff https://github.com/cozy/cordova-jsbackgroundservice, but we should now use the new APIs provided by Android. I think we should we try to follow the WorkManager (https://developer.android.com/topic/libraries/architecture/workmanager). Currently we use AlarmManager (https://github.com/cozy/cordova-jsbackgroundservice/blob/c879ab01bf708c5c0c2dc0953bf742874ea7760b/src/android/JSBackgroundServicePlugin.java#L51) but if available we should use JobScheduler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants