ModernAsyncTask IllegalStateException

We use AsyncTaskLoaders in our application to download content. We get this glitch

java.lang.IllegalStateException: Cannot execute task: the task is already running.
   at android.support.v4.content.ModernAsyncTask.doInBackground(ModernAsyncTask.java:414)
   at android.support.v4.content.AsyncTaskLoader.executePendingTask(AsyncTaskLoader.java:219)
   at android.support.v4.content.AsyncTaskLoader.dispatchOnCancelled(AsyncTaskLoader.java:232)
   at android.support.v4.content.AsyncTaskLoader$LoadTask.onCancelled(AsyncTaskLoader.java:88)
   at android.support.v4.content.ModernAsyncTask.finish(ModernAsyncTask.java:464)
   at android.support.v4.content.ModernAsyncTask.access$400(ModernAsyncTask.java:48)
   at android.support.v4.content.ModernAsyncTask$InternalHandler.handleMessage(ModernAsyncTask.java:483)
   at android.os.Handler.dispatchMessage(Handler.java:102)
   at android.os.Looper.loop(Looper.java:211)
   at android.app.ActivityThread.main(ActivityThread.java:5335)
   at java.lang.reflect.Method.invoke(Method.java)
   at java.lang.reflect.Method.invoke(Method.java:372)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1016)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:811)

We tried to reproduce it, but were not successful!

Is there any way to find out which bootloader is causing this?

We are using com.android.support:support-v4:23.0.1

We are exploring the possibility that this may have a link to Activity Leaks, besides this, this is all the information we receive.

Any ideas?

+4
source share
2 answers

I am still hunting for this error, because I cannot reproduce it myself, but I believe that I have found the reason (at least for my case, but I need to release it and see if it helps).

, , , , Handler ( , , ). , onChange , .. onChange, , onContentChanged, , ... , cancelationTask (- ), , .

, , cancelationTask , , (takeContentChanged ).

, , , () (onStartLoading ).

+2

, - async-. onClick. View, .

, , Leak Canary. .

StrictMode .

 public void onCreate() {
 if (DEVELOPER_MODE) {
     StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
             .detectDiskReads()
             .detectDiskWrites()
             .detectNetwork()   // or .detectAll() for all detectable problems
             .penaltyLog()
             .build());
     StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
             .detectLeakedSqlLiteObjects()
             .detectLeakedClosableObjects()
             .penaltyLog()
             .penaltyDeath()
             .build());
 }
 super.onCreate();

}

0

Source: https://habr.com/ru/post/1611591/


All Articles