Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐞Cannot set backoff criteria on an idle mode job #107

Closed
4 tasks done
pro100svitlo opened this issue Oct 25, 2019 · 6 comments
Closed
4 tasks done

🐞Cannot set backoff criteria on an idle mode job #107

pro100svitlo opened this issue Oct 25, 2019 · 6 comments
Assignees
Labels
android Android specific bug Something isn't working

Comments

@pro100svitlo
Copy link

  • 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.1.3
Xcode version 11.1
Swift version 4.2
iOS deployment target 10

Describe the error

trying to set repetable task, and its crached:

E/MethodChannel#be.tramckrijte.workmanager/foreground_channel_work_manager(18644): Failed to handle method call
E/MethodChannel#be.tramckrijte.workmanager/foreground_channel_work_manager(18644): java.lang.IllegalArgumentException: Cannot set backoff criteria on an idle mode job
E/MethodChannel#be.tramckrijte.workmanager/foreground_channel_work_manager(18644): 	at androidx.work.PeriodicWorkRequest$Builder.buildInternal(PeriodicWorkRequest.java:188)
E/MethodChannel#be.tramckrijte.workmanager/foreground_channel_work_manager(18644): 	at androidx.work.PeriodicWorkRequest$Builder.buildInternal(PeriodicWorkRequest.java:73)
E/MethodChannel#be.tramckrijte.workmanager/foreground_channel_work_manager(18644): 	at androidx.work.WorkRequest$Builder.build(WorkRequest.java:279)
E/MethodChannel#be.tramckrijte.workmanager/foreground_channel_work_manager(18644): 	at be.tramckrijte.workmanager.WM.enqueuePeriodicTask(WorkmanagerCallHandler.kt:162)
E/MethodChannel#be.tramckrijte.workmanager/foreground_channel_work_manager(18644): 	at be.tramckrijte.workmanager.RegisterTaskHandler.enqueuePeriodicTask(WorkmanagerCallHandler.kt:66)
E/MethodChannel#be.tramckrijte.workmanager/foreground_channel_work_manager(18644): 	at be.tramckrijte.workmanager.RegisterTaskHandler.handle(WorkmanagerCallHandler.kt:60)
E/MethodChannel#be.tramckrijte.workmanager/foreground_channel_work_manager(18644): 	at be.tramckrijte.workmanager.WorkmanagerCallHandler.handle(WorkmanagerCallHandler.kt:25)
E/MethodChannel#be.tramckrijte.workmanager/foreground_channel_work_manager(18644): 	at be.tramckrijte.workmanager.WorkmanagerPlugin.onMethodCall(WorkmanagerPlugin.kt:27)
E/MethodChannel#be.tramckrijte.workmanager/foreground_channel_work_manager(18644): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222)
E/MethodChannel#be.tramckrijte.workmanager/foreground_channel_work_manager(18644): 	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96)
E/MethodChannel#be.tramckrijte.workmanager/foreground_channel_work_manager(18644): 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:656)
E/MethodChannel#be.tramckrijte.workmanager/foreground_channel_work_manager(18644): 	at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#be.tramckrijte.workmanager/foreground_channel_work_manager(18644): 	at android.os.MessageQueue.next(MessageQueue.java:323)
E/MethodChannel#be.tramckrijte.workmanager/foreground_channel_work_manager(18644): 	at android.os.Looper.loop(Looper.java:136)
E/MethodChannel#be.tramckrijte.workmanager/foreground_channel_work_manager(18644): 	at android.app.ActivityThread.main(ActivityThread.java:6077)
E/MethodChannel#be.tramckrijte.workmanager/foreground_channel_work_manager(18644): 	at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#be.tramckrijte.workmanager/foreground_channel_work_manager(18644): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
E/MethodChannel#be.tramckrijte.workmanager/foreground_channel_work_manager(18644): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)

here is how I init and set task:

Workmanager.initialize(_fetcherCallback, isInDebugMode: isDebug);
    Workmanager.registerPeriodicTask(_TASK_NAME, _TASK_NAME,
        initialDelay: _INTERVAL,
        backoffPolicy: BackoffPolicy.linear,
        backoffPolicyDelay: _INTERVAL,
        existingWorkPolicy: ExistingWorkPolicy.keep,
        constraints: Constraints(networkType: NetworkType.connected, requiresDeviceIdle: true));

here is screenshot from registerPeriodicTask breackpoint before crash:
Screen Shot 2019-10-25 at 15 39 03

Output of flutter doctor -v

 ios git:(workManager) ✗ flutter doctor -v
[✓] Flutter (Channel stable, v1.9.1+hotfix.6, on Mac OS X 10.14.6 18G95, locale en)
    • Flutter version 1.9.1+hotfix.6 at /Users/userName/dev/flutter/sdk
    • Framework revision 68587a0916 (6 weeks ago), 2019-09-13 19:46:58 -0700
    • Engine revision b863200c37
    • Dart version 2.5.0

 
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/userName/Library/Android/sdk/
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 28.0.3
    • ANDROID_HOME = /Users/userName/Library/Android/sdk/
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.1, Build version 11A1027
    • CocoaPods version 1.7.0

[✓] Android Studio (version 3.5)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 40.2.2
    • Dart plugin version 191.8423
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] Connected device (1 available)
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 5.0.2 (API 21) (emulator)

• No issues found!

@pro100svitlo pro100svitlo added the bug Something isn't working label Oct 25, 2019
@timrijckaert
Copy link
Contributor

It seems like you can not set a back off criteria and an idle constraint together.
See upstream.

However we are always setting one internally so we'll need to fix this.

Thanks for the bug report.

@timrijckaert timrijckaert added the android Android specific label Oct 25, 2019
@timrijckaert timrijckaert self-assigned this Oct 25, 2019
@pro100svitlo
Copy link
Author

but this one happen even if I remove all backOff criterias 😉

@timrijckaert
Copy link
Contributor

timrijckaert commented Oct 25, 2019

Yes like I said we assign a default value of Backoff.exponential, so it is a bug on our end.
We'll fix this in an upcoming release.

For now if you get rid of the requiresDeviceIdle constraint it should successfully register

@timrijckaert
Copy link
Contributor

Hi @pro100svitlo,

I have prepared a fix.
Will ask colleagues on monday to review the code.

I tested it and it seems ok now.

However do note that even with the fix you will not be able to use backoff policy together with the requiresDeviceIdle. This is simply prevented by Android.

@timrijckaert timrijckaert added the answered Used to auto-close 'answered' issues after a certain time of inactivity label Oct 26, 2019
@pro100svitlo
Copy link
Author

Thanks for fast hot fix!

you will not be able to use backoff policy together with the requiresDeviceIdle

for me it kind of obvoius 😆
but it would be nice, If app will crash in case somebody will try to enable both of them 😉

@no-response no-response bot removed the answered Used to auto-close 'answered' issues after a certain time of inactivity label Oct 27, 2019
@timrijckaert
Copy link
Contributor

timrijckaert commented Oct 28, 2019

Good news!
0.1.4 is released. 🥇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android Android specific bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants