Fixed
Status Update
Comments
ra...@google.com <ra...@google.com>
ra...@google.com <ra...@google.com>
at...@bloomberg.net <at...@bloomberg.net> #2
Yigit, do you have time to fix it?
reemission of the same liveData is racy
reemission of the same liveData is racy
su...@google.com <su...@google.com> #3
yea i'll take it.
at...@bloomberg.net <at...@bloomberg.net> #4
Thanks for the detailed analysis. This may not be an issue anymore since we've started using Main.immediate there but I' not sure; I'll try to create a test case.
su...@google.com <su...@google.com> #5
just emitting same live data reproduces the issue.
@Test
fun raceTest() {
val subLiveData = MutableLiveData(1)
val subject = liveData(testScope.coroutineContext) {
emitSource(subLiveData)
emitSource(subLiveData) //crashes
}
subject.addObserver().apply {
testScope.advanceUntilIdle()
}
}
@Test
fun raceTest() {
val subLiveData = MutableLiveData(1)
val subject = liveData(testScope.coroutineContext) {
emitSource(subLiveData)
emitSource(subLiveData) //crashes
}
subject.addObserver().apply {
testScope.advanceUntilIdle()
}
}
Description
Version used: 1.0.0-alpha
Devices/Android versions reproduced on: Emulator API 27
PeriodicWork is rescheduled each time cold start.
So JobService will be registered as many times as cold start.
- Sample project to trigger the issue.
- Reproduction
1. Launch WorkManagerSample app
2. Push [SCHEDULE] button. (will scheduled the 15min interval Worker)
3. Exit app and Clear app history(from the ■ button)
4. Launch WorkManagerSample app again(cold start)
- Result of [>>adb shell dumpsys jobscheduler]. (scheduled 2 jobs...)
JOB #u0a80/4: c32b177 com.example.workmanagersample/androidx.work.impl.background.systemjob.SystemJobService
u0a80 tag=*job*/com.example.workmanagersample/androidx.work.impl.background.systemjob.SystemJobService
Source: uid=u0a80 user=0 pkg=com.example.workmanagersample
JobInfo:
Service: com.example.workmanagersample/androidx.work.impl.background.systemjob.SystemJobService
PERIODIC: interval=+15m0s0ms flex=+15m0s0ms
PERSISTED
Requires: charging=false batteryNotLow=false deviceIdle=false
Extras: {EXTRA_WORK_SPEC_ID=c46ef83e-13b1-4595-888e-b80a4c8a72cf, EXTRA_IS_PERIODIC=true}
Backoff: policy=1 initial=+30s0ms
Has early constraint
Has late constraint
Required constraints: TIMING_DELAY DEADLINE
Satisfied constraints: APP_NOT_IDLE DEVICE_NOT_DOZING
Unsatisfied constraints: TIMING_DELAY DEADLINE
Tracking: TIME
Enqueue time: -4m46s595ms
Run time: earliest=+10m7s569ms, latest=+25m7s569ms
Last successful run: 2018-05-14 04:49:01
Ready: false (job=false user=true !pending=true !active=true !backingup=true comp=true)
JOB #u0a80/5: 93cf1f3 com.example.workmanagersample/androidx.work.impl.background.systemjob.SystemJobService
u0a80 tag=*job*/com.example.workmanagersample/androidx.work.impl.background.systemjob.SystemJobService
Source: uid=u0a80 user=0 pkg=com.example.workmanagersample
JobInfo:
Service: com.example.workmanagersample/androidx.work.impl.background.systemjob.SystemJobService
PERIODIC: interval=+15m0s0ms flex=+15m0s0ms
PERSISTED
Requires: charging=false batteryNotLow=false deviceIdle=false
Extras: {EXTRA_WORK_SPEC_ID=c46ef83e-13b1-4595-888e-b80a4c8a72cf, EXTRA_IS_PERIODIC=true}
Backoff: policy=1 initial=+30s0ms
Has early constraint
Has late constraint
Required constraints: TIMING_DELAY DEADLINE
Satisfied constraints: APP_NOT_IDLE DEVICE_NOT_DOZING
Unsatisfied constraints: TIMING_DELAY DEADLINE
Tracking: TIME
Enqueue time: -2m12s405ms
Run time: earliest=+12m29s338ms, latest=+27m29s338ms
Last successful run: 2018-05-14 04:51:35
Ready: false (job=false user=true !pending=true !active=true !backingup=true comp=true)