Comments (5)
Hi! Sorry to hear you're having this problem. A few basics:
- Which version of the package are you using?
- What platform does this happen on, and what version of that OS?
- Can you share the code snippet of how you're enqueueing your tasks?
As for fixes, a few ideas:
- Try using `downloadBatch' instead of separate downloads
- If you use
enqueue
then insertawait Future.delayed(const Duration(milliseconds: 200))
after every third enqueue or so. You can look at the implementation ofdownloadBatch
to see how this is done there. Reason is I found that enqueueing without a break sort of chokes the queue.
For what it's worth, I use this package to download >1000 files at once (albeit a bit smaller, more like 2Mb each) and it works without issues so I think we should be able to solve this.
from background_downloader.
Thank you for your input, that sounds promising!
I'll try your ideas and will give detailed feedback on your basic questions later today (25.05.) or latest tomorrow.
I'll answer what I can right away:
- newest version of the package, 7.1.0
- Android platform, I only tried my Xiaomi Redmi Note 11 (Android 12 SKG1.210908.001) and on a Pixel 6 Emulator with the newest available Android distribution.
- I'll share the exact snippet ASAP, but it's basically just a
for
loop that triggersenqueue()
for every Task in the List.
from background_downloader.
Thanks. I do think the issue is the for loop without yielding for processing. Here's how it's implemented in downloadBatch
(where we also enqueue a list of tasks):
var counter = 0;
for (final task in tasks) {
taskFutures.add(_enqueueAndAwait(task,
taskStatusCallback: taskStatusCallback,
taskProgressCallback: taskProgressCallback));
counter++;
if (counter % 3 == 0) {
// To prevent blocking the UI we 'yield' for a few ms after every 3
// tasks we enqueue
await Future.delayed(const Duration(milliseconds: 50));
}
}
You would replace the bit that says taskFutures.add(_enqueueAndAwait
with a regular FileDownloader().enqueue
.
from background_downloader.
I did my testing now, it seems like it was my fault all along, because I am using the library in an edge case at the moment: For testing purposes, I was using the very same download link for all the download tasks, because I don't have the actual download links for the files yet.
Now I have tried some other random but unique 120 download links and the downloads completed as expected. It didn't even need the little yielding for 50 milliseconds to do the trick. I will nevertheless switch to the downloadBatch
method in the future, as to not block the UI.
Maybe the operating system in the background is assuming some kind of error, if you try to download the same file too many times and that caused the tasks to get stuck.
So, sorry for bothering you and thank you for helping out this quickly again!
from background_downloader.
No problem, glad it was resolved!
from background_downloader.
Related Issues (20)
- [Android] notification icon HOT 3
- Large attachment uploading takes a while HOT 2
- Build failure with `background_downloader` due to missing Kotlin plugin HOT 3
- Monthly issue metrics report for opened issues and prs
- Monthly issue metrics report for closed issues and prs
- Receive status update in background HOT 6
- Lack of Docs for `downloadBatch` HOT 1
- Upload tasks get randomly restarted on a slow Android device HOT 4
- Duplicate Task when uploading an image HOT 6
- Could not find org.jetbrains.kotlin:kotlin-serialization-compiler-plugin-embeddable:1.7.10. HOT 3
- Failed to open file on Android java.lang.IllegalArgumentException: Failed to find configured root that contains: HOT 4
- Android build is failing due to missing Kotlin lib HOT 1
- IOS download error HOT 6
- kotlin-serialization-compiler-plugin-embeddable:1.7.10. HOT 1
- Monthly issue metrics report for opened issues and prs
- Monthly issue metrics report for closed issues and prs
- when use FileDownloader().download() on IOS devices, it throws Exception "could not enqueue DownloadTask"
- downloadBatch can't be cancelled mid download
- ParallelDownloadTask: All Chunks Cancelled Unexpectedly HOT 5
- can't be cancelled mid download all cancel api HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from background_downloader.