Skip to content

fix(anr): Skip ANR profiling while a debugger is connected - #6389

Draft
markushi wants to merge 2 commits into
mainfrom
feat/skip-anr-debugger
Draft

markushi wants to merge 2 commits into
mainfrom
feat/skip-anr-debugger

Conversation

@markushi

Copy link
Copy Markdown
Member

📜 Description

AnrProfilingIntegration now checks Debug.isDebuggerConnected() at the start of every poll. While a debugger is connected, the integration treats the main thread as idle:

  • the state goes back to IDLE and the sample decision is cleared
  • the last main-thread execution timestamp is reset
  • no stack traces are collected

isDebuggerConnected() is a protected method because Robolectric's ShadowDebug cannot set the debugger state. Tests override the method instead. This adds one entry to sentry-android-core.api.

💡 Motivation and Context

Align with ANRWatchDog, which already ignores this.

💚 How did you test it?

  • New unit test debugger pauses are treated as idle. It holds the debugger connected for a long virtual-clock gap, then disconnects it and makes sure that the state stays IDLE and no stacks are collected.
  • All AnrProfilingIntegrationTest tests pass.

📝 Checklist

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🤖 Generated with Claude Code

@github-actions

Copy link
Copy Markdown
Contributor
Fails
🚫 Please consider adding a changelog entry for the next release.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

### Fixes

- Skip ANR profiling while a debugger is connected ([#6389](https://github.com/getsentry/sentry-java/pull/6389))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description or adding a skip-changelog label.

Generated by 🚫 dangerJS against a26b3e1

@sentry

sentry Bot commented Oct 27, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.62.0 (1) release

⚙️ sentry-android Build Distribution Settings

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant