Skip to content

Commit 25b0da1

Browse files
authored
Prevent ANR duplicates (#39)
* Prevent ANR duplicates * typo * Format change
1 parent e3bff7a commit 25b0da1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

backtrace-library/src/main/java/backtraceio/library/watchdog/BacktraceANRWatchdog.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public void setOnApplicationNotRespondingEvent(OnApplicationNotRespondingEvent
9797
*/
9898
@Override
9999
public void run() {
100+
Boolean reported = false;
100101
while (!shouldStop && !isInterrupted()) {
101102
String dateTimeNow = Calendar.getInstance().getTime().toString();
102103
BacktraceLogger.d(LOG_TAG, "ANR WATCHDOG - " + dateTimeNow);
@@ -116,6 +117,7 @@ public void run() {
116117
threadWatcher.tickPrivateCounter();
117118

118119
if (threadWatcher.getCounter() == threadWatcher.getPrivateCounter()) {
120+
reported = false;
119121
BacktraceLogger.d(LOG_TAG, "ANR is not detected");
120122
continue;
121123
}
@@ -125,6 +127,11 @@ public void run() {
125127
"is on and connected debugger");
126128
continue;
127129
}
130+
if (reported) {
131+
// skipping, because we already reported an ANR report for current ANR
132+
continue;
133+
}
134+
reported = true;
128135
BacktraceWatchdogShared.sendReportCauseBlockedThread(backtraceClient,
129136
Looper.getMainLooper().getThread(), onApplicationNotRespondingEvent, LOG_TAG);
130137
}

0 commit comments

Comments
 (0)