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

Cancel upload from notification #3563

Merged
merged 1 commit into from
Jan 17, 2024
Merged

Cancel upload from notification #3563

merged 1 commit into from
Jan 17, 2024

Conversation

parneet-guraya
Copy link
Contributor

@parneet-guraya parneet-guraya commented Jan 8, 2024

Fix: #2374

🖼️ Screenshots

Record_2024-01-08-21-51-44.mp4

Functionality Check

  • Folder which is created to upload chunks gets deleted.
  • Due to deletion no chunks of the file are left on the server so if we try to upload the same file again it would start from beginning.
  • Worker which does the uploading work is cancelled.
  • Notification of uploading file is also cancelled.

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not needed
  • 🔖 Capability is checked or not needed
  • 🔙 Backport requests are created or not needed: /backport to stable-xx.x
  • 📅 Milestone is set
  • 🌸 PR title is meaningful (if it should be in the changelog: is it meaningful to users?)

Copy link
Contributor

@rapterjet2004 rapterjet2004 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 👍🏾

@mahibi
Copy link
Collaborator

mahibi commented Jan 16, 2024

i tested with 2 devices.

on one device, there is this an exception whenever i cancel the upload (progress bar stops and notification remains):

2024-01-16 13:35:34.822  7827-7871  WM-WorkerWrapper        com.nextcloud.talk2                  I  Work [ id=8379a708-ccb3-401e-b68f-d88adb5af4f2, tags={ com.nextcloud.talk.jobs.UploadAndShareFilesWorker } ] was cancelled
                                                                                                    java.util.concurrent.CancellationException: Task was cancelled.
                                                                                                    	at androidx.work.impl.utils.futures.AbstractFuture.cancellationExceptionWithCause(AbstractFuture.java:1183)
                                                                                                    	at androidx.work.impl.utils.futures.AbstractFuture.getDoneValue(AbstractFuture.java:513)
                                                                                                    	at androidx.work.impl.utils.futures.AbstractFuture.get(AbstractFuture.java:474)
                                                                                                    	at androidx.work.impl.WorkerWrapper$2.run(WorkerWrapper.java:316)
                                                                                                    	at androidx.work.impl.utils.SerialExecutorImpl$Task.run(SerialExecutorImpl.java:96)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
                                                                                                    	at java.lang.Thread.run(Thread.java:1012)
2024-01-16 13:35:35.093  7827-7903  okhttp.OkHttpClient     com.nextcloud.talk2                  I  <-- 404 Not Found https://sermo.nextcloud.com/remote.php/dav/uploads/marcel2/96a8b16a8d10da74b83d12b4685898f9/0000000025600000-0000000026623999 (325ms)
2024-01-16 13:35:35.093  7827-7903  okhttp.OkHttpClient     com.nextcloud.talk2                  I  Server: nginx/1.24.0
2024-01-16 13:35:35.093  7827-7903  okhttp.OkHttpClient     com.nextcloud.talk2                  I  Date: Tue, 16 Jan 2024 12:35:34 GMT
2024-01-16 13:35:35.094  7827-7903  okhttp.OkHttpClient     com.nextcloud.talk2                  I  Content-Type: application/xml; charset=utf-8
2024-01-16 13:35:35.094  7827-7903  okhttp.OkHttpClient     com.nextcloud.talk2                  I  Transfer-Encoding: chunked
2024-01-16 13:35:35.094  7827-7903  okhttp.OkHttpClient     com.nextcloud.talk2                  I  Connection: keep-alive
2024-01-16 13:35:35.094  7827-7903  okhttp.OkHttpClient     com.nextcloud.talk2                  I  Vary: Accept-Encoding
2024-01-16 13:35:35.094  7827-7903  okhttp.OkHttpClient     com.nextcloud.talk2                  I  Expires: Thu, 19 Nov 1981 08:52:00 GMT
2024-01-16 13:35:35.095  7827-7903  okhttp.OkHttpClient     com.nextcloud.talk2                  I  Cache-Control: no-store, no-cache, must-revalidate
2024-01-16 13:35:35.095  7827-7903  okhttp.OkHttpClient     com.nextcloud.talk2                  I  Pragma: no-cache
2024-01-16 13:35:35.095  7827-7903  okhttp.OkHttpClient     com.nextcloud.talk2                  I  Content-Security-Policy: default-src 'none';
2024-01-16 13:35:35.096  7827-7903  okhttp.OkHttpClient     com.nextcloud.talk2                  I  <?xml version="1.0" encoding="utf-8"?>
2024-01-16 13:35:35.096  7827-7903  okhttp.OkHttpClient     com.nextcloud.talk2                  I  <d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
2024-01-16 13:35:35.096  7827-7903  okhttp.OkHttpClient     com.nextcloud.talk2                  I    <s:exception>Sabre\DAV\Exception\NotFound</s:exception>
2024-01-16 13:35:35.097  7827-7903  okhttp.OkHttpClient     com.nextcloud.talk2                  I    <s:message>File with name //96a8b16a8d10da74b83d12b4685898f9 could not be located</s:message>
2024-01-16 13:35:35.097  7827-7903  okhttp.OkHttpClient     com.nextcloud.talk2                  I  </d:error>
2024-01-16 13:35:35.097  7827-7903  okhttp.OkHttpClient     com.nextcloud.talk2                  I  <-- END HTTP (262-byte body)
2024-01-16 13:35:35.102  7827-7903  ChunkedFileUploader     com.nextcloud.talk2                  E  Something went wrong in ChunkedFileUploader
                                                                                                    at.bitfire.dav4jvm.exception.NotFoundException: HTTP 404 Not Found
                                                                                                    	at at.bitfire.dav4jvm.DavResource.checkStatus(DavResource.kt:376)
                                                                                                    	at at.bitfire.dav4jvm.DavResource.checkStatus(DavResource.kt:358)
                                                                                                    	at at.bitfire.dav4jvm.DavResource.put(DavResource.kt:262)
                                                                                                    	at at.bitfire.dav4jvm.DavResource.put$default(DavResource.kt:244)
                                                                                                    	at com.nextcloud.talk.upload.chunked.ChunkedFileUploader.uploadChunk(ChunkedFileUploader.kt:261)
                                                                                                    	at com.nextcloud.talk.upload.chunked.ChunkedFileUploader.upload(ChunkedFileUploader.kt:106)
                                                                                                    	at com.nextcloud.talk.jobs.UploadAndShareFilesWorker.doWork(UploadAndShareFilesWorker.kt:149)
                                                                                                    	at androidx.work.Worker$1.run(Worker.java:82)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
                                                                                                    	at java.lang.Thread.run(Thread.java:1012)

on the other device, it works, but it's totally slow in response (however this might not be caused by this PR. starting the upload is also slow, might have to be improved by using coroutineWorker with "setExpedited")

@parneet-guraya
Copy link
Contributor Author

parneet-guraya commented Jan 16, 2024

Hi @mahibi 👋
I tested myself but couldn't reproduce the same :-( .

Device: Oneplus 9RT (Android 13)

Record_2024-01-16-20-04-45.2.mp4

Device: Google Pixel 6a (Android 13)

screen-20240116-195338.2.mp4
2024-01-16 13:35:35.102  7827-7903  ChunkedFileUploader     com.nextcloud.talk2                  E  Something went wrong in ChunkedFileUploader
                                                                                                    at.bitfire.dav4jvm.exception.NotFoundException: HTTP 404 Not Found
                                                                                                    	at at.bitfire.dav4jvm.DavResource.checkStatus(DavResource.kt:376)
                                                                                                    	at at.bitfire.dav4jvm.DavResource.checkStatus(DavResource.kt:358)
                                                                                                    	at at.bitfire.dav4jvm.DavResource.put(DavResource.kt:262)
                                                                                                    	at at.bitfire.dav4jvm.DavResource.put$default(DavResource.kt:244)
                                                                                                    	at com.nextcloud.talk.upload.chunked.ChunkedFileUploader.uploadChunk(ChunkedFileUploader.kt:261)
                                                                                                    	at com.nextcloud.talk.upload.chunked.ChunkedFileUploader.upload(ChunkedFileUploader.kt:106)
                                                                                                    	at com.nextcloud.talk.jobs.UploadAndShareFilesWorker.doWork(UploadAndShareFilesWorker.kt:149)
                                                                                                    	at androidx.work.Worker$1.run(Worker.java:82)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
                                                                                                    	at java.lang.Thread.run(Thread.java:1012)

But, I believe the above exception could be happening because the upload folder is deleted (where the chunks are uploaded) but the chunks upload logic still uploading some chunks even if the worker has been cancelled and that is what raising the exception.

on the other device, it works, but it's totally slow in response (however this might not be caused by this PR. starting the upload is also slow, might have to be improved by using coroutineWorker with "setExpedited")

Do you want me to handle this too in this PR or should I keep this for another one?

Signed-off-by: parneet-guraya <gurayaparneet@gmail.com>
@mahibi mahibi force-pushed the upload-noti-cancel branch from cdd0fcc to 6f88c8b Compare January 17, 2024 08:21
@mahibi mahibi merged commit 160426e into master Jan 17, 2024
15 of 16 checks passed
@delete-merged-branch delete-merged-branch bot deleted the upload-noti-cancel branch January 17, 2024 08:25
Copy link
Contributor

Codacy

Lint

TypemasterPR
Warnings8383
Errors88

SpotBugs

CategoryBaseNew
Bad practice66
Correctness88
Dodgy code112112
Internationalization33
Malicious code vulnerability33
Performance66
Security11
Total139139

Copy link
Contributor

APK file: https://www.kaminsky.me/nc-dev/android-artifacts/3563-talk.apk

qrcode

To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud Talk app.

@mahibi
Copy link
Collaborator

mahibi commented Jan 17, 2024

But, I believe the above exception could be happening because the upload folder is deleted (where the chunks are uploaded) but the chunks upload logic still uploading some chunks even if the worker has been cancelled and that is what raising the exception.

I merged for now. If the above exception appears again we can fix with a followup PR

on the other device, it works, but it's totally slow in response (however this might not be caused by this PR. starting the upload is also slow, might have to be improved by using coroutineWorker with "setExpedited")

Do you want me to handle this too in this PR or should I keep this for another one?

if you would like, feel free to give it a try with another PR 👍
I did some approach in #3185 but never found the time to research more about it.
If you think that could be the right direction, feel free to migrate UploadAndShareFilesWorker to coroutineWorker and try out "setExpedited".
If it seems to solve issues, we could continue to migrate more workers to coroutine workers and if necessary setExpedited.

@parneet-guraya
Copy link
Contributor Author

Great 👍, will definitely pick this up

Copy link
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

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

Successfully merging this pull request may close these issues.

cancel button for upload notification
3 participants