I'm using the new library WorkManager for periodic work and one-time work request. Currently used version of the lib is 1.0.0, while min SDK is 21 and compile is 28.
Work manager does the job as described in the documentation but causes a lot of ANRs seen in the Play Store console.
I'm using code for triggering works like :
WorkManager.getInstance().enqueueUniquePeriodicWork(
tag,
ExistingPeriodicWorkPolicy.KEEP,
workRequest
)
and WorkManager.getInstance().enqueue(workRequest)
The most common ANR is coming from the broadcast receiver with package androidx.work.impl.background.systemalarm.RescheduleReceiver
and this is a problem mainly on OnePlus phones. I found a somehow connected issue in the Work manager issue tracker but this states that the bug is fixed in the previous version this issue. Still, following the steps mentioned in the tracker, I see logs showing that this problem continues in version 1.0.0. The ANRs that I'm seeing cannot be reproduced on the test devices that I have.