Skip to content

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

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

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

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

@antonis antonis marked this pull request as ready for review May 7, 2026 08:27
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

Android (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 416.40 ms 490.16 ms 73.76 ms
Size 48.30 MiB 53.48 MiB 5.18 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
0d9949d+dirty 414.88 ms 428.68 ms 13.81 ms
3817909+dirty 357.52 ms 391.52 ms 34.00 ms
04207c4+dirty 395.40 ms 456.55 ms 61.15 ms
4b87b12+dirty 356.23 ms 399.86 ms 43.63 ms
890d145+dirty 486.42 ms 514.85 ms 28.43 ms
3ce5254+dirty 373.90 ms 427.84 ms 53.94 ms
4953e94+dirty 398.80 ms 431.81 ms 33.01 ms
5c1e987+dirty 444.71 ms 475.13 ms 30.42 ms
44c8b3f+dirty 492.13 ms 563.47 ms 71.34 ms
df5d108+dirty 434.82 ms 447.39 ms 12.57 ms

App size

Revision Plain With Sentry Diff
0d9949d+dirty 43.94 MiB 48.99 MiB 5.05 MiB
3817909+dirty 43.94 MiB 48.94 MiB 5.00 MiB
04207c4+dirty 43.94 MiB 48.98 MiB 5.04 MiB
4b87b12+dirty 43.94 MiB 49.00 MiB 5.06 MiB
890d145+dirty 43.94 MiB 49.00 MiB 5.06 MiB
3ce5254+dirty 43.94 MiB 48.98 MiB 5.04 MiB
4953e94+dirty 43.94 MiB 48.94 MiB 5.00 MiB
5c1e987+dirty 43.94 MiB 48.94 MiB 5.00 MiB
44c8b3f+dirty 48.30 MiB 53.46 MiB 5.15 MiB
df5d108+dirty 43.94 MiB 48.94 MiB 5.00 MiB

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

Android (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 407.29 ms 469.31 ms 62.02 ms
Size 48.30 MiB 53.48 MiB 5.18 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
0d9949d+dirty 403.57 ms 437.00 ms 33.43 ms
3817909+dirty 406.67 ms 416.58 ms 9.91 ms
04207c4+dirty 459.19 ms 518.54 ms 59.35 ms
4b87b12+dirty 421.82 ms 413.60 ms -8.22 ms
890d145+dirty 504.54 ms 491.55 ms -12.99 ms
3ce5254+dirty 410.57 ms 448.48 ms 37.91 ms
4953e94+dirty 442.02 ms 456.52 ms 14.50 ms
5c1e987+dirty 423.52 ms 471.64 ms 48.12 ms
44c8b3f+dirty 414.20 ms 457.28 ms 43.08 ms
df5d108+dirty 527.06 ms 603.58 ms 76.52 ms

App size

Revision Plain With Sentry Diff
0d9949d+dirty 43.75 MiB 48.13 MiB 4.37 MiB
3817909+dirty 43.75 MiB 48.08 MiB 4.33 MiB
04207c4+dirty 43.75 MiB 48.12 MiB 4.37 MiB
4b87b12+dirty 43.75 MiB 48.14 MiB 4.39 MiB
890d145+dirty 43.75 MiB 48.14 MiB 4.39 MiB
3ce5254+dirty 43.75 MiB 48.12 MiB 4.37 MiB
4953e94+dirty 43.75 MiB 48.08 MiB 4.33 MiB
5c1e987+dirty 43.75 MiB 48.08 MiB 4.33 MiB
44c8b3f+dirty 48.30 MiB 53.46 MiB 5.15 MiB
df5d108+dirty 43.75 MiB 48.08 MiB 4.33 MiB

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