Closed Amokrane closed 4 years ago
Version 0.8.2 - same issue. Related https://github.com/firebase/firebase-jobdispatcher-android/issues/190
I was able to resolve this by having my JobService extend SimpleJobService
instead of JobService
and then moving my code from onStartJob
to onRunJob
in which SimpleJobService runs in a single background thread.
Not sure how SimpleJobService
will resolve this as internally it dispatches job to worker thread using AsyncTask
. I am also facing this issue, I am running this inside Async itself.
I was able to resolve this by having my JobService extend
SimpleJobService
instead ofJobService
and then moving my code fromonStartJob
toonRunJob
in which SimpleJobService runs in a single background thread.
This is not a solution, SimpleJobService extends JobService, so there's no difference between use SimpleJobService and JobService.
Guys, please review your code because it is very likely that you're causing this deadlock. I had exactly the same issue with mine code. Where is the issue? In calling JobDispatcher methods from JobService (main thread) and other thread at the same time. Have in mind that JobDispatcher internally calls some callbacks on main thread (like onStopJob). So, here is the stack:
Thread A (non-main):
at the same time: Thread B (JobService, main thread):
and we have deadlock. Solution: Don't call FBJobDispatcher methods from JobService on main thread.
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.
Hello,
Since we started using firebase-jobdispatcher we noticed a big increase in the number of ANRs in our application. The ANR trace that we got shows that a deadlock occurs when a job is about to get scheduled. Specifically, two threads are blocked competing for the same locks (runningJobs and serviceConnection) that they acquire in a different order.
Here is the thread dump that shows what happens:
And this is how we are defining our JobService:
The job is created and scheduled this way:
I looked to check whether this was a known issue or whether this same error was already seen in other projects but didn't find anything.
We are using the version 0.8.5.
Any thoughts?
Thank you.