Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a0b493e
feat(anr): Sample app and UI test for non-fatal ANRs
markushi Nov 19, 2026
6448ffa
chore(anr): Merge non-fatal-anr-6 into non-fatal-anr-7
markushi Nov 23, 2026
9504c95
docs(changelog): Remove the ANR profiling behavior change
markushi Nov 23, 2026
8f78b82
chore(anr): Merge non-fatal-anr-6 into non-fatal-anr-7
markushi Nov 23, 2026
0528741
docs(changelog): Note the earlier start of ANR profiles
markushi Nov 23, 2026
c1db0d1
chore(anr): Merge non-fatal-anr-6 into non-fatal-anr-7
markushi Nov 23, 2026
2992839
chore(anr): Merge non-fatal-anr-6 into non-fatal-anr-7
markushi Nov 24, 2026
270d610
chore(anr): Merge non-fatal-anr-6 into non-fatal-anr-7
markushi Nov 24, 2026
73b94fd
chore(anr): Merge non-fatal-anr-6 into non-fatal-anr-7
markushi Nov 24, 2026
0294bd4
chore(anr): Merge non-fatal-anr-6 into non-fatal-anr-7
markushi Nov 24, 2026
6c9a774
chore(anr): Merge non-fatal-anr-6 into non-fatal-anr-7
markushi Nov 24, 2026
a1de0f0
chore(anr): Merge non-fatal-anr-6 into non-fatal-anr-7
markushi Nov 24, 2026
72928f5
chore(anr): Merge non-fatal-anr-6 into non-fatal-anr-7
markushi Nov 24, 2026
2514bf5
chore(anr): Merge non-fatal-anr-6 into non-fatal-anr-7
markushi Nov 24, 2026
381b4f8
docs(anr): Mention cut hangs in the non-fatal ANR changelog entry
markushi Nov 24, 2026
6dbff4f
chore(anr): Merge non-fatal-anr-6 into non-fatal-anr-7
markushi Nov 24, 2026
0e6473b
chore(anr): Merge non-fatal-anr-6 into non-fatal-anr-7
markushi Nov 24, 2026
3ebb01b
chore(anr): Merge non-fatal-anr-6 into non-fatal-anr-7
markushi Nov 24, 2026
8f190b0
chore(anr): Merge non-fatal-anr-6 into non-fatal-anr-7
markushi Nov 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@

## Unreleased

### Features

- Report main-thread hangs as non-fatal ANR events: hangs that recover, and hangs that still block the main thread after 8 s, from Android 11 (API 30). Enable it with `options.nonFatalAnrSampleRate` (manifest: `io.sentry.anr.non-fatal.sample-rate`), and set the minimum hang duration with `options.nonFatalAnrThresholdMs` (default 700 ms, manifest: `io.sentry.anr.non-fatal.threshold-ms`). A fatal ANR that was already reported as a non-fatal ANR is not reported a second time ([#6726](https://github.com/getsentry/sentry-java/pull/6726))

### Improvements

- ANR profiling: the profile now starts when the main thread has been blocked for 300 ms instead of 1 s, so it also shows the beginning of the hang ([#6725](https://github.com/getsentry/sentry-java/pull/6725))

### Fixes

- Kotlin now sees `Attachment.getBytes()`, `Device.getArchs()`, `Spring.getActiveProfiles()` and `JsonSerializationUtils.bytesFrom(...)` as nullable, because `@Nullable` now annotates the returned array instead of its elements ([#6558](https://github.com/getsentry/sentry-java/pull/6558))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,9 @@
<meta-data
android:name="io.sentry.anr.profiling.sample-rate"
android:value="1.0" />
<meta-data
android:name="io.sentry.anr.non-fatal.sample-rate"
android:value="1.0" />
<meta-data
android:name="io.sentry.anr.enable-fingerprinting"
android:value="true" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,19 @@ fun ErrorsScreen() {
}
}
}
item {
SentryTraced("non_fatal_anr") {
OutlinedButton(
onClick = {
tagSampleAction("non_fatal_anr")
Thread.sleep(2000)
},
modifier = Modifier,
) {
Text("Non-fatal ANR (2 s)", maxLines = 2, overflow = TextOverflow.Ellipsis)
}
}
}
item {
SentryTraced("native_anr") {
OutlinedButton(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package io.sentry.uitest.android

import androidx.test.core.app.launchActivity
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SdkSuppress
import io.sentry.SentryLevel
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
import kotlin.test.assertTrue
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
@SdkSuppress(minSdkVersion = 30)
class NonFatalAnrTest : BaseUiTest() {
@Test
fun blockingMainThreadSendsOneNonFatalAnrEvent() {
initSentry(true) { it.nonFatalAnrSampleRate = 1.0 }
relayIdlingResource.increment()

launchActivity<EmptyActivity>().onActivity { Thread.sleep(2000) }

relay.assert {
assertFirstEnvelope {
val event = it.assertEvent()
it.assertNoOtherItems()

assertEquals(SentryLevel.ERROR, event.level)
val mechanismTypes = event.exceptions?.mapNotNull { e -> e.mechanism?.type }
assertTrue(mechanismTypes?.contains("NonFatalANR") == true, "mechanisms: $mechanismTypes")
assertTrue(event.exceptions!!.all { e -> e.mechanism?.isHandled == true })

val context = event.contexts["non_fatal_anr"] as Map<*, *>
val durationMs = assertNotNull(context["duration_ms"] as? Number)
assertTrue(durationMs.toLong() >= 700, "duration_ms: $durationMs")
}
assertNoOtherEnvelopes()
}
}
}
Loading