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

Job not running #5

Open
piotrpalek opened this issue Jun 22, 2018 · 4 comments
Open

Job not running #5

piotrpalek opened this issue Jun 22, 2018 · 4 comments

Comments

@piotrpalek
Copy link

piotrpalek commented Jun 22, 2018

Hey, I've followed the steps to install and configure the job scheduler, but it seems the jobs aren't running (nothing is printed in the logs, but also no error).

Is there some example app I could maybe compare mine with?

btw. as far as I could get, the examples are a bit wrong right? it should be

await AndroidJobScheduler.scheduleEvery( const Duration(seconds: 10), 42, iRunPeriodically);

instead of:

await AndroidJobScheduler.scheduleEvery( const Duration(seconds: 10), iRunPeriodically, 42);

I've pushed the example app I've been trying here: https://github.com/piotrpalek/test_flutter_job

@georggrab
Copy link
Owner

Hi there, your App looks fine, and I just tested it on my Test Device; the Job gets run there. Can you share more information about your Environment? Do you happen to run on API Level < 21, where the Job Scheduler isn't available? Could you test it on a recent Android Emulator?
Thanks for the hint regarding the examples, you're exactly right, they are outdated.

@piotrpalek
Copy link
Author

piotrpalek commented Jun 22, 2018

Hmm this is weird, it ran for a bit, but now doesn't. My device is Samsung Galaxy S5 with Android 6.0.1 so the API version should be good.

It sometimes runs, but very rare and not consistently (I think sometimes when I close the app). I've also noticed this in the logs when it's running:

06-22 11:05:59.990 31058 31307 V AlarmManager: Expired Alarm result :8
06-22 11:06:26.620 31058 31307 V AlarmManager: Expired Alarm result :8
06-22 11:06:31.440 31058 32447 V AlarmManager:  remove PendingIntent] PendingIntent{a03ba5: PendingIntentRecord{40212a6 com.google.android.gms broadcastIntent}}

edit: just to confirm, tried it on a Pixel 2 and it runs smoothly there
edit2: tried to run on an emulator with API level 23 (x86) and it doesn't run there as well for me

@georggrab
Copy link
Owner

Thanks for bringing this to my attention. This is likely a problem with the Service implementation. One thing to note here is that the Android OS normally doesn't allow you to schedule jobs at a more frequent interval than 15min. One possibility (read "hack") to work around this is to Schedule OneShot Jobs, and reschedule another OneShot Job at the end, which is how the service is implemented. I'll investigate how this is behaving on lower API levels, it probably is breaking at that stage.

Did you, by any chance, notice any exceptions thrown by the Jobscheduler (io.gjg.androidjobscheduler) service? Also, are you able to reproduce the problem with the example app provided in this repo? This would help us rule out any issues related to Logging, because the Job in the example app is performing a much more visible thing than just printing text (writing state to persistent storage)

@piotrpalek
Copy link
Author

piotrpalek commented Jun 23, 2018

No, I didn't see any exceptions thrown by the Jobscheduler, also I've just tried the example app in the repo. It seems to work! But I have no idea what I'm doing wrong in my example :)

btw. do the jobs run when the phone is locked / in sleep mode? The logs seem to pause when the phone is locked.

edit:

I've had a bunch of weird behaviors, I'm not sure how to reproduce them but I'll list them anyway for now (sorry if this is vague):

  • it seems that when I've installed the example app from the repo, and started a timer it worked and it also seemed to trigger the timer from my test app. To make it clear, the bg job from my test app didn't work, but when I've started the job in the example app the job from my test app started to trigger, but produced an error:
/flutter ( 8735): [ERROR:flutter/shell/platform/android/android_context_gl.cc(217)] Could not make the context current
E/flutter ( 8735): [ERROR:flutter/shell/platform/android/android_context_gl.cc(53)] EGL Error: EGL_BAD_ACCESS (12290)
  • after that I have played around with the example app and it seems I've broken the job scheduling somehow (didn't work no matter what I did, force close, uninstall / reinstall, clear app data). After that I've tried to reboot the phone, and now after I've scheduled a job, and move the app to the background (press home btn) I've got this:
(...)
I/flutter ( 5994): Contents: 13
I/flutter ( 5994): Yolo executing
I/flutter ( 5994): Contents: 14
V/ActivityThread( 5994): updateVisibility : ActivityRecord{80bad5a token=android.os.BinderProxy@3fe5ca9 {io.gjg.androidjobschedulerexample/io.gjg.androidjobschedulerexample.MainActivity}} show : false
W/art     ( 5994): Native thread exiting without having called DetachCurrentThread (maybe it's going to use a pthread_key_create destructor?): Thread[13,tid=8674,Native,Thread*=0x98bb6900,peer=0x32d4b0a0,"Thread-755"]
D/ViewRootImpl( 5994): #3 mView = null
D/FlutterNativeView( 5994): FlutterView.send called on a detached view, channel=plugins.gjg.io/android_job_scheduler
D/FlutterNativeView( 5994): FlutterView.send called on a detached view, channel=plugins.gjg.io/android_job_scheduler
(...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants