Skip to content
This repository has been archived by the owner on Apr 8, 2020. It is now read-only.

GooglePlayDriver: doesn't reschedule Jobs after App is updated. #6

Closed
raphaelMediaMonk opened this issue May 29, 2016 · 22 comments
Closed

Comments

@raphaelMediaMonk
Copy link

raphaelMediaMonk commented May 29, 2016

GooglePlayDriver doesn't reschedule Jobs after Google Play Services or the app is updated.

GooglePlayReceiver has check for that situation in onStartCommand, but it doesn't handle this case correctly. All Jobs should be rescheduled.

To Reproduce issue:

  1. create any recurring Job with Lifetime.FOREVER.
  2. schedule the job.
  3. install updated .apk or update Google Play Services.
  4. Job won't be called no more.
@libhide
Copy link

libhide commented Oct 5, 2016

Hey! Is this still an issue? I want to use the library in production. I've got the library working like I want it too but reading this issue has got me worried.

@ciarand
Copy link
Contributor

ciarand commented Oct 6, 2016

Yes, this is still happening. We have an internal issue tracking this (the fix needs to happen in Google Play services), but the fix hasn't been launched yet.

For now, as a workaround, I recommend scheduling all your jobs sometime during your initialization phase with shouldReplaceCurrent set to false: https://github.com/firebase/firebase-jobdispatcher-android/blob/0.5.0/jobdispatcher/src/main/java/com/firebase/jobdispatcher/JobParameters.java#L82

@LouisCAD
Copy link

On this page, it's written that Google Play Services has an onInitializeTasks() callback called after Play Services or the client app is updated, where we are supposed to reschedule tasks. It's not ideal as not having to reschedule tasks would be better, but how can we apply this "workaround" to Firebase Job Dispatcher in the meantime?

@trignodev-manish
Copy link

is this an issue with recurring job only or with one time scheduled job also, i have used this in my project and wondering if this is happening in one time scheduled job as well then that will create issues and i have to look for alternates.

@LouisCAD
Copy link

LouisCAD commented Feb 7, 2017

When this critical issue will see a fix?

I'm going to advocate against this library if usability issues big like this one take months (closer to a year in fact) to be solved here!

sytolk added a commit to sytolk/firebase-jobdispatcher-android that referenced this issue Feb 27, 2017
@sytolk
Copy link

sytolk commented Feb 27, 2017

@ciarand Do you know how jobs can be automatically rescheduled here ?
sytolk@a47ab5a

@wilburx9
Copy link

wilburx9 commented Mar 2, 2017

Has this issue been fixed yet?

@summersmichael
Copy link

If anyone is still facing this issue, a workaround I found is what LouisCAD touched on. Create a stub GcmTaskService, that does nothing in OnRunTask, and override OnInitializeTasks function to perform all re-scheduling.

@aftabsikander
Copy link

@summersmichael any example code you can share?

@wilburx9
Copy link

wilburx9 commented Jun 7, 2017

@aftabsikander here:

public class PostNotifyReschedule extends GcmTaskService {
    @Override
    public int onRunTask(TaskParams taskParams) {
        PostNotification.switchOn(PostNotifyReschedule.this);  // Schedules the job
        return 0;
    }
}

Then register it in the manifest as usual:

<service
            android:name=".services.PostNotifyReschedule"
            android:enabled="true"
            android:exported="true"
            android:permission="com.google.android.gms.permission.BIND_NETWORK_TASK_SERVICE">
            <intent-filter>
                <action android:name="com.google.android.gms.gcm.ACTION_TASK_READY" />
            </intent-filter>

 </service>

@lpellegr
Copy link

lpellegr commented Jun 25, 2017

@unEgor
Copy link
Contributor

unEgor commented Jul 22, 2017

As a workaround you could listen to ACTION_MY_PACKAGE_REPLACED and reschedule your job onReceive.

@LouisCAD
Copy link

@ciarand I'm ringing the bell. What's the progress on your internal issue on this?
It's been more than a year, 3 newer Android versions since (7.0, 7.1, 8.0).
Are we waiting for something, or are we waiting for vaporware?

@LouisCAD
Copy link

@ciarand Also, why is this issue marked as unassigned?

@LouisCAD
Copy link

Hi,
After making a small sample to try the behavior of this library, I could see that jobs are not forgotten after an app update or Google Play Services update (downgraded to stock v8 too see how the sample would behave when auto updating to v11). So it seems this issue is fixed and that Firebase Job Dispatcher doesn't need the trick that was needed for GCMTaskManager after all. So why is this issue still open?

@LouisCAD
Copy link

LouisCAD commented Sep 9, 2017

Hi,
After testing again, I saw a scheduled job that wasn't run after I updated my app through adb with Android Studio, so this critical issue (as seen from us, developers who want to make reliable apps that user can trust, at least) seems to still be unresolved. I'll publish a gist with my workaround until the folks that work on this library fix this issue.

@LouisCAD
Copy link

LouisCAD commented Sep 9, 2017

Here's a workaround that requires GCM dependency

@ciarand
Copy link
Contributor

ciarand commented Sep 19, 2017

That makes sense, @LouisCAD. The current version of Google Play services does not cancel FJD jobs when the app is updated, which matches the behavior of the platform job scheduler. There was a bug in older versions where it would, but it was fixed in the February release (v9). We were waiting for market penetration before closing this, but it ended up falling off our radar.

If the onInitializeTasks behavior + pre-v9 compat is important, it's probably much easier just to listen for your MY_PACKAGE_REPLACED broadcast instead of the onInitializeTasks, no? That saves you the hassle of including the GCM package and is ultimately a better solution from the system's perspective.

@LouisCAD
Copy link

@ciarand Thanks for letting us know the status of this issue! We had really no information about this before.
Doesn't MY_PACKAGE_REPLACED fails to be called when Google Play Services themselves are replaced (and discard scheduled jobs before v9)?
Also, maybe a solution is to block our app from working until Play Services are updated to v9+, using a simple check like this one?

@samtstern
Copy link
Contributor

@ciarand do you consider this closed?

@Signez
Copy link

Signez commented Oct 16, 2018

There was a bug in older versions where it would, but it was fixed in the February release (v9). We were waiting for market penetration before closing this, but it ended up falling off our radar.

Is the market penetration good enough now (in October 2018) to consider that problem solved? I'm considering using Firebase JobDispatcher and the workaround is non-trivial.

@samtstern
Copy link
Contributor

In April 2019 we announced that Firebase Job Dispatcher would be deprecated today, April 7th 2020. For this reason we are going to close all open issues and archive the repository. We will also stop supporting FJD for new app installations (such as those targeting sdk versions greater than Android Q). Existing apps that rely on FJD should continue to function as usual.

While we will no longer work on FJD, we encourage you to migrate to Work Manager which is a superior tool and fully supported by the Android team.

Thank you for taking the time to try the library and provide this feedback. We sincerely appreciate your effort and we apologize for not addressing it in time.

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

No branches or pull requests