tanoDxyz / GDownload

Light Weight, Fast 🚀 , Easy to Use, Reliable Download client for android.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RejectedExecutionException

freehussain opened this issue · comments

hello,

i have the issue below even i initialized the library on mainactivity, this happens after 1 hour of being application in background, the application is single task

E  FATAL EXCEPTION: main
                                                                                                java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.FutureTask@6bac32c rejected from java.util.concurrent.ThreadPoolExecutor@504b1f5[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 1]
                                                                                                	at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2086)
                                                                                                	at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:848)
                                                                                                	at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1394)
                                                                                                	at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:118)
                                                                                                	at com.tanodxyz.gdownload.executors.BackgroundExecutorImpl.execute(BackgroundExecutorImpl.kt:10)
                                                                                                	at com.tanodxyz.gdownload.GDownload.runOnBackground(GDownload.kt:184)
                                                                                                	at com.tanodxyz.gdownload.GDownload.getFreeDownloaderOrCreateNewOne(GDownload.kt:77)
                                                                                                	at com.tanodxyz.gdownload.GDownload.freeDownloader(GDownload.kt:415)
                                                                                                	at com.tanodxyz.gdownload.GDownload.freeDownloader$default(GDownload.kt:398)
                                                                                                	at org.goldenquran.freesoft.ui.booksLibrary.UtilsKt.downloadBookItem(Utils.kt:28)
                                                                                                	at org.goldenquran.freesoft.ui.booksLibrary.BooksListFragment$setBooks$1$1.invoke(BooksListFragment.kt:68)
                                                                                                	at org.goldenquran.freesoft.ui.booksLibrary.BooksListFragment$setBooks$1$1.invoke(BooksListFragment.kt:69)
                                                                                                	at org.goldenquran.freesoft.ui.booksLibrary.BooksListAdapter.onBindViewHolder$lambda$1(BooksListAdapter.kt:77)
                                                                                                	at org.goldenquran.freesoft.ui.booksLibrary.BooksListAdapter.$r8$lambda$_XjqJdT-IdMqBeMhCfmxZBPr_Ts(Unknown Source:0)
                                                                                                	at org.goldenquran.freesoft.ui.booksLibrary.BooksListAdapter$$ExternalSyntheticLambda0.onClick(Unknown Source:4)
                                                                                                	at android.view.View.performClick(View.java:7465)
                                                                                                	at android.view.View.performClickInternal(View.java:7438)
                                                                                                	at android.view.View.access$3600(View.java:813)
                                                                                                	at android.view.View$PerformClick.run(View.java:28511)
                                                                                                	at android.os.Handler.handleCallback(Handler.java:938)
                                                                                                	at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                                	at android.os.Looper.loop(Looper.java:268)
                                                                                                	at android.app.ActivityThread.main(ActivityThread.java:8019)
                                                                                                	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:627)
                                                                                                	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:997)

please post your

library initialization code
and also
your download code.

i found that if your are downloading a file and the application in background (after press back button many times ), this issue happened

thank you for further details.
i am investigating it.

Anthoer case, if you are downloading form fragment and go another one a crash comes I think it's the same as above

checkout the following link.
https://github.com/tanoDxyz/GDownload#%EF%B8%8Fremember%EF%B8%8F

moreover
your code is scheduling a download when the lifecycle associated to library is destroyed.

avoid passing lifecycle while calling GDownload.init()
also
GDownload.freeDownloader(activity) avoid passing activity, instead use context.

there is also an activity named as SingleDownloadLifecycleSurvivalActivity in sample app which explains how one can
continue the download after the fragments/activity is destroyed and attach listeners to downloader when activity/fragment UI is recreated.

hello,

thank you alot

it works now 👍