Stuck downloads when changing network conditions
See original GitHub issueIssue description
DownloadService race condition causing downloads to not resume when network requirements are met after previously not being met.
The issue appears to be that DownloadManagerHelper.onDownloadChanged
is called before the new service is attached to the DownloadManagerHelper
. Therefore DownloadService.notifyDownloadChanged
is never called and startForeground
is never called on the new service. The app process is then killed after roughly 10 seconds as the scheduler has been cancelled.
Reproduction steps
Using the exoplayer app:
- Start downloading some content
- Click back to exit the app. Downloading notification should be shown.
- Turn off network. Downloading notification should be hidden.
- Wait approximately 2 minutes.
- Turn on network. Downloading notification is not reshown when it should be.
Link to test content
Tested using WV: Clear SD & HD (MP4,H264)
in the sample app.
Version of ExoPlayer being used
2.10.7. Also reproduced the issue on 2.11.1.
Device(s) and version(s) of Android being used
Pixel 3XL Android 10 (QQ1A.191205.008)
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (7 by maintainers)
Top Results From Across the Web
Solved: Re: Downloads randomly getting stuck via Wi-Fi
Hello,. For the past week, downloading files have been a pain via wireless. For some odd reason, when I download a file, it...
Read more >Steam download stuck, not showing progress or keeps restarting
If Steam download is stuck, not showing progress or keeps restarting, then these effective fixes are sure to resolve the issue.
Read more >AP migration - Stuck in downloading status - Cisco Community
Once the AP joins a new controller, it downloads a new softare, reloads and is in the donwloading status again - showing it...
Read more >"Couldn't download - Network issue" error on any files
I am having issues downloading any files over 20 - 30 Mb's. And it isn't my Wi-Fi or ISP or connection at fault....
Read more >FIX: Steam Download Stuck at 0 Bytes - Help Desk Geek
To do that, open the Start menu and go to Settings > Network & Internet > Status > Network reset. Follow that by...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for checking! I see what’s going on now, and yes you’re absolutely right.
What’s happening in this case is that the
DownloadManager
is callingDownloadManagerHelper. onRequirementsStateChanged
, which is then failing to restart the service because the process is in the background (the “wait approximately 2 minutes” part of the reproduction instructions are important, else the process is still classified as being in the foreground).DownloadManagerHelper.onDownloadChanged
is then called as theDownloadManager
resumes its downloads. At some point later theScheduler
then restarts the service, which does work because it starts it as a foreground service.Your PR will cause the
DownloadManagerHelper.onDownloadChanged
events to be processed when theScheduler
restarts the service, but it’s a relatively uncontrolled fix because there aren’t particularly strong guarantees on when this will happen. There are also some related issues, such as what happens if there’s aScheduler
andforegroundNotificationId == FOREGROUND_NOTIFICATION_ID_NONE
. I’d like to spend a bit of time this week seeing if there’s a more controlled fix, that’ll also solve this type of related issue at the same time.We do now have reproduction steps for one case in which downloads fail to resume when network connectivity is restored. We’re tracking this using https://github.com/google/ExoPlayer/issues/7453.