tanoDxyz/GDownload

FutureTask@35b614f rejected from java.util.concurrent.ThreadPoolExecutor@7a8b0dc

shahzadafridi opened this issue · 3 comments

Fatal Exception: java.lang.RuntimeException: Unable to destroy activity {com.-------/com.xyz.ui.main.MainActivity}: java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.FutureTask@35b614f rejected from java.util.concurrent.ThreadPoolExecutor@7a8b0dc[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 1]
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:5301)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:5330)
at android.app.servertransaction.DestroyActivityItem.execute(DestroyActivityItem.java:44)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:181)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:102)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2235)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:240)
at android.app.ActivityThread.main(ActivityThread.java:7829)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:512)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1027)


Caused by java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.FutureTask@35b614f rejected from java.util.concurrent.ThreadPoolExecutor@7a8b0dc[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:11)
at com.tanodxyz.gdownload.GDownload.runOnBackground(GDownload.kt:184)
at com.tanodxyz.gdownload.GDownload.onDestroy(GDownload.kt:145)
at androidx.lifecycle.FullLifecycleObserverAdapter.onStateChanged(FullLifecycleObserverAdapter.java:51)
at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:360)
at androidx.lifecycle.LifecycleRegistry.backwardPass(LifecycleRegistry.java:290)
at androidx.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.java:308)
at androidx.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.java:151)
at androidx.lifecycle.LifecycleRegistry.handleLifecycleEvent(LifecycleRegistry.java:134)
at androidx.lifecycle.ReportFragment.dispatch(ReportFragment.java:68)
at androidx.lifecycle.ReportFragment$LifecycleCallbacks.onActivityPreDestroyed(ReportFragment.java:224)
at android.app.Activity.dispatchActivityPreDestroyed(Activity.java:1436)
at android.app.Activity.performDestroy(Activity.java:8254)
at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1341)
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:5286)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:5330)
at android.app.servertransaction.DestroyActivityItem.execute(DestroyActivityItem.java:44)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:181)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:102)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2235)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:240)
at android.app.ActivityThread.main(ActivityThread.java:7829)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:512)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1027)

   **Crashlytics**
image

@tanoDxyz this is the most reported issue on this library as I am using in one of the app. I have insight in the code but as brief knowledge of your library code could not make any fix for that.

From Fragment side:

 GDownload.singleDownload(requireActivity()) {
            maxNumberOfConnections = 32 // number of connections/ threads
            url = file.url
            name = file.name
            networkType = NetworkType.valueOf(
                NetworkType.ALL
            )
            this.downloadProgressListener = downloadListener
            downloader = getDownloader()
            downloadFilesRoot = requireActivity().getOkDownloaderRoot()
        }

Thank you for reporting it.

since you have brief knowledge of the library you can gave more details or suggest something or hopefully open a PR for that.

also please confirm
that
How are you initializing the library?
and
how it occurred.( scenario)

i will debug that on my side.

please stay in a loop.😊