fluttercommunity / flutter_downloader

Flutter Downloader - A plugin for creating and managing download tasks.
https://pub.dev/packages/flutter_downloader
BSD 3-Clause "New" or "Revised" License
907 stars 510 forks source link

Garbage Collector issue, when i enqueue above 100 downloads and cancel it and then again enqueue, #733

Open jawwad-iqbal22 opened 1 year ago

jawwad-iqbal22 commented 1 year ago

Describe the bug

So the bug is that garbage collection stop the download, don't start until garbage collector clean by itself during app is running or when i kill the app open it again

To Reproduce

1-first create a list of 100 url (can be small file of mp3) and enquue it in download manager, 2-after that cancel the enqueue download or running download using flutterdownload.remove, flutterdownload.cancel etc. 3-then again enqueue the download and again cancel it. 4-repeat the process 3 to 4 time, On 5th attempt , you will notice your download is taking longer time to start or it may halt for very long time 5- you will notice in flutter log that there is some kind of background garbage cleaning is going. when the garbage collection work done then after that your download start 6- Another way to start the download is to kill your app and start again, you download will start

Expected behavior

Download of Enqueue and Cancel should be smoothly done, should not be halt by any Garbage Collection

Screenshots

Desktop (please complete the following information):

Device information:

Additional context

No

P.S: CANNOT UPDATE THE FLUTTER VERSION TO 3 for specific reasons, So i need to fix this deadlock in FLUTTER 2

Thank you, Awaiting for reply

jawwad-iqbal22 commented 1 year ago

this is the message i am getting

Background concurrent copying GC freed 677855(25MB) AllocSpace objects, 0(0B) LOS objects, 44% free, 30MB/54MB, paused 46us,36us total 141.927ms

i am also getting this message when i cancel or delete from enqueue or running download

I/WM-WorkerWrapper(32100): at java.lang.Thread.run(Thread.java:1012) I/WM-WorkerWrapper(32100): Work [ id=3fc4834e-ef4a-418c-b18d-1441341b8296, tags={ flutter_download_task, vn.hunghd.flutterdownloader.DownloadWorker } ] was cancelled I/WM-WorkerWrapper(32100): java.util.concurrent.CancellationException: Task was cancelled. I/WM-WorkerWrapper(32100): at androidx.work.impl.utils.o.a.d(:1184) I/WM-WorkerWrapper(32100): at androidx.work.impl.utils.o.a.i(:514) I/WM-WorkerWrapper(32100): at androidx.work.impl.utils.o.a.get(:475) I/WM-WorkerWrapper(32100): at androidx.work.impl.k$b.run(:311) I/WM-WorkerWrapper(32100): at androidx.work.impl.utils.g$a.run(:91) I/WM-WorkerWrapper(32100): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137) I/WM-WorkerWrapper(32100): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)

jawwad-iqbal22 commented 1 year ago

this my delete or cancel download function

//CONFIRM DELETE DOWNLOAD Future confirmDeleteDownload(List taskList) async { await setCancelDownload(taskList[0].itemIndex, true); await Future.forEach(taskList, (element) async { if (element.status == DownloadTaskStatus.running) { await FlutterDownloader.pause(taskId: element.taskId); await FlutterDownloader.cancel(taskId: element.taskId); } await FlutterDownloader.remove( taskId: element.taskId, shouldDeleteContent: true); }); }

jawwad-iqbal22 commented 1 year ago

why this package is dead?

bartekpacia commented 1 year ago

why this package is dead?

It's certainly not "dead", it has many users. If by "dead" you mean "no active development", then it's because I don't have enough time to do this.

If you're willing to sacrifice your free time and help maintain it, you're welcome to apply.

781flyingdutchman commented 1 year ago

I published a package optimized for large numbers of file downloads, called background_downloader. I think it addresses your needs, please let me know what you think.