-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Fix auto upload does not start automatically #12337
Fix auto upload does not start automatically #12337
Conversation
Just tested my "new" getFileChecksum, and it returns the same result as the old one did for the same file (tested with 1 file), so I guess it should work fine. |
@JonasMayerDev App is crashing here is the log
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You must check implementation on Android 14 emulator. ForegroundServiceHelper may solve this problem
@alperozturk96 Do you have a better idea for the manifest.xml entry? I think this is not optimal? |
app/src/main/java/com/owncloud/android/datamodel/FilesystemDataProvider.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Jonas Mayer <[email protected]>
Signed-off-by: Jonas Mayer <[email protected]>
Signed-off-by: Jonas Mayer <[email protected]>
Signed-off-by: Jonas Mayer <[email protected]>
Signed-off-by: Jonas Mayer <[email protected]>
9359dd4
to
6c834f4
Compare
APK file: https://www.kaminsky.me/nc-dev/android-artifacts/12337.apk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've given this PR a quick test run and have encountered the following exception:
Logcat
WM-Processor I Moving WorkSpec (29319770-c67b-40c5-bf9e-84dc3f2ac140) to the foreground
UploadsStorageManager D QUERY: (status== ? OR last_result==9 OR last_result==13 OR last_result==11 OR last_result==14 ) AND last_result!= 16 ROWID: -1
WM-SystemFgDispatcher I Started foreground service Intent { act=ACTION_START_FOREGROUND cmp=com.nextcloud.client/androidx.work.impl.foreground.SystemForegroundService (has extras) }
MediaProvider D Reading images for DCIM
UploadsStorageManager V getUploads() got 0 rows from page 0, 0 rows total so far, last ID -1
UploadsStorageManager V getUploads() returning 0 (0) rows after reading 1 pages
UploadsStorageManager D QUERY: (status== ? OR last_result==9 OR last_result==13 OR last_result==11 OR last_result==14 ) AND last_result!= 16 ROWID: -1
UploadsStorageManager V getUploads() got 0 rows from page 0, 0 rows total so far, last ID -1
UploadsStorageManager V getUploads() returning 0 (0) rows after reading 1 pages
WM-Processor I Moving WorkSpec (29319770-c67b-40c5-bf9e-84dc3f2ac140) to the foreground
WM-Processor I Moving WorkSpec (29319770-c67b-40c5-bf9e-84dc3f2ac140) to the foreground
WM-WorkerWrapper E Work [ id=2f00d1e0-c91b-40e6-8524-501dffca5e18, tags={ com.nextcloud.client.jobs.MediaFoldersDetectionWork, *, name:immediate_media_folder_detection, timestamp:1704785714230, class:MediaFoldersDetectionWork } ] failed because it threw an exception/error
java.util.concurrent.ExecutionException: android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 1
at androidx.work.impl.utils.futures.AbstractFuture.getDoneValue(AbstractFuture.java:516)
at androidx.work.impl.utils.futures.AbstractFuture.get(AbstractFuture.java:475)
at androidx.work.impl.WorkerWrapper$2.run(WorkerWrapper.java:317)
at androidx.work.impl.utils.SerialExecutorImpl$Task.run(SerialExecutorImpl.java:96)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)
Caused by: android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 1
at android.database.AbstractCursor.checkPosition(AbstractCursor.java:521)
at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:139)
at android.database.AbstractWindowedCursor.getLong(AbstractWindowedCursor.java:77)
at android.database.CursorWrapper.getLong(CursorWrapper.java:131)
at com.owncloud.android.datamodel.SyncedFolderProvider.createSyncedFolderFromCursor(SyncedFolderProvider.java:346)
at com.owncloud.android.datamodel.SyncedFolderProvider.findByLocalPathAndAccount(SyncedFolderProvider.java:208)
at com.nextcloud.client.jobs.MediaFoldersDetectionWork.doWork(MediaFoldersDetectionWork.kt:154)
at androidx.work.Worker$1.run(Worker.java:82)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)
WM-WorkerWrapper I Worker result FAILURE for Work [ id=2f00d1e0-c91b-40e6-8524-501dffca5e18, tags={ com.nextcloud.client.jobs.MediaFoldersDetectionWork, *, name:immediate_media_folder_detection, timestamp:1704785714230, class:MediaFoldersDetectionWork } ]
WM-Processor I Moving WorkSpec (29319770-c67b-40c5-bf9e-84dc3f2ac140) to the foreground
WM-WorkerWrapper I Worker result SUCCESS for Work [ id=29319770-c67b-40c5-bf9e-84dc3f2ac140, tags={ com.nextcloud.client.jobs.FilesSyncWork, *, name:immediate_files_sync, timestamp:1704785714229, class:FilesSyncWork } ]
WM-SystemFgDispatcher I Stopping foreground service
This occurred after I moved a 1GB test file into the specified auto-upload directory. At first glance this looks to be another issue, that doesn't stem from this change.
Later on, I've tried again, renaming the test file and got the following log entries:
Logcat
WM-WorkerWrapper I Work [ id=c9bd3090-e9fe-4f4b-bc37-95dc04b3144c, tags={ com.nextcloud.client.jobs.ContentObserverWork, *, name:content_observer, timestamp:1704785714230, class:ContentObserverWork } ] was cancelled
java.util.concurrent.CancellationException: Task was cancelled.
at androidx.work.impl.utils.futures.AbstractFuture.cancellationExceptionWithCause(AbstractFuture.java:1184)
at androidx.work.impl.utils.futures.AbstractFuture.getDoneValue(AbstractFuture.java:514)
at androidx.work.impl.utils.futures.AbstractFuture.get(AbstractFuture.java:475)
at androidx.work.impl.WorkerWrapper$2.run(WorkerWrapper.java:317)
at androidx.work.impl.utils.SerialExecutorImpl$Task.run(SerialExecutorImpl.java:96)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)
MediaProvider D Reading images for DCIM
WM-WorkerWrapper I Worker result SUCCESS for Work [ id=8f23593d-5431-4981-a960-39f82e604679, tags={ com.nextcloud.client.jobs.MediaFoldersDetectionWork, *, name:immediate_media_folder_detection, timestamp:1704786164352, class:MediaFoldersDetectionWork } ]
WM-Processor I Moving WorkSpec (381138c2-92f5-44a4-b84d-5eff98203d3a) to the foreground
WM-SystemFgDispatcher I Started foreground service Intent { act=ACTION_START_FOREGROUND cmp=com.nextcloud.client/androidx.work.impl.foreground.SystemForegroundService (has extras) }
UploadsStorageManager D QUERY: (status== ? OR last_result==9 OR last_result==13 OR last_result==11 OR last_result==14 ) AND last_result!= 16 ROWID: -1
UploadsStorageManager V getUploads() got 0 rows from page 0, 0 rows total so far, last ID -1
UploadsStorageManager V getUploads() returning 0 (0) rows after reading 1 pages
UploadsStorageManager D QUERY: (status== ? OR last_result==9 OR last_result==13 OR last_result==11 OR last_result==14 ) AND last_result!= 16 ROWID: -1
UploadsStorageManager V getUploads() got 0 rows from page 0, 0 rows total so far, last ID -1
UploadsStorageManager V getUploads() returning 0 (0) rows after reading 1 pages
WM-Processor I Moving WorkSpec (381138c2-92f5-44a4-b84d-5eff98203d3a) to the foreground
WM-Processor I Moving WorkSpec (381138c2-92f5-44a4-b84d-5eff98203d3a) to the foreground
WM-Processor I Moving WorkSpec (381138c2-92f5-44a4-b84d-5eff98203d3a) to the foreground
UploadsStorageManager V Inserting 1 uploads
FileContentProvider D applying batch in provider com.owncloud.android.providers.FileContentProvider@8486d7d (temporary: false)
FileContentProvider D applied batch in provider com.owncloud.android.providers.FileContentProvider@8486d7d
UploadsStorageManager D notifyObserversNow
WM-WorkerWrapper I Worker result SUCCESS for Work [ id=381138c2-92f5-44a4-b84d-5eff98203d3a, tags={ com.nextcloud.client.jobs.FilesSyncWork, *, name:immediate_files_sync, timestamp:1704786164352, class:FilesSyncWork } ]
WM-SystemFgDispatcher I Stopping foreground service
UploadsStorageManager D QUERY: status==0 OR last_result==9 OR last_result==13 OR last_result==11 OR last_result==14 AND account_name== ? ROWID: -1
FilesUploadWorker D Handling 1 uploads for account [email protected]:8080
UploadsStorageManager D Retrieve job com.owncloud.android.db.OCUpload@6b1b26b for id 2
UploadsStorageManager V Updating /storage/emulated/0/DCIM/test.png with status=UPLOAD_IN_PROGRESS
UploadsStorageManager D updateUpload returns with: 1 for file: /storage/emulated/0/DCIM/test.png
UploadsStorageManager D notifyObserversNow
UploadFileOperation D normal upload
UploadFileOperation D Checking name collision in server
OwnCloudClient #0 D REQUEST HEAD /remote.php/dav/files/alice/InstantUpload/DCIM/test.png
TrafficStats D tagSocket(94) with statsTag=0xffffffff, statsUid=-1
ExistenceC...eOperation D Existence check for http://10.0.2.2:8080/remote.php/dav/files/alice/InstantUpload/DCIM/test.png targeting for existence finished with HTTP status 404(FAIL)
UploadsStorageManager D Retrieve job com.owncloud.android.db.OCUpload@15301e0 for id 2
UploadsStorageManager V Updating /storage/emulated/0/DCIM/test.png with status=UPLOAD_IN_PROGRESS
UploadsStorageManager D updateUpload returns with: 1 for file: /storage/emulated/0/DCIM/test.png
UploadsStorageManager D notifyObserversNow
OwnCloudClient #0 D REQUEST MKCOL /remote.php/dav/uploads/alice/8bdafcf274931efebe4bf35bebfc65ab
OwnCloudClient #0 D REQUEST PROPFIND /remote.php/dav/uploads/alice/8bdafcf274931efebe4bf35bebfc65ab
TrafficStats D tagSocket(105) with statsTag=0xffffffff, statsUid=-1
OwnCloudClient #0 D REQUEST PUT /remote.php/dav/uploads/alice/8bdafcf274931efebe4bf35bebfc65ab/000001
...
This time I was met with a File upload conflict notification. And when clicking on Resolve conflict an error message appeared, stating that the dialogue couldn't be created.
In both cases, the upload was unsuccessful. Again, I'm not sure how much of that has to do with this pull request.
@ZetaTom I am not entirely sure but as you said I can not imagine how these fails are caused by this pr... Could you maybe do the exact same thing on master and see if it works there? And if you have time test again in this PR to see if it is a reliably reproducible issue for you? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After some trial and error, I think there's either something wrong with my local instance or it's also happening on master. Either way, this PR doesn't seem to directly affect this behaviour.
/backport to stable-3.27 |
The backport to stable-3.27 failed. Please do this backport manually. # Switch to the target branch and update it
git checkout stable-3.27
git pull origin stable-3.27
# Create the new backport branch
git checkout -b fix/foo-stable-3.27
# Cherry pick the change from the commit sha1 of the change against the default branch
# This might cause conflicts. Resolve them.
git cherry-pick abc123
# Push the cherry pick commit to the remote repository and open a pull request
git push origin fix/foo-stable-3.27 Error: Unknown error More info at https://docs.nextcloud.com/server/latest/developer_manual/getting_started/development_process.html#manual-backport |
Screen_recording_20240103_123529.webm
Add foreground info (also interesting for user) to prevent android killing the worker. (Only visible if worker is active more than ca. 1s -> Use large folder with many files for testing)
Make getFileChecksum a lot faster (previously over 1 h for a folder of 6000 Images now only minutes)
Previously 7.5s
Now 15ms
|_ Should be tested (maybe too good to be true)
For me, it also helps with #12141