Status Update
Comments
ma...@google.com <ma...@google.com> #2
cl...@google.com <cl...@google.com> #3
Artifact used androidx.work:work-runtime:2.3.1
Version used:2.3.1
Theme used:
Devices/Android versions reproduced on:
Pixel devices,One Plus devices / 10.0
Samsung, Realme, Oppo/ 9.0
Motorola / 8.0
- Relevant code to trigger the issue.
WorkManager workManagerInstance = WorkManager.getInstance(context);
Data input = new Data.Builder().putString("xxx", xxx).build();
Constraints constraints = new Constraints.Builder()
.setRequiredNetworkType(NetworkType.CONNECTED).build();
mGetShowRequest = new OneTimeWorkRequest.Builder(ShowParserWork.class)
.setConstraints(constraints).setInputData(input)
.addTag(TAG_WORKER_NAME)
.setBackoffCriteria(BackoffPolicy.EXPONENTIAL, 30, TimeUnit.SECONDS).build();
workManagerInstance.enqueueUniqueWork(TAG_WORKER_NAME,
ExistingWorkPolicy.KEEP,mGetShowRequest);
Stacktrace:-
Fatal Exception: java.lang.IllegalStateException: JobScheduler 100 job limit exceeded. We count 101 WorkManager jobs in JobScheduler; we have 20 tracked jobs in our DB; our Configuration limit is 20.
at androidx.work.impl.background.systemjob.SystemJobScheduler.scheduleInternal + 199(SystemJobScheduler.java:199)
at androidx.work.impl.background.systemjob.SystemJobScheduler.schedule + 127(SystemJobScheduler.java:127)
at androidx.work.impl.Schedulers.schedule + 92(Schedulers.java:92)
at androidx.work.impl.WorkerWrapper.onWorkFinished + 369(WorkerWrapper.java:369)
at androidx.work.impl.WorkerWrapper$2.run + 318(WorkerWrapper.java:318)
at androidx.work.impl.utils.SerialExecutor$Task.run + 91(SerialExecutor.java:91)
at java.util.concurrent.ThreadPoolExecutor.runWorker + 1167(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run + 641(ThreadPoolExecutor.java:641)
at java.lang.Thread.run + 919(Thread.java:919)
Caused by java.lang.IllegalStateException: Apps may not schedule more than 100 distinct jobs
at android.os.Parcel.createException + 2079(Parcel.java:2079)
at android.os.Parcel.readException + 2039(Parcel.java:2039)
at android.os.Parcel.readException + 1987(Parcel.java:1987)
at android.app.job.IJobScheduler$Stub$Proxy.schedule + 308(IJobScheduler.java:308)
at android.app.JobSchedulerImpl.schedule + 43(JobSchedulerImpl.java:43)
at androidx.work.impl.background.systemjob.SystemJobScheduler.scheduleInternal + 181(SystemJobScheduler.java:181)
at androidx.work.impl.background.systemjob.SystemJobScheduler.schedule + 127(SystemJobScheduler.java:127)
at androidx.work.impl.Schedulers.schedule + 92(Schedulers.java:92)
at androidx.work.impl.WorkerWrapper.onWorkFinished + 369(WorkerWrapper.java:369)
at androidx.work.impl.WorkerWrapper$2.run + 318(WorkerWrapper.java:318)
at androidx.work.impl.utils.SerialExecutor$Task.run + 91(SerialExecutor.java:91)
at java.util.concurrent.ThreadPoolExecutor.runWorker + 1167(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run + 641(ThreadPoolExecutor.java:641)
Caused by android.os.RemoteException: Remote stack trace:
at com.android.server.job.JobSchedulerService.scheduleAsPackage(JobSchedulerService.java:1038)
at com.android.server.job.JobSchedulerService$JobSchedulerStub.schedule(JobSchedulerService.java:2740)
at android.app.job.IJobScheduler$Stub.onTransact(IJobScheduler.java:153)
at android.os.Binder.execTransactInternal(Binder.java:1021)
at android.os.Binder.execTransact(Binder.java:994)
This issue has resurfaced only on our production builds, with multiple instances of crashes. Can you let us know a fix for this issue? Thanks
ma...@google.com <ma...@google.com> #4
We fixed a bug recently, where there is a mismatch between WorkManager
s tracking of jobs in JobScheduler
and the actual state of the jobs
. This happens in very rare cases, and I think that's what is going on in your case.
This change (WorkManager
2.3.2 very soon.
If you cannot wait, you can use a snapshot build that should be identical to the eventual release.
Here is the gradle snippet you will need:
repositories {
google()
maven { url 'https://ci.android.com/builds/submitted/6195753/androidx_snapshot/latest/repository/' }
}
dependencies {
implementation "androidx.work:work-runtime:2.4.0-SNAPSHOT"
}
One other thing you might need to do is to get rid of stale jobs. It is as simple as calling JobScheduler.cancelAllJobs()
before WorkManager is initialized. You can do it inside Application.onCreate()
in your Application subclass.
sh...@google.com <sh...@google.com>
ap...@google.com <ap...@google.com> #5
ap...@google.com <ap...@google.com> #6
Failed to resolve: androidx.work:work-runtime:2.4.0-SNAPSHOT
<a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>
Affected Modules: <a href="openFile:D:/ Android App/app/build.gradle">app</a>
In my Application class, we have added WorkManager.getInstance(this).cancelAllWork();.Also, should I use the same work manager instance from my application class for all my work requests?
Description