'WorkManager loses data for Satisfied CONTENT_TRIGGER on "cancelled while waiting for bind" event
I observe changes in resources like images for example. From time to time events for changes are lost.
I check the JS dump with the following command:
adb shell dumpsys jobscheduler
I can see the following:
-4s021ms START: #u0a443/93 com.myapp.test.debug/androidx.work.impl.background.systemjob.SystemJobService
-3s468ms STOP-P: #u0a443/93 com.myapp.test.debug/androidx.work.impl.background.systemjob.SystemJobService cancelled while waiting for bind
The cancelled while waiting for bind is the problem.
At this period:
- I do not cancel the work.
- I do not reschedule it.
- Work is not executed.
So all would be considered normal for me if the work is just stopped and then it could proceed later in the right state(knowing that images were made). But what I observe is as follows:
- There is currently scheduled work with id 93(same as the cancelled one)
- In the Recently completed jobs section I see that the last work was with Satisfied CONTENT_TRIGGER. That is why it was executed. I see that Changed URIs has detected changes.
Why the currently scheduled job with id 93 has: CONTENT_TRIGGER as NOT Satisfied
Recently completed jobs:
-3s344ms
u0a443 tag=*job*/com.myapp.test.debug/androidx.work.impl.background.systemjob.SystemJobService
Source: uid=u0a443 user=0 pkg=com.myapp.test.debug
JobInfo:
Service: com.myapp.test.debug/androidx.work.impl.background.systemjob.SystemJobService
Flags: 2
Requires: charging=false batteryNotLow=true deviceIdle=false
Trigger content URIs:
1 content://media/internal/images/media
1 content://media/external/images/media
Trigger update delay: +30s0ms
Trigger max delay: +5m0s0ms
Extras: mParcelledData.dataSize=180
Network type: NetworkRequest [ NONE id=0, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&VALIDATED&NOT_VCN_MANAGED Uid: 10443] ]
Backoff: policy=1 initial=+30s0ms
Required constraints: BATTERY_NOT_LOW CONNECTIVITY CONTENT_TRIGGER [0x14000002]
Dynamic constraints:
Satisfied constraints: CHARGING BATTERY_NOT_LOW CONNECTIVITY CONTENT_TRIGGER DEVICE_NOT_DOZING BACKGROUND_NOT_RESTRICTED WITHIN_QUOTA [0x17400003]
Unsatisfied constraints:
Constraint history:
-2m15s270ms = CONNECTIVITY [0x10000000]
-2m15s270ms = CHARGING CONNECTIVITY [0x10000001]
-2m15s270ms = CHARGING BATTERY_NOT_LOW CONNECTIVITY [0x10000003]
-2m15s270ms = CHARGING BATTERY_NOT_LOW CONNECTIVITY BACKGROUND_NOT_RESTRICTED [0x10400003]
-2m15s270ms = CHARGING BATTERY_NOT_LOW CONNECTIVITY DEVICE_NOT_DOZING BACKGROUND_NOT_RESTRICTED [0x12400003]
-2m15s270ms = CHARGING BATTERY_NOT_LOW CONNECTIVITY DEVICE_NOT_DOZING BACKGROUND_NOT_RESTRICTED WITHIN_QUOTA [0x13400003]
-3s907ms = CHARGING BATTERY_NOT_LOW CONNECTIVITY CONTENT_TRIGGER DEVICE_NOT_DOZING BACKGROUND_NOT_RESTRICTED WITHIN_QUOTA [0x17400003]
Doze whitelisted: true
Implicit constraints:
readyNotDozing: true
readyNotRestrictedInBg: true
readyComponentEnabled: true
Changed authorities:
media
Changed URIs:
content://media/external/images/media/2209
content://media/external/images/media/2210
content://media/external/images/media/2211
Network: 100
Standby bucket: ACTIVE
Enqueue time: -2m15s270ms
Run time: earliest=none, latest=none, original latest=none
Current job:
JOB #u0a443/93: c7599bd com.myapp.test.debug/androidx.work.impl.background.systemjob.SystemJobService
u0a443 tag=*job*/com.myapp.test.debug/androidx.work.impl.background.systemjob.SystemJobService
Source: uid=u0a443 user=0 pkg=com.myapp.test.debug
JobInfo:
Service: com.myapp.test.debug/androidx.work.impl.background.systemjob.SystemJobService
Flags: 2
Requires: charging=false batteryNotLow=true deviceIdle=false
Trigger content URIs:
1 content://media/internal/images/media
1 content://media/external/images/media
Trigger update delay: +30s0ms
Trigger max delay: +5m0s0ms
Extras: mParcelledData.dataSize=180
Network type: NetworkRequest [ NONE id=0, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&VALIDATED&NOT_VCN_MANAGED Uid: 10443] ]
Backoff: policy=1 initial=+30s0ms
Required constraints: BATTERY_NOT_LOW CONNECTIVITY CONTENT_TRIGGER [0x14000002]
Dynamic constraints:
Satisfied constraints: CHARGING BATTERY_NOT_LOW CONNECTIVITY DEVICE_NOT_DOZING BACKGROUND_NOT_RESTRICTED WITHIN_QUOTA [0x13400003]
Unsatisfied constraints: CONTENT_TRIGGER [0x4000000]
Constraint history:
-3s482ms = CONNECTIVITY [0x10000000]
-3s482ms = CHARGING CONNECTIVITY [0x10000001]
-3s482ms = CHARGING BATTERY_NOT_LOW CONNECTIVITY [0x10000003]
-3s482ms = CHARGING BATTERY_NOT_LOW CONNECTIVITY BACKGROUND_NOT_RESTRICTED [0x10400003]
-3s481ms = CHARGING BATTERY_NOT_LOW CONNECTIVITY DEVICE_NOT_DOZING BACKGROUND_NOT_RESTRICTED [0x12400003]
-3s481ms = CHARGING BATTERY_NOT_LOW CONNECTIVITY DEVICE_NOT_DOZING BACKGROUND_NOT_RESTRICTED WITHIN_QUOTA [0x13400003]
Doze whitelisted: true
Tracking: BATTERY CONNECTIVITY CONTENT QUOTA
Implicit constraints:
readyNotDozing: true
readyNotRestrictedInBg: true
readyComponentEnabled: true
Network: 100
Standby bucket: ACTIVE
Enqueue time: -3s482ms
Run time: earliest=none, latest=none, original latest=none
Restricted due to: none.
Ready: false (job=false user=true !restricted=true !pending=true !active=true !backingup=true comp=true)
At the moment it is observed only on Android 12, but at the same time I see that the code related to "cancelled while waiting for bind" from the Google Source Code is written in 2017. So it doesn't look like something new.
Also for me is a bit annoying that I can't update constraints for a work. In JS API this was possible. So if I have a work with Satisfied constrain(for example, the trigger) and I want an update of the Constraints - I can't know about the trigger Constraint to be satisfied. I can't update the work. I can only throw it away and lose the state. I don't know what is the reason behind this, but it looks like a similar case.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
