Merged
Conversation
This comment has been minimized.
This comment has been minimized.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3192 +/- ##
===========================================
- Coverage 71.31% 71.25% -0.06%
===========================================
Files 929 929
Lines 34442 34457 +15
Branches 5813 5813
===========================================
- Hits 24562 24551 -11
- Misses 8247 8263 +16
- Partials 1633 1643 +10
🚀 New features to boost your workflow:
|
2880b77 to
2a301ad
Compare
hamorillo
previously approved these changes
Feb 20, 2026
...-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/anr/ANRDetectorRunnable.kt
Outdated
Show resolved
Hide resolved
| shouldStop = true | ||
| } | ||
|
|
||
| private fun reportAnr() { |
Contributor
There was a problem hiding this comment.
Nice refactor! It looks much cleaner now!
2a301ad to
d5cc76c
Compare
hamorillo
approved these changes
Feb 20, 2026
ambushwork
approved these changes
Feb 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR changes a bit ANR detection mechanism to move away from the shared (between main thread and detector thread) synchronization object to the
CountDownLatch.This should reduce the execution cost of the detector callback from the main thread by not waiting to acquire the lock if detector thread is performing long operation when ANR is registered (
addErrormay be a long waiting call if context queue is full and blocks till ready to accept new item).Here is the benchmark results in case if getting thread info (or reporting to RUM monitor) takes 5ms. It compares the detector callback execution from the main thread between new implementation vs previous one.
ANR threshold is set to 1s, ANR test blocks thread for 1.05s, each scenario was executed 100 times with 20 warm-up iterations before.
Here are results if getting thread info (or reporting to RUM monitor) takes 500 ms instead.
It can be seen, that with the original approach trying to acquire the monitor when detector has long reporting routine comes with long wait as well, which is not there for the new approach.
Other results are mixed, but given the overall time (dozens of microseconds) it is okay.
100-400 us timings in the table above are probably outliers. Detector runnable just calls
countDown(), and time should be more or less in the same ballpark.Review checklist (to be filled by reviewers)