Skip to content

Guard continuous profiling on API < 35#5290

Draft
43jay wants to merge 1 commit intomainfrom
cursor/fix-api35-continuous-profiler-guard-5932
Draft

Guard continuous profiling on API < 35#5290
43jay wants to merge 1 commit intomainfrom
cursor/fix-api35-continuous-profiler-guard-5932

Conversation

@43jay
Copy link
Copy Markdown
Collaborator

@43jay 43jay commented Apr 13, 2026

📜 Description

  • add an explicit API level guard in AndroidOptionsInitializer.setupProfiler so continuous profiling is not initialized below API 35
  • add the same guard in SentryPerformanceProvider.createAndStartContinuousProfiler for app-start continuous profiling
  • add regression tests covering API < 35 behavior in:
    • AndroidOptionsInitializerTest
    • SentryPerformanceProviderTest

💡 Motivation and Context

Continuous profiling can be enabled by options, but API < 35 should not initialize the API-35-only implementation path. Without an explicit runtime guard, lazy initialization can still reach classes that depend on API 35 (ProfilingManager path), leading to runtime crashes on older Android versions.

💚 How did you test it?

  • Added unit tests asserting continuous profiler remains NoOpContinuousProfiler / not started on API < 35.
  • Attempted to run targeted tests:
    • ./gradlew :sentry-android-core:testDebugUnitTest --tests="*AndroidOptionsInitializerTest*" --tests="*SentryPerformanceProviderTest*"
  • In this cloud environment, test execution is blocked by missing Android SDK configuration (ANDROID_HOME / sdk.dir).

📝 Checklist

  • I added GH Issue ID & Linear ID
  • 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.

🔮 Next steps

  • Re-run the targeted Android unit tests in an environment with Android SDK configured.
Open in Web Open in Cursor 

Co-authored-by: Matthew Jay Williams <43jay@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

Semver Impact of This PR

None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Internal Changes 🔧

  • (deps) Update Native SDK to v0.13.6 by github-actions in #5277

Other

  • Guard continuous profiling on API < 35 by 43jay in #5290

🤖 This preview updates automatically when you update the PR.

@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

### Features

- Guard continuous profiling on API < 35 ([#5290](https://github.com/getsentry/sentry-java/pull/5290))

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 0ed09ae

@romtsn
Copy link
Copy Markdown
Member

romtsn commented Apr 14, 2026

@43jay should this target your branch with ProfilingManager instead of main?

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.

3 participants