From 10b00cebbc1e62712e1041451fddbebd41f2667f Mon Sep 17 00:00:00 2001 From: Dzmitry Babrovich Date: Fri, 11 Mar 2022 12:08:35 +0000 Subject: [PATCH] Insert ticker runnable using Handler.postAtFrontOfQueue instead of Handler.post method, which add a message to the end of the queue. This way we detect timeout of the currently running runnable and not the timeout of the queue of runnables that happens to be in front of ticker runnable. --- .../src/main/java/com/github/anrwatchdog/ANRWatchDog.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/anr-watchdog/src/main/java/com/github/anrwatchdog/ANRWatchDog.java b/anr-watchdog/src/main/java/com/github/anrwatchdog/ANRWatchDog.java index d1d9e24..8680665 100644 --- a/anr-watchdog/src/main/java/com/github/anrwatchdog/ANRWatchDog.java +++ b/anr-watchdog/src/main/java/com/github/anrwatchdog/ANRWatchDog.java @@ -255,7 +255,7 @@ public void run() { boolean needPost = _tick == 0; _tick += interval; if (needPost) { - _uiHandler.post(_ticker); + _uiHandler.postAtFrontOfQueue(_ticker); } try {