DownloadManager requests delayed on Android Pie
Asked Answered
S

1

10

I have been using the DownloadManager APIs to handle downloads in one app for about 3 years. Recently I had some users on Android Pie complaining that sometimes downloads get stuck for several minutes before actually starting, thus compromising the UX: some of them had to reinstall the app to make them work correctly, some others had the issue fixed itself over time. Please note that I haven't set any special settings to the DownloadManager.Request instances (e.g. allowedNetworkTypes, setRequiresCharging, ...).

My understanding of the problem is that requests get stuck in the pending or paused status for a long time before getting started. Didn't notice any significant changes introduced in the SDK 28, although it's not important since I'm targeting API level 27.

Has anyone experienced something similar and came up with some workarounds? Thank you

Shaunna answered 28/8, 2018 at 10:43 Comment(9)
maybe they are pending since there is a fixed limit of current downloads and that limit has been reached... but its just wild speculationCrosspollinate
Bear in mind that the implementation of DownloadManager not only varies by OS version, but can vary by device manufacturer. DownloadManager has never been a good choice if the download is time-sensitive.Nerval
@Crosspollinate there is a limit for sure but apparently there wasn't anything else queued at that moment.Shaunna
@Nerval Really appreciate your comment, but I have reasons to keep using such a helpful system service. I was just asking myself about any changes in Android Pie since users across all the other OS versions (and manufacturers) aren't complaining at all about itShaunna
So it turns out that deleting the Download Manager app cache and data just once completely restores the functionality, meaning that enqueued downloads start immediately (of course taking into account the concurrency limit).Shaunna
@MatteoInnocenti Hi. I just experienced the same issue right now on a Pixel 2 9.0 device. Can you tell me how did you reset the Download Manager cache ? I didn't found it in setting's applications list. Thx.Bannerol
@Bannerol see here under "clear cache & data from download manager" support.google.com/googleplay/answer/7512202?hl=enShaunna
Did you got any solution.I also face the same issue in pie updateBuke
#53493577Suppositious
J
6

As mentioned in the comments above, clearing the Download manager cache and data resolves this problem on Android 9 Pie. To clear these settings, you need to go to Apps & notifications, click the option to See all apps, tap the options menu in the upper-right corner, select Show system, select Download Manager from the list, tap on Storage, then clear the cache and storage.

When troubleshooting this problem I discovered that when trying to use DownloadManager to download a file to a public directory, the following warning was written to the log if a public download location was used:

DownloadManager: Path appears to be invalid: /storage/emulated/0/Download/File Name

This error appears irrespective of whether the app has the storage permission. However, it appears to be a false warning that is logged by isFilenameValidInExternalPackage() (source code) when checking if the file is outside an app directory and is run even if the app has the storage permission. As such, this false warning continues to appear even after clearing DownloadManager's cache and storage, although the download works anyway.

Edit: this problem appears to recur periodically. Typically, force stopping Download Manager resolves it temporarily. Hopefully Google releases a permanent fix.

Jackal answered 27/10, 2018 at 21:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.