Fixed
Status Update
Comments
ra...@google.com <ra...@google.com>
ra...@google.com <ra...@google.com> #2
Thanks for your patience with this bug. At this point you are just racing against JobScheduler itself. JobScheduler's book keeping. Unbinding a Job is asynchronous. So you if are creating jobs and completing jobs faster than JobScheduler can do book-keeping you are going to run against this limit.
JobScheduler's behavior is more deterministic on newer versions of the platform (O and above). So its harder to get close to this limit on these versions of the OS.
For your use-case, I suggest using a lower limit on the number of jobs you want WorkManager to schedule on your behalf. Use Configuration#setMaxSchedulerLimit() and use a limit << 100. I tried to reproduce your test case with a limit of 50, and we no longer exceed the scheduling limits.
In alpha08 we will clamp down the max limit to something more reasonable than 100 so developers don't race against the underlying scheduler.
JobScheduler's behavior is more deterministic on newer versions of the platform (O and above). So its harder to get close to this limit on these versions of the OS.
For your use-case, I suggest using a lower limit on the number of jobs you want WorkManager to schedule on your behalf. Use Configuration#setMaxSchedulerLimit() and use a limit << 100. I tried to reproduce your test case with a limit of 50, and we no longer exceed the scheduling limits.
In alpha08 we will clamp down the max limit to something more reasonable than 100 so developers don't race against the underlying scheduler.
d....@infotech.team <d....@infotech.team> #3
Okay, we will try setMaxSchedulerLimit 50. Thanks for your operative work.
Description
Version used:1.0.0-alpha07
Devices/Android versions reproduced on:
java.lang.IllegalStateException: Apps may not schedule more than 100 distinct jobs
at android.os.Parcel.readException(Parcel.java:1692)
at android.os.Parcel.readException(Parcel.java:1637)
at android.app.job.IJobScheduler$Stub$Proxy.schedule(IJobScheduler.java:158)
at android.app.JobSchedulerImpl.schedule(JobSchedulerImpl.java:42)
at androidx.work.impl.background.systemjob.SystemJobScheduler.scheduleInternal(SystemJobScheduler.java:126)
at androidx.work.impl.background.systemjob.SystemJobScheduler.schedule(SystemJobScheduler.java:95)
at androidx.work.impl.Schedulers.schedule(Schedulers.java:99)
at androidx.work.impl.utils.EnqueueRunnable.scheduleWorkInBackground(EnqueueRunnable.java:114)
at androidx.work.impl.utils.EnqueueRunnable.run(EnqueueRunnable.java:86)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
I already reported this bug multiple times but it is still not fixed. I attached sample project from my prevoious report. In our production app there is only one schedule operation(it calulculates worker tree once and schedules them all on the same thread frame) that you see in the sample app, but it still crashes.
I attached a sample project.
Run the app and press the button multiple times in a quick succession.