-
Notifications
You must be signed in to change notification settings - Fork 189
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 Android Large Download Failure #1231
base: master
Are you sure you want to change the base?
Conversation
InternalDownloadManager takes in the File parameter, this will be used to check if it already exists, and if so use it's byte length to continue. The download now starts the range request at the end of the last byte length.
Update InternalDownloadManager.kt
I spent some time trying to get this and #1230 to work both in emulation and on my phone this morning but was not successful in getting the download to resume. Is there a specific way you're testing this to show the download resumes? I tried:
|
Using the original code on my personal phone the download would never finish. It would freeze up. So I found in the logcat that it would randomly crash with an unexpected end of stream error. I never encountered a the end of stream error or a way to simulate it during emulation even though I was emulating the exact same settings as my personal phone. I was able to test it using my phone and would see that when it encountered the end of stream error it would resume right away without any lack of progress. I was able to use it to download multiple books without it freezing up. This is my first time using github and working on a community project. I should have been a bit more extensive on my testing. I fixed it for the issue I was having hoping it would be the issue that other people are having. I just finished similar testing to what you did and found that when the internet is shut off during emulation it closes the socket and the listeners mark the download as complete even though it is not. And because it has a file stored, the download button isn't showing up to resume the incomplete file. Thank you for bringing this to my attention. I think I have an idea on how to fix this and will hopefully have an update that will handle these issues. |
No worries, I was just trying to review the changes but also haven't really experienced the download issue in the first place myself so not sure how to reproduce it. I'm not sure if the listener marking the download as finished is due to the current so behavior or your changes. I would expect it is the current behavior, but I'm not as familiar with the mobile apps. You can continue adding commits to the same branch and this PR will update automatically so it's easier to keep the discussion in one place. |
I think the hardest thing about this issue was that it is very difficult to replicate the end of stream error that would randomly happen and cause downloads to freeze. But your comment has got me thinking about the two other cases that can cause incomplete downloads, loss of internet connection and closing the app partially through a download. I don't know how often a user might experience these issues, but it seems like a fun challenge to try and fix. I believe I understand why and how they happen, I'll see if I can come up with solution. |
Fixed progress Callback percentages.
Removed logging used for testing.
Cleaning up code.
Good that people are working on this issue as I've encountered various download timeouts and errors that are probably related to this. As an idea for "testing", in scenarios like this I have deliberately compiled my backend API with "chaos" wrappers around various endpoint (or feature flags etc.) For example, if we did this with the API, you could enable a "network timeout" chaos parameter that could always stop the download stream from the server end after X seconds .. It can be a bit tricky to emulate a true failure here, and it depends on what API hosting library your using. Another alternative is to proxy your calls through ToxiProxy which is excellent for this type of thing. You can configure the proxy endpoint to timeout, slow down and various other things to simulate network connectivity being dropped etc.. |
The updated InternalDownloadManger takes in the downloaded file as the parameter. This way if it exits, it will use it's byte length as the starting Range parameter for the remaining download.