googlearchive / firebase-jobdispatcher-android

DEPRECATED please see the README.md below for details.
Apache License 2.0
1.79k stars 208 forks source link

Memory leak #263

Closed LouisCAD closed 4 years ago

LouisCAD commented 6 years ago

Saw this in the logs in version 0.8.5.

2018-08-08 16:33:38.925 3721-3721/net.suivideflotte.drivercompanion.debug E/ActivityThread: Service com.firebase.jobdispatcher.GooglePlayReceiver has leaked ServiceConnection com.firebase.jobdispatcher.JobServiceConnection@181a6ef that was originally bound here
    android.app.ServiceConnectionLeaked: Service com.firebase.jobdispatcher.GooglePlayReceiver has leaked ServiceConnection com.firebase.jobdispatcher.JobServiceConnection@181a6ef that was originally bound here
        at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:1532)
        at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:1424)
        at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1605)
        at android.app.ContextImpl.bindService(ContextImpl.java:1557)
        at android.content.ContextWrapper.bindService(ContextWrapper.java:684)
        at com.firebase.jobdispatcher.ExecutionDelegator.executeJob(ExecutionDelegator.java:110)
        at com.firebase.jobdispatcher.GooglePlayMessageHandler.handleStartMessage(GooglePlayMessageHandler.java:98)
        at com.firebase.jobdispatcher.GooglePlayMessageHandler.handleMessage(GooglePlayMessageHandler.java:67)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
dtuttle commented 6 years ago

Seconded.

I've seen this quite frequently with 0.8.5 in the last few weeks or so. The symptoms will be an onStopJob() is called on a currently executing job and when I check my background worker thread, the thread appears healthy but stuck (see below example A). Then, when I check logcat, I can see the aforementioned stacktrace which precedes the onStopJob by 8ms (see below example B). The Firebase JobService itself seems to have gone away.

Is there a conflict between Firebase Job Dispatcher 0.8.5 and Google Play Services? I've observed the issue on a Nexus 5 w/5.0, an LG G6 w/8.0, a Pixel w/8.1, and a Pixel 2 w/9.0. All of the devicces would have been updated to the most recent version(s) of Play Services.

Example A:

Application log snippet (in UTC time) on a Pixel w/8.1:

[2018/08/14-13:51:13.817] Java: NetworkService [1534254673817] onStopJob - current running job stopped. Thread is alive and not interrupted, state = RUNNABLE com.firebase.jobdispatcher.GooglePlayDriver.createSchedulerIntent(GooglePlayDriver.java:143) com.firebase.jobdispatcher.GooglePlayDriver.createCancelRequest(GooglePlayDriver.java:110) com.firebase.jobdispatcher.GooglePlayDriver.cancel(GooglePlayDriver.java:96) com.firebase.jobdispatcher.FirebaseJobDispatcher.cancel(FirebaseJobDispatcher.java:99) com.devicescape.connectsdk.NetworkService$2.run(NetworkService.java:1058) java.lang.Thread.run(Thread.java:764)

Example B:

Logcat snippet (in US-East time) on Pixel w/8.1:

08-14 09:51:13.809 11467 11467 E ActivityThread: Service com.firebase.jobdispatcher.GooglePlayReceiver has leaked ServiceConnection com.firebase.jobdispatcher.JobServiceConnection@387b55 that was originally bound here 08-14 09:51:13.809 11467 11467 E ActivityThread: android.app.ServiceConnectionLeaked: Service com.firebase.jobdispatcher.GooglePlayReceiver has leaked ServiceConnection com.firebase.jobdispatcher.JobServiceConnection@387b55 that was originally bound here 08-14 09:51:13.809 11467 11467 E ActivityThread: at android.app.LoadedApk$ServiceDispatcher.(LoadedApk.java:1532) 08-14 09:51:13.809 11467 11467 E ActivityThread: at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:1424) 08-14 09:51:13.809 11467 11467 E ActivityThread: at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1605) 08-14 09:51:13.809 11467 11467 E ActivityThread: at android.app.ContextImpl.bindService(ContextImpl.java:1557) 08-14 09:51:13.809 11467 11467 E ActivityThread: at android.content.ContextWrapper.bindService(ContextWrapper.java:684) 08-14 09:51:13.809 11467 11467 E ActivityThread: at com.firebase.jobdispatcher.ExecutionDelegator.executeJob(ExecutionDelegator.java:110) 08-14 09:51:13.809 11467 11467 E ActivityThread: at com.firebase.jobdispatcher.GooglePlayMessageHandler.handleStartMessage(GooglePlayMessageHandler.java:98) 08-14 09:51:13.809 11467 11467 E ActivityThread: at com.firebase.jobdispatcher.GooglePlayMessageHandler.handleMessage(GooglePlayMessageHandler.java:67) 08-14 09:51:13.809 11467 11467 E ActivityThread: at android.os.Handler.dispatchMessage(Handler.java:106) 08-14 09:51:13.809 11467 11467 E ActivityThread: at android.os.Looper.loop(Looper.java:164) 08-14 09:51:13.809 11467 11467 E ActivityThread: at android.app.ActivityThread.main(ActivityThread.java:6494) 08-14 09:51:13.809 11467 11467 E ActivityThread: at java.lang.reflect.Method.invoke(Native Method) 08-14 09:51:13.809 11467 11467 E ActivityThread: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 08-14 09:51:13.809 11467 11467 E ActivityThread: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

marcosalis commented 5 years ago

I'm getting this too on 0.8.5, any chance for this to be fixed? Thank you!

stevesamknows commented 5 years ago

Just saw this on version 0.7.0 (on Pixel 2 running 9.0)

samtstern commented 4 years ago

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.