Skip to content

Commit

Permalink
Merge pull request #2367 from square/py/looper_null
Browse files Browse the repository at this point in the history
Handler null looper
  • Loading branch information
pyricau committed Apr 20, 2022
2 parents be925ba + 207a77e commit cacd5b3
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,17 @@ enum class AndroidLeakFixes {
threadId to thread
}
}
flushedThreadIds += newHandlerThreadsById.map { it.first }
newHandlerThreadsById
.map { it.second }
.forEach { handlerThread ->
.forEach { (threadId, handlerThread) ->
val looper = handlerThread.looper
if (looper == null) {
SharkLog.d { "Handler thread found without a looper: $handlerThread" }
return@forEach
}
flushedThreadIds += threadId
SharkLog.d { "Setting up flushing for $handlerThread" }
var scheduleFlush = true
val flushHandler = Handler(handlerThread.looper)
val flushHandler = Handler(looper)
flushHandler.onEachIdle {
if (handlerThread.isAlive && scheduleFlush) {
scheduleFlush = false
Expand Down

0 comments on commit cacd5b3

Please sign in to comment.