googlearchive / firebase-jobdispatcher-android

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

Deadlock in v0.8.5 #270

Closed dtuttle closed 5 years ago

dtuttle commented 5 years ago

My code is making an API call to schedule a job (from a background worker thread) while the process' Main thread is handling a message for Firebase. The problem is that the two threads are locking the same objects in a different order :-(

The background thread scheduling a job locks 0x0b0a4414 then is blocked waiting on 0x0f9544bd. The main thread handling messages locks 0x0f9544bd then is blocked waiting on 0x0b0a4414.


Today, 9:11 AM on app version 60000021 LGE LG K20 Plus (lv517), Android 7.0 Report 1 of 3

The "main" (tid=1), "Thread-12" (tid=7) threads are in a deadlock.

"main" prio=5 tid=1 Blocked | group="main" sCount=1 dsCount=0 obj=0x7444f598 self=0xa5f04400 | sysTid=15179 nice=0 cgrp=bg_non_interactive sched=0/0 handle=0xa8d69534 | state=S schedstat=( 0 0 0 ) utm=6 stm=9 core=3 HZ=100 | stack=0xbe581000-0xbe583000 stackSize=8MB | held mutexes= at com.firebase.jobdispatcher.ExecutionDelegator.onJobFinishedMessage (ExecutionDelegator.java:140)

"Thread-12" prio=5 tid=7 Blocked | group="main" sCount=1 dsCount=0 obj=0x22d91ee0 self=0xa5f04e00 | sysTid=16207 nice=0 cgrp=bg_non_interactive sched=0/0 handle=0x8c5f7920 | state=S schedstat=( 0 0 0 ) utm=0 stm=0 core=0 HZ=100 | stack=0x8c4f5000-0x8c4f7000 stackSize=1038KB | held mutexes= at com.firebase.jobdispatcher.JobService.stop (JobService.java:183)

cooliceman commented 5 years ago

Had the same problem, after my app version that integrated job dispatcher released, ANRs are raising because of this ANR. any solution?

Fishfield commented 5 years ago

We have exactly the same ANR in our Apps

Qubitium commented 5 years ago

Until this is fixed by better locking code, you can sidestep the bugs by executing any relevant stopJob codes on the main/UI thread and you should see the ANRs rates drop like a rock.

Fishfield commented 5 years ago

Did anyone try v.0.8.6 and check if this issue is fixed?

toddshansen commented 5 years ago

please verify this is still occuring in v0.8.6 as there were additional fixes there.