Fixed
Status Update
Comments
su...@google.com <su...@google.com> #2
A couple of questions:
1. Have you saw crash in real device or only in simulators?
2. Do you use dynamic feature for language ID?
1. Have you saw crash in real device or only in simulators?
2. Do you use dynamic feature for language ID?
su...@google.com <su...@google.com> #3
Tested on Android 12 Emulator with custom executor, but cannot repro this issue.
Description
Version used: 1.0.0-alpha12
Devices/Android versions reproduced on: Pixel 2 Emulator
Canceling work that is deeper in the chain (by tag) seems to cancel the work correctly, but it get enqueued again incorrectly.
DownloadCommentsWorker:
```
override fun doWork(): Result {
System.out.println("$this::class.java - Started")
Thread.sleep(Random.nextLong(5000))
System.out.println("$this::class.java - Done")
return Result.success()
}
```
FinalWorker:
```
override fun doWork(): Result {
System.out.println("ALL WORK COMPLETE")
return Result.success()
}
```
```
WorkManager.getInstance()
.beginUniqueWork("unique", ExistingWorkPolicy.KEEP, OneTimeWorkRequestBuilder<DownloadCommentsWorker>().build())
.then(OneTimeWorkRequestBuilder<FinalWorker>().addTag("finally").build())
.enqueue()
WorkManager.getInstance().getWorkInfosForUniqueWorkLiveData("unique").observe(this, workInfos -> {
for (WorkInfo info : workInfos) {
System.out.println(info.toString());
}
});
WorkManager.getInstance().cancelAllWorkByTag("finally").getState().observe(this, state -> {
System.out.println(state);
});
```
Console Output
```
2018-12-11 11:04:51.182 6991-6991/com.plangrid.android.devgrid I/System.out: SUCCESS
2018-12-11 11:04:51.184 6991-7056/com.plangrid.android.devgrid I/System.out: com.plangrid.android.workmanager.DownloadCommentsWorker@e5d859f::class.java - Started
2018-12-11 11:04:51.240 6991-6991/com.plangrid.android.devgrid I/System.out: WorkInfo{mId='4eac7884-3374-494a-a549-fcd7505fc5b4', mState=CANCELLED, mOutputData=androidx.work.Data@0, mTags=[finally, com.plangrid.android.workmanager.FinalWorker]}
2018-12-11 11:04:51.240 6991-6991/com.plangrid.android.devgrid I/System.out: WorkInfo{mId='c8e75590-8f60-40b7-a2e6-4e7aa6e7830d', mState=RUNNING, mOutputData=androidx.work.Data@0, mTags=[com.plangrid.android.workmanager.DownloadCommentsWorker]}
2018-12-11 11:04:54.488 6991-7056/com.plangrid.android.devgrid I/System.out: com.plangrid.android.workmanager.DownloadCommentsWorker@e5d859f::class.java - Done
2018-12-11 11:04:54.508 6991-6991/com.plangrid.android.devgrid I/System.out: WorkInfo{mId='4eac7884-3374-494a-a549-fcd7505fc5b4', mState=ENQUEUED, mOutputData=androidx.work.Data@0, mTags=[finally, com.plangrid.android.workmanager.FinalWorker]}
2018-12-11 11:04:54.509 6991-6991/com.plangrid.android.devgrid I/System.out: WorkInfo{mId='c8e75590-8f60-40b7-a2e6-4e7aa6e7830d', mState=SUCCEEDED, mOutputData=androidx.work.Data@0, mTags=[com.plangrid.android.workmanager.DownloadCommentsWorker]}
2018-12-11 11:04:54.518 6991-7057/com.plangrid.android.devgrid I/System.out: ALL WORK COMPLETE
2018-12-11 11:04:54.528 6991-6991/com.plangrid.android.devgrid I/System.out: WorkInfo{mId='4eac7884-3374-494a-a549-fcd7505fc5b4', mState=SUCCEEDED, mOutputData=androidx.work.Data@0, mTags=[finally, com.plangrid.android.workmanager.FinalWorker]}
2018-12-11 11:04:54.528 6991-6991/com.plangrid.android.devgrid I/System.out: WorkInfo{mId='c8e75590-8f60-40b7-a2e6-4e7aa6e7830d', mState=SUCCEEDED, mOutputData=androidx.work.Data@0, mTags=[com.plangrid.android.workmanager.DownloadCommentsWorker]}
```