Status Update
Comments
kl...@google.com <kl...@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
kl...@google.com <kl...@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.
kl...@google.com <kl...@google.com> #5
kl...@google.com <kl...@google.com>
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?
ke...@gmail.com <ke...@gmail.com> #7
Coming from stackoverflow here.
The build you mentioned doesn't seem to exist, and when I use the latest build (
I get some very weird missing library errors.
ke...@gmail.com <ke...@gmail.com> #8
My apologies for the delay. Try using this. This is from our dev branch.
repositories {
google()
maven { url 'https://ci.android.com/builds/submitted/6215972/androidx_snapshot/latest/repository/' }
}
dependencies {
implementation "androidx.work:work-runtime:2.4.0-SNAPSHOT"
}
ja...@deepl.com <ja...@deepl.com> #9
ap...@google.com <ap...@google.com> #10
My apologies, it looks like the artifacts were not generated for that build. I have verified that this one works:
repositories {
google()
maven { url '
dependencies { implementation "androidx.work:work-runtime:2.4.0-SNAPSHOT" }
ap...@google.com <ap...@google.com> #11
My apologies, it looks like the artifacts were not generated for that build. I have verified that this one works:
repositories {
google()
maven { url 'https://ci.android.com/builds/submitted/6217200/androidx_snapshot/latest/repository/' }
}
dependencies {
implementation "androidx.work:work-runtime:2.4.0-SNAPSHOT"
}
ap...@google.com <ap...@google.com> #12
na...@google.com <na...@google.com> #13
Logs:
androidx.work.impl.background.systemjob.SystemJobScheduler.scheduleInternal + 199 (SystemJobScheduler.java:199)
androidx.work.impl.background.systemjob.SystemJobScheduler.schedule + 127 (SystemJobScheduler.java:127)
androidx.work.impl.Schedulers.schedule + 92 (Schedulers.java:92)
androidx.work.impl.utils.ForceStopRunnable.run + 98 (ForceStopRunnable.java:98)
androidx.work.impl.utils.SerialExecutor$Task.run + 91 (SerialExecutor.java:91)
java.util.concurrent.ThreadPoolExecutor.runWorker + 1133 (ThreadPoolExecutor.java:1133)
java.util.concurrent.ThreadPoolExecutor$Worker.run + 607 (ThreadPoolExecutor.java:607)
java.lang.Thread.run + 761 (Thread.java:761)
Caused by java.lang.IllegalStateException
Apps may not schedule more than 100 distinct jobs
android.os.Parcel.readException + 1691 (Parcel.java:1691)
android.os.Parcel.readException + 1636 (Parcel.java:1636)
android.app.job.IJobScheduler$Stub$Proxy.schedule + 158 (IJobScheduler.java:158)
android.app.JobSchedulerImpl.schedule + 42 (JobSchedulerImpl.java:42)
androidx.work.impl.background.systemjob.SystemJobScheduler.scheduleInternal + 181 (SystemJobScheduler.java:181)
androidx.work.impl.background.systemjob.SystemJobScheduler.schedule + 127 (SystemJobScheduler.java:127)
androidx.work.impl.Schedulers.schedule + 92 (Schedulers.java:92)
androidx.work.impl.utils.ForceStopRunnable.run + 98 (ForceStopRunnable.java:98)
androidx.work.impl.utils.SerialExecutor$Task.run + 91 (SerialExecutor.java:91)
java.util.concurrent.ThreadPoolExecutor.runWorker + 1133 (ThreadPoolExecutor.java:1133)
java.util.concurrent.ThreadPoolExecutor$Worker.run + 607 (ThreadPoolExecutor.java:607)
java.lang.Thread.run + 761 (Thread.java:761)
As you can see this log line :-
androidx.work.impl.utils.ForceStopRunnable.run + 98 (ForceStopRunnable.java:98)
This is happening during force stop or application got killed
Will this fix cover this scenario as well??
ca...@cba.com.au <ca...@cba.com.au> #14
ca...@gmail.com <ca...@gmail.com> #15
Fatal Exception: java.lang.IllegalStateException: JobScheduler 100 job limit exceeded. We count 3 WorkManager jobs in JobScheduler; we have 7 tracked jobs in our DB; our Configuration limit is 20.
at androidx.work.impl.background.systemjob.SystemJobScheduler.scheduleInternal(SystemJobScheduler.java:199)
at androidx.work.impl.background.systemjob.SystemJobScheduler.schedule(SystemJobScheduler.java:127)
at androidx.work.impl.Schedulers.schedule(Schedulers.java:92)
at androidx.work.impl.WorkManagerImpl.rescheduleEligibleWork(WorkManagerImpl.java:631)
at androidx.work.impl.utils.ForceStopRunnable.run(ForceStopRunnable.java:90)
at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:91)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
Caused by java.lang.IllegalStateException: Apps may not schedule more than 100 distinct jobs
at android.os.Parcel.readException(Parcel.java:2024)
at android.os.Parcel.readException(Parcel.java:1962)
at android.app.job.IJobScheduler$Stub$Proxy.schedule(IJobScheduler.java:180)
at android.app.JobSchedulerImpl.schedule(JobSchedulerImpl.java:44)
at androidx.work.impl.background.systemjob.SystemJobScheduler.scheduleInternal(SystemJobScheduler.java:181)
at androidx.work.impl.background.systemjob.SystemJobScheduler.schedule(SystemJobScheduler.java:127)
at androidx.work.impl.Schedulers.schedule(Schedulers.java:92)
at androidx.work.impl.WorkManagerImpl.rescheduleEligibleWork(WorkManagerImpl.java:631)
at androidx.work.impl.utils.ForceStopRunnable.run(ForceStopRunnable.java:90)
at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:91)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
I'm on WorkManager 2.3.4
Can you please provide a resolution for this?
Description
Reported in https://b.corp.google.com/issues/192043120#comment81 .