Fixed
Status Update
Comments
ra...@google.com <ra...@google.com>
ia...@gmail.com <ia...@gmail.com> #2
Bringing setMaxSchedulerLimit to say 49 doesn't help. Same error.
su...@google.com <su...@google.com> #3
If you are using work-firebase then you should not be using JobScheduler directly. Can you please send us the full bug report so we can investigate ?
su...@google.com <su...@google.com> #4
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.scheduleInternal(Schedulers.java:104)
at androidx.work.impl.Schedulers.schedule(Schedulers.java:73)
at androidx.work.impl.WorkerWrapper.setSucceededAndNotify(WorkerWrapper.java:393)
at androidx.work.impl.WorkerWrapper.handleResult(WorkerWrapper.java:255)
at androidx.work.impl.WorkerWrapper.run(WorkerWrapper.java:181)
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)
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.scheduleInternal(Schedulers.java:104)
at androidx.work.impl.Schedulers.schedule(Schedulers.java:73)
at androidx.work.impl.WorkerWrapper.setSucceededAndNotify(WorkerWrapper.java:393)
at androidx.work.impl.WorkerWrapper.handleResult(WorkerWrapper.java:255)
at androidx.work.impl.WorkerWrapper.run(WorkerWrapper.java:181)
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)
to...@googlemail.com <to...@googlemail.com> #5
What do you mean I shouldn't use JobScheduler directly? Isn't work-firebase is just for <21 devices, otherwise JobScheduler always used?
su...@google.com <su...@google.com> #6
I think i was confused by your previous comment. You are right, we only use work-firebase for API < 23.
JobScheduler is used for API >= 23.
This issue should have been resolved in `alpha03` and `alpha04` (we addressed different parts of the problem). If you can reproduce this on a device, then can you do:
1. adb shell dumpsys jobscheduler for your app.
2. Reboot your device.
3. After the reboot, can you re-run adb shell dumpsys jobscheduler ?
I want to check if you see any differences in the jobs created before and after the reboot.
Thanks for your patience.
JobScheduler is used for API >= 23.
This issue should have been resolved in `alpha03` and `alpha04` (we addressed different parts of the problem). If you can reproduce this on a device, then can you do:
1. adb shell dumpsys jobscheduler for your app.
2. Reboot your device.
3. After the reboot, can you re-run adb shell dumpsys jobscheduler ?
I want to check if you see any differences in the jobs created before and after the reboot.
Thanks for your patience.
to...@googlemail.com <to...@googlemail.com> #7
Actually for step 2, the easier thing to do is to force stop your app. You don't need to fo a full reboot.
su...@google.com <su...@google.com> #8
I don't have to to rummage through traces. Here's code snippet that sends app into a crash loop. https://pastebin.com/NcTAnwjZ
su...@google.com <su...@google.com> #9
I tried to reproduce this on alpha04. However, I cannot reproduce your issue.
For reference, this is what my activity looks like:
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
findViewById<Button>(R.id.scheduler_limits_testcase1).setOnClickListener {
for (i in 1..100) {
val a1 = newWorkRequest("--- A1 ---")
val b1 = newWorkRequest("--- B1 ---")
val b2 = newWorkRequest("--- B2 ---")
val c1 = newWorkRequest("--- C1 ---")
WorkManager.getInstance()!!
.beginWith(a1).then(b1).enqueue()
WorkManager.getInstance()!!
.beginWith(a1).then(b2).enqueue()
WorkManager.getInstance()!!
.beginWith(b1, b2).then(c1).enqueue()
}
}
}
companion object {
private fun newWorkRequest(message: String): OneTimeWorkRequest {
val data = mapOf(TestWorker.KEY_MESSAGE to message).toWorkData()
return OneTimeWorkRequestBuilder<TestWorker>()
.setInputData(data)
.build()
}
}
}
This is what my Worker looks like:
class TestWorker : Worker() {
companion object {
private const val TAG = "TestWorker"
private const val MESSAGE_DEFAULT = "Default"
const val KEY_MESSAGE = "KEY_MESSAGE"
}
override fun doWork(): Result {
val message = inputData.getString(KEY_MESSAGE, MESSAGE_DEFAULT)
val random = Random()
val time = 500L + random.nextInt(300)
Log.d(TAG, "Before. $message")
Thread.sleep(time)
Log.d(TAG, "After. $message")
return Result.SUCCESS
}
}
For reference, this is what my activity looks like:
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
findViewById<Button>(R.id.scheduler_limits_testcase1).setOnClickListener {
for (i in 1..100) {
val a1 = newWorkRequest("--- A1 ---")
val b1 = newWorkRequest("--- B1 ---")
val b2 = newWorkRequest("--- B2 ---")
val c1 = newWorkRequest("--- C1 ---")
WorkManager.getInstance()!!
.beginWith(a1).then(b1).enqueue()
WorkManager.getInstance()!!
.beginWith(a1).then(b2).enqueue()
WorkManager.getInstance()!!
.beginWith(b1, b2).then(c1).enqueue()
}
}
}
companion object {
private fun newWorkRequest(message: String): OneTimeWorkRequest {
val data = mapOf(TestWorker.KEY_MESSAGE to message).toWorkData()
return OneTimeWorkRequestBuilder<TestWorker>()
.setInputData(data)
.build()
}
}
}
This is what my Worker looks like:
class TestWorker : Worker() {
companion object {
private const val TAG = "TestWorker"
private const val MESSAGE_DEFAULT = "Default"
const val KEY_MESSAGE = "KEY_MESSAGE"
}
override fun doWork(): Result {
val message = inputData.getString(KEY_MESSAGE, MESSAGE_DEFAULT)
val random = Random()
val time = 500L + random.nextInt(300)
Log.d(TAG, "Before. $message")
Thread.sleep(time)
Log.d(TAG, "After. $message")
return Result.SUCCESS
}
}
to...@googlemail.com <to...@googlemail.com> #10
Do you have another part of your codebase that is scheduling jobs with JobScheduler?
su...@google.com <su...@google.com> #11
We have 1 job that schedules once on app start, that's it.
to...@googlemail.com <to...@googlemail.com> #12
I created a sample app.
For some reason it rarely crashes on AVD Emulator(Api 27), but 100% crashes on Genymotion Api 26 and my Xiaomi Redmi 7.1.2
You can try both Activities.
For some reason it rarely crashes on AVD Emulator(Api 27), but 100% crashes on Genymotion Api 26 and my Xiaomi Redmi 7.1.2
You can try both Activities.
to...@googlemail.com <to...@googlemail.com> #13
Hi, I've tried numerous times and have been unable to get your example to exhibit this problem. Could you please update to alpha05 and reproduce it? If you can reliably reproduce this issue, could you please do so with verbose logging enabled in your Configuration object (introduced in alpha05) and send us a bugreport?
ap...@google.com <ap...@google.com> #14
I will some time later when I have time
su...@google.com <su...@google.com> #15
Alpha 05, VERBOSE log level. Running the MainActivity in previous app.
to...@googlemail.com <to...@googlemail.com> #16
Hmm, there is a possibility based on your stacktrace that you are running into b/111801342 ; something about these particular devices/emulators is leading to the issue manifesting like this. This is fixed in alpha06 (which will be released later today). Please update later today to check.
su...@google.com <su...@google.com> #17
alpha 06, same thing
to...@googlemail.com <to...@googlemail.com> #18
↑ This is Genymotion not Xiaomi log
su...@google.com <su...@google.com> #19
I tried to reproduce this on a Genymotion emulator as well (on alpha04 and alpha06) on API 26. I cannot seem to.
I am marking this as not reproducible.
I am marking this as not reproducible.
to...@googlemail.com <to...@googlemail.com> #20
You tried to reproduce it on my example above?
su...@google.com <su...@google.com> #21
How can you not reproduce it when I linked you the code to do so?
to...@googlemail.com <to...@googlemail.com> #22
Same issue for me, "java.lang.IllegalStateException: Apps may not schedule more than 100 distinct jobs", on Android 8.0.0 (HTC U11).
Just for my understanding, should we be able to enqueue more than ~100 WorkRequest ?
Just for my understanding, should we be able to enqueue more than ~100 WorkRequest ?
su...@google.com <su...@google.com> #23
Yes, you should. We found some edge cases where it's possible to schedule more work than allowable by the system and we're working on a fix. Thanks!
ra...@google.com <ra...@google.com> #25
A fix should be available in alpha07.
to...@googlemail.com <to...@googlemail.com> #26
I still got the 100 job crash once using alpha-07
ri...@googlemail.com <ri...@googlemail.com> #27
Still getting this crash with alpha08 from users (LGE Android 7 and Samsung Android 8):
Fatal Exception: java.lang.IllegalStateException: Apps may not schedule more than 100 distinct jobs
at android.os.Parcel.readException(Parcel.java:1691)
at android.os.Parcel.readException(Parcel.java:1636)
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(DT:126)
at androidx.work.impl.background.systemjob.SystemJobScheduler.schedule(DT:95)
at androidx.work.impl.Schedulers.schedule(DT:99)
at androidx.work.impl.WorkerWrapper$1.run(DT:263)
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)
Fatal Exception: java.lang.IllegalStateException: Apps may not schedule more than 100 distinct jobs
at android.os.Parcel.readException(Parcel.java:1691)
at android.os.Parcel.readException(Parcel.java:1636)
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(DT:126)
at androidx.work.impl.background.systemjob.SystemJobScheduler.schedule(DT:95)
at androidx.work.impl.Schedulers.schedule(DT:99)
at androidx.work.impl.WorkerWrapper$1.run(DT:263)
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)
ri...@googlemail.com <ri...@googlemail.com> #28
#27, do you mind providing some more info about this? How are you enqueuing your jobs? Do you have a customized WorkManager Configuration (if so, what is it?)? Did you have previously scheduled jobs using alpha07 or earlier or did you enqueue these jobs in alpha08?
Finally, if you can turn on verbose logging through the Configuration options, please send us the logcat using that.
Finally, if you can turn on verbose logging through the Configuration options, please send us the logcat using that.
ra...@google.com <ra...@google.com> #29
I am en-queuing a OneTimeWorkRequest and listening to it's status change. On status change, I enqueue the same work request (with same tag and other constraints). For some time it runs fine, and then it suddenly crashes complaining of the 100 job crash and also of "WorkerWrapper: Didn't find WorkSpec for id"
Here's the crash log
08-31 17:31:19.892 9930-9985/com.example.agupta15.tryouts E/AndroidRuntime: FATAL EXCEPTION: pool-2-thread-1
Process: com.example.agupta15.tryouts, PID: 9930
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)
08-31 17:31:19.893 9930-9930/com.example.agupta15.tryouts D/status worker: id f5c workstatus state = ENQUEUED
08-31 17:31:19.893 9930-9930/com.example.agupta15.tryouts D/WorkManagerUtils: Schedule for Worker Class: Class Job Id: 100100
08-31 17:31:20.016 9930-9993/com.example.agupta15.tryouts E/WorkerWrapper: Didn't find WorkSpec for id 7f9fdb71-1c34-41e0-b012-97be46ecba85
08-31 17:31:20.020 9930-10011/com.example.agupta15.tryouts E/WorkerWrapper: Didn't find WorkSpec for id 6fdcb2ea-1f3c-4238-b175-15c4c4d80ec6
Please ignore the D/ logs (they are my own for debugging)
Here's the crash log
08-31 17:31:19.892 9930-9985/com.example.agupta15.tryouts E/AndroidRuntime: FATAL EXCEPTION: pool-2-thread-1
Process: com.example.agupta15.tryouts, PID: 9930
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)
08-31 17:31:19.893 9930-9930/com.example.agupta15.tryouts D/status worker: id f5c workstatus state = ENQUEUED
08-31 17:31:19.893 9930-9930/com.example.agupta15.tryouts D/WorkManagerUtils: Schedule for Worker Class: Class Job Id: 100100
08-31 17:31:20.016 9930-9993/com.example.agupta15.tryouts E/WorkerWrapper: Didn't find WorkSpec for id 7f9fdb71-1c34-41e0-b012-97be46ecba85
08-31 17:31:20.020 9930-10011/com.example.agupta15.tryouts E/WorkerWrapper: Didn't find WorkSpec for id 6fdcb2ea-1f3c-4238-b175-15c4c4d80ec6
Please ignore the D/ logs (they are my own for debugging)
Description
Version used: 1.0.0-alpha09
When using ProGuard, the Worker(Context context, WorkerParameters) constructor isn't kept, leading to Workers being unable to be created:
DefaultWorkerFactory: Could not instantiate com.google.android.apps.muzei.sync.ProviderChangedWorker
DefaultWorkerFactory: java.lang.NoSuchMethodException: <init> []
DefaultWorkerFactory: at java.lang.Class.getConstructor0(Class.java:2327)
DefaultWorkerFactory: at java.lang.Class.getDeclaredConstructor(Class.java:2166)
DefaultWorkerFactory: at androidx.work.DefaultWorkerFactory.createWorker(DefaultWorkerFactory.java:58)
DefaultWorkerFactory: at androidx.work.impl.WorkerWrapper.runWorker(WorkerWrapper.java:180)
DefaultWorkerFactory: at androidx.work.impl.WorkerWrapper.run(WorkerWrapper.java:117)
DefaultWorkerFactory: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
DefaultWorkerFactory: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
DefaultWorkerFactory: at java.lang.Thread.run(Thread.java:764)
WorkerWrapper: Could for create Worker com.google.android.apps.muzei.sync.ProviderChangedWorker
I had to manually add the ProGuard rule:
-keepclassmembers class * extends androidx.work.Worker {
public <init>(android.content.Context,androidx.work.WorkerParameters);
}