Skip to content

perf(android): Replace RNSentryFrameDelayCollector with sentry-java getFramesDelay API#6074

Draft
antonis wants to merge 9 commits intomainfrom
feat/android-frames-delay-api
Draft

perf(android): Replace RNSentryFrameDelayCollector with sentry-java getFramesDelay API#6074
antonis wants to merge 9 commits intomainfrom
feat/android-frames-delay-api

Conversation

@antonis
Copy link
Copy Markdown
Contributor

@antonis antonis commented Apr 30, 2026

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

Replaces the custom RNSentryFrameDelayCollector (listener-based frame delay collector) with a direct call to the new SentryFrameMetricsCollector.getFramesDelay() API added in sentry-java#5248 (commit 61659b6).

Changes:

  • Delete RNSentryFrameDelayCollector.java (~130 lines) — no longer needed
  • Simplify fetchNativeFramesDelay() to call collector.getFramesDelay(startNanos, endNanos) directly
  • Replace custom listener with a no-op listener registration to ensure frame metrics collection stays active
  • Add stopFrameMetricsCollection() helper for clean lifecycle management

💡 Motivation and Context

Closes #5908

The previous implementation in #5907 duplicated work already done internally by sentry-java:

  • Double listener callbacks: Every frame triggered two listener callbacks on the UI thread
  • Double storage: Two separate data structures holding the same per-frame delay records
  • Redundant computation: Both collectors computed delay overlap independently

With sentry-java now exposing a queryable API (mirroring iOS's getFramesDelaySPI), we can eliminate all of this overhead.

💚 How did you test it?

CI, Manual

📝 Checklist

  • I added tests to verify 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.
  • All tests passing
  • No breaking changes

🔮 Next steps

…etFramesDelay API

Uses the new queryable `SentryFrameMetricsCollector.getFramesDelay()` API
from sentry-java (getsentry/sentry-java#5248, commit 61659b6) instead of
maintaining a custom listener-based collector.

Closes #5908

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 30, 2026

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).


  • perf(android): Replace RNSentryFrameDelayCollector with sentry-java getFramesDelay API by antonis in #6074
  • chore(deps): update Android SDK to v8.41.0 by github-actions in #6104
  • chore(deps): update Cocoa SDK to v9.12.1 by github-actions in #6105
  • build(core): Add public API surface tracking with api-extractor by antonis in #6093
  • chore(deps): bump axios from 1.15.0 to 1.16.0 by dependabot in #6091
  • ci: Add workflow to notify issues when fix is released by antonis in #6089
  • ci: Add Danger check to warn about auth token handling changes by antonis in #6087
  • Fix PNPM iOS Upload Debug Symbol fail in EAS Build by alwx in #6086
  • chore(deps): update Sentry Android Gradle Plugin to v6.6.0 by github-actions in #6085
  • fix(e2e): Remove flaky iOS replay assertion from captureReplay test by antonis in #6072
  • chore(deps): bump github/codeql-action from 4.35.2 to 4.35.3 by dependabot in #6078
  • fix: Prevent shell injection vulnerability in GitHub Actions workflow by fix-it-felix-sentry in #6077
  • chore(deps): update Maestro to v2.5.1 by github-actions in #6075

🤖 This preview updates automatically when you update the PR.

Copy link
Copy Markdown
Contributor Author

@antonis antonis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marking as blocked till an Android bump containing the changes in getsentry/sentry-java#5248 is shipped

@antonis antonis added ready-to-merge Triggers the full CI test suite and removed Blocked labels May 7, 2026
Copy link
Copy Markdown
Contributor Author

@antonis antonis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unblocking with #6104

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sentry
Copy link
Copy Markdown

sentry Bot commented May 7, 2026

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
Sentry RN io.sentry.reactnative.sample 8.10.0 (86) Release

⚙️ sentry-react-native Build Distribution Settings

Comment thread packages/core/android/src/main/java/io/sentry/react/RNSentryModuleImpl.java Outdated
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6b4adee. Configure here.

antonis and others added 2 commits May 7, 2026 10:13
Tests cover: null collector, valid delay result, negative delay result,
future timestamps, and zero delay with no slow frames.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Comment thread packages/core/android/src/main/java/io/sentry/react/RNSentryModuleImpl.java Outdated
…ceeds

Prevents getFramesDelay() from being called without an active listener
when startCollection() returns null.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Triggers the full CI test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf(android): Replace RNSentryFrameDelayCollector with queryable sentry-java API

1 participant