seadroid icon indicating copy to clipboard operation
seadroid copied to clipboard

no camera uploads longer lasting than 10 minutes - incl. patch (proof of concept!)

Open hede5562 opened this issue 7 years ago • 3 comments
trafficstars

I have made some videos sized >100 MB. They do successfully upload if I'm at a location with high bandwidth. But they fail uploading after 10 Minutes if the file size is larger or bandwidth is low.

I did find the reason: You are using AbstractThreadedSyncAdapter in combination with AsyncTasks. That's a no go.

Android will run the onPerformSync method within its own thread, where seadroid triggers the sync some other task (AsyncTask). The onPerformSync itself is a background task which get killed by Android on inactivity. With seadroid the onPerformSync thread is just waiting for the AsyncTask tasks so it's indeed idle -> get's killed after some time.

See: https://developer.android.com/reference/android/content/AbstractThreadedSyncAdapter

Nevertheless, even if fixing the 10 minutes problem it will get killed after 30 minutes anyway so artifically generating traffic within onPerformSync is not a solution either.

I did some work (just a proof of concept!) if returning from onPerformSync while the AsyncTasks are still running would be an option. It works! I successfully uploaded a big file to my throttled seafile host (tc qdisc) lasting at least ~ 1 hour. But I haven't tested it extensively, there's certainly something missing (don't know if dbhelper works that way) and I'm pretty sure it's not fitting your coding styles (as is).

Further details: errors which get thrown by Seadroid 2.2.8:

10-10 10:29:36.565  1596  1596 I JobServiceContext: Client timed out while executing (no jobFinished received), sending onStop: 4cd99a0 #1000/103506 com.seafile.seadroid2.debug.cameraupload.provider/com.seafile.seadroid2.debug.account.api2[...]:android
10-10 10:29:36.652 23444  9854 E CameraSyncAdapter: sync aborted because an unknown error
10-10 10:29:36.652 23444  9854 E CameraSyncAdapter: java.lang.InterruptedException
10-10 10:29:36.652 23444  9854 E CameraSyncAdapter:   at java.lang.Thread.sleep(Native Method)
10-10 10:29:36.652 23444  9854 E CameraSyncAdapter:   at java.lang.Thread.sleep(Thread.java:373)
10-10 10:29:36.652 23444  9854 E CameraSyncAdapter:   at java.lang.Thread.sleep(Thread.java:314)
10-10 10:29:36.652 23444  9854 E CameraSyncAdapter:   at com.seafile.seadroid2.cameraupload.CameraSyncAdapter.waitForUploads(CameraSyncAdapter.java:538)
10-10 10:29:36.652 23444  9854 E CameraSyncAdapter:   at com.seafile.seadroid2.cameraupload.CameraSyncAdapter.iterateCursor(CameraSyncAdapter.java:531)
10-10 10:29:36.652 23444  9854 E CameraSyncAdapter:   at com.seafile.seadroid2.cameraupload.CameraSyncAdapter.uploadVideos(CameraSyncAdapter.java:464)
10-10 10:29:36.652 23444  9854 E CameraSyncAdapter:   at com.seafile.seadroid2.cameraupload.CameraSyncAdapter.onPerformSync(CameraSyncAdapter.java:313)
[...]

seadroid-2.2.8-long-running-camera-syncs-proof-of-concept.patch.txt

hede5562 avatar Oct 12 '18 17:10 hede5562

I think this migh've been plagueing me for a while, the camer upload service used to stop itself regularly.

then4p avatar Dec 11 '18 12:12 then4p

@freeplant

shoeper avatar Dec 11 '18 15:12 shoeper

Any news on this? This issue is plaguing me too and it's trivial to reproduce:

  • take any recent Android smartphone
  • record two or more short movies in high quality (e.g. 1 minute each, should easily be 150MB or so)
  • use a slow Wifi (e.g. at a hotel with only 5MBit/s upstream)
  • observe that automatic camera backup is in an endless loop due to failing uploads.

The issue is made worse by seadroid's default behaviour of trying to upload two files at once, which effectively halves the upload speed of the individual transfers. After exactly 10 minutes the uploads fail ... and some time later seadroid tries again ... still failing.

Needless to say, it's highly annoying: it wastes battery, it wastes bandwidth, other uploads are blocked too due to the ever failing 10 minute uploads. (Otherwise camera upload is a great feature of course, but sometimes it makes using seadroid almost impossible.)

gschintgen avatar Sep 03 '20 13:09 gschintgen