question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Stuck downloads when changing network conditions

See original GitHub issue

Issue 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:closed
  • Created 4 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
ojw28commented, Jan 5, 2020

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 calling DownloadManagerHelper. 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 the DownloadManager resumes its downloads. At some point later the Scheduler 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 the Scheduler 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 a Scheduler and foregroundNotificationId == 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.

0reactions
ojw28commented, Jun 3, 2020

It doesn’t appear to happen as often any more but it still happens.

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found