optimizely/android-sdk

`Parcel.createExceptionOrNull` due to too many scheduled jobs

davidalbers opened this issue · 5 comments

I see this exception in Crashlytics:

Fatal Exception: java.lang.IllegalStateException: JobScheduler 100 job limit exceeded.  We count 9 WorkManager jobs in JobScheduler; we have 10 tracked jobs in our DB; our Configuration limit is 20.
       at androidx.work.impl.background.systemjob.SystemJobScheduler.scheduleInternal(SystemJobScheduler.java:218)
       at androidx.work.impl.background.systemjob.SystemJobScheduler.schedule(SystemJobScheduler.java:133)
       at androidx.work.impl.Schedulers.schedule(Schedulers.java:108)
       at androidx.work.impl.utils.ForceStopRunnable.forceStopRunnable(ForceStopRunnable.java:226)
       at androidx.work.impl.utils.ForceStopRunnable.run(ForceStopRunnable.java:110)
       at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:91)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
       at java.lang.Thread.run(Thread.java:923)
--
Caused by java.lang.IllegalStateException: Maximum limit of concurrent alarms 500 reached for uid: 1000, callingPackage: android
       at android.os.Parcel.createExceptionOrNull(Parcel.java:2381)
       at android.os.Parcel.createException(Parcel.java:2357)
       at android.os.Parcel.readException(Parcel.java:2340)
       at android.os.Parcel.readException(Parcel.java:2282)
       at android.app.job.IJobScheduler$Stub$Proxy.schedule(IJobScheduler.java:308)
       at android.app.JobSchedulerImpl.schedule(JobSchedulerImpl.java:47)
       at androidx.work.impl.background.systemjob.SystemJobScheduler.scheduleInternal(SystemJobScheduler.java:187)
       at androidx.work.impl.background.systemjob.SystemJobScheduler.schedule(SystemJobScheduler.java:133)
       at androidx.work.impl.Schedulers.schedule(Schedulers.java:108)
       at androidx.work.impl.utils.ForceStopRunnable.forceStopRunnable(ForceStopRunnable.java:226)
       at androidx.work.impl.utils.ForceStopRunnable.run(ForceStopRunnable.java:110)
       at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:91)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
       at java.lang.Thread.run(Thread.java:923)

The traces don't show any code from my app or the Optimizely SDK. However, when I run ./gradlew android:dependencies Optimizely is the only dependency with androidx.work as a dependency.

Since I found this issue on Crashlytics I don't have steps to reproduce. However, I do see that 100% of the crashes are from Android 11 and 51% are from a phone brand called "FIH".

I see an issue in the Google issue tracker but I'm not sure what my app might be calling in Optimizely to schedule too many jobs.

Is this a bug with Optimizely or possibly the way I'm using Optimizely?

@davidalbers Thanks for sharing. We'll take a look.

@davidalbers what is the SDK version you're currently using? The google issue you shared indicates that the android bug is supposed to be fixed in WorkManager 2.3.2, and the updated version of our SDK uses WorkManager 2.7.1.

I'm using the latest Optimizely SDK, version 3.13.2

@davidalbers that version with WorkManager 2.7.1 is supposed to fix the android bug. Other developers still see the same issue with the upgrade and it looks like google needs to fix it. We'll follow up the issue and get you updated.

FSSDK-8561