Giter Site home page Giter Site logo

Comments (5)

781flyingdutchman avatar 781flyingdutchman commented on August 11, 2024

Hi! Sorry to hear you're having this problem. A few basics:

  1. Which version of the package are you using?
  2. What platform does this happen on, and what version of that OS?
  3. 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 insert await Future.delayed(const Duration(milliseconds: 200)) after every third enqueue or so. You can look at the implementation of downloadBatch 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.

flying-wizzy avatar flying-wizzy commented on August 11, 2024

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:

  1. newest version of the package, 7.1.0
  2. 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.
  3. I'll share the exact snippet ASAP, but it's basically just a for loop that triggers enqueue() for every Task in the List.

from background_downloader.

781flyingdutchman avatar 781flyingdutchman commented on August 11, 2024

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.

flying-wizzy avatar flying-wizzy commented on August 11, 2024

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.

781flyingdutchman avatar 781flyingdutchman commented on August 11, 2024

No problem, glad it was resolved!

from background_downloader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.