Skip to content

馃悶Workmanager().registerOneOffTask no more runs the task immediately#732

Description

@absar
  • I have read the README
  • I have done the setup for Android
  • I have done the setup for iOS
  • I have ran the sample app and it does not work there

Version

Technology Version
Workmanager version 0.10.7
workmanager_android 0.10.6
Android OS 16

Describe the error
Workmanager on Android after recent updates has become unreliable. Expected behavior of Workmanager().registerOneOffTask is to schedule the job and run almost immediately if no delay is given, but 90%+ of the time it's not running the job anymore, it says Starting work for xxx then Work WorkGenerationalId(workSpecId=xxx, generation=0) is already enqueued for processing even though it's not a recurring task rather a one time task.

Steps to reproduce:

  • Run the example app and press Start the Flutter background service
  • Press Register OneOff Task
  • Expected behavior: the job should run and callback output should be seen in the terminal, but it does not run and just show Work WorkGenerationalId(workSpecId=xxx, generation=0) is already enqueued for processing
  • If the issue is not reproduced press the Register OneOff Task button again
  • It feels like it's behaving like registerPeriodicTask not a one time near realtime task
Workmanager().registerOneOffTask(
  simpleTaskKey,
  simpleTaskKey,
  inputData: <String, dynamic>{
    'int': 1,
    'bool': true,
    'double': 1.0,
    'string': 'string',
    'array': [1, 2, 3],
  },
);

Logs

W/JobInfo ( 5115): Requested important-while-foreground flag for job3 is ignored and takes no effect
D/WM-SystemJobScheduler( 5115): Scheduling work ID 08a9e735-efc4-4bd8-9b46-64abe52389d5Job ID 3
D/WM-GreedyScheduler( 5115): Starting work for 08a9e735-efc4-4bd8-9b46-64abe52389d5
D/WM-Processor( 5115): Processor: processing WorkGenerationalId(workSpecId=08a9e735-efc4-4bd8-9b46-64abe52389d5, generation=0)
D/WM-SystemJobService( 5115): onStartJob for WorkGenerationalId(workSpecId=08a9e735-efc4-4bd8-9b46-64abe52389d5, generation=0)
D/WM-WorkerWrapper( 5115): Starting work for dev.fluttercommunity.workmanager.BackgroundWorker
D/WM-Processor( 5115): Work WorkGenerationalId(workSpecId=08a9e735-efc4-4bd8-9b46-64abe52389d5, generation=0) is already enqueued for processing
D/WM-PackageManagerHelper( 5115): androidx.work.impl.background.systemalarm.RescheduleReceiver enabled

Notifications:

Image

After waiting for a few minutes the job never starts. Pressing Cancel all shows these logs and notifications:

Image
I/ImeTracker( 6091): dev.fluttercommunity.workmanager.example:4ed837a9: onCancelled at PHASE_CLIENT_ALREADY_HIDDEN
D/WM-Processor( 6091): Processor cancelling ef66360d-2066-47c1-9b6f-146fd8958f02
I/flutter ( 6091): Cancel all tasks completed
D/WM-Processor( 6091): WorkerWrapper interrupted for ef66360d-2066-47c1-9b6f-146fd8958f02
D/WM-GreedyScheduler( 6091): Cancelling work ID ef66360d-2066-47c1-9b6f-146fd8958f02
D/WM-StopWorkRunnable( 6091): StopWorkRunnable for ef66360d-2066-47c1-9b6f-146fd8958f02; Processor.stopWork = false
D/WM-PackageManagerHelper( 6091): androidx.work.impl.background.systemalarm.RescheduleReceiver disabled
D/WM-SystemJobService( 6091): onStopJob for WorkGenerationalId(workSpecId=ef66360d-2066-47c1-9b6f-146fd8958f02, generation=0)
I/WM-WorkerWrapper( 6091): Work [ id=ef66360d-2066-47c1-9b6f-146fd8958f02, tags={ dev.fluttercommunity.workmanager.BackgroundWorker } ] was cancelled
I/WM-WorkerWrapper( 6091): androidx.work.impl.WorkerStoppedException
I/WM-WorkerWrapper( 6091): 	at androidx.work.impl.WorkerWrapper.interrupt(WorkerWrapper.kt:355)
I/WM-WorkerWrapper( 6091): 	at androidx.work.impl.Processor.interrupt(Processor.java:436)
I/WM-WorkerWrapper( 6091): 	at androidx.work.impl.Processor.stopAndCancelWork(Processor.java:280)
I/WM-WorkerWrapper( 6091): 	at androidx.work.impl.utils.CancelWorkRunnable.cancel(CancelWorkRunnable.kt:33)
I/WM-WorkerWrapper( 6091): 	at androidx.work.impl.utils.CancelWorkRunnable.forAll$lambda$7$lambda$6(CancelWorkRunnable.kt:149)
I/WM-WorkerWrapper( 6091): 	at androidx.work.impl.utils.CancelWorkRunnable.$r8$lambda$WQ8qWu08hO2qnt0ltJMkDwBtAwg(Unknown Source:0)
I/WM-WorkerWrapper( 6091): 	at androidx.work.impl.utils.CancelWorkRunnable$$ExternalSyntheticLambda7.run(D8$$SyntheticClass:0)
I/WM-WorkerWrapper( 6091): 	at androidx.room.RoomDatabase.runInTransaction(RoomDatabase.android.kt:713)
I/WM-WorkerWrapper( 6091): 	at androidx.work.impl.utils.CancelWorkRunnable.forAll$lambda$7(CancelWorkRunnable.kt:145)
I/WM-WorkerWrapper( 6091): 	at androidx.work.impl.utils.CancelWorkRunnable.$r8$lambda$lTL9Gg9r_NUH7ARdqAbl768p6fs(Unknown Source:0)
I/WM-WorkerWrapper( 6091): 	at androidx.work.impl.utils.CancelWorkRunnable$$ExternalSyntheticLambda5.invoke(D8$$SyntheticClass:0)
I/WM-WorkerWrapper( 6091): 	at androidx.work.OperationKt.launchOperation$lambda$2$lambda$1(Operation.kt:50)
I/WM-WorkerWrapper( 6091): 	at androidx.work.OperationKt.$r8$lambda$XKAkIiEN7OgIvwuLUZRQpJhjmyE(Unknown Source:0)
I/WM-WorkerWrapper( 6091): 	at androidx.work.OperationKt$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:0)
I/WM-WorkerWrapper( 6091): 	at androidx.work.impl.utils.SerialExecutorImpl$Task.run(SerialExecutorImpl.java:96)
I/WM-WorkerWrapper( 6091): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1156)
I/WM-WorkerWrapper( 6091): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:651)
I/WM-WorkerWrapper( 6091): 	at java.lang.Thread.run(Thread.java:1119)
D/WM-WorkerWrapper( 6091): Status for ef66360d-2066-47c1-9b6f-146fd8958f02 is CANCELLED ; not doing any work
D/WM-StopWorkRunnable( 6091): StopWorkRunnable for ef66360d-2066-47c1-9b6f-146fd8958f02; Processor.stopWork = false
D/WM-Processor( 6091): Processor ef66360d-2066-47c1-9b6f-146fd8958f02 executed; reschedule = false
D/WM-GreedyScheduler( 6091): Cancelling work ID ef66360d-2066-47c1-9b6f-146fd8958f02
I/ImeTracker( 6091): dev.fluttercommunity.workmanager.example:89fbcb18: onCancelled at PHASE_CLIENT_ALREADY_HIDDEN

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions