Skip to content

fix(android): Include CPU and memory measurements in Android profiles - #6891

Merged
antonis merged 3 commits into
mainfrom
fix/android-profile-cpu-memory-measurements
Oct 15, 2026
Merged

antonis merged 3 commits into
mainfrom
fix/android-profile-cpu-memory-measurements

Conversation

@antonis

@antonis antonis commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

This PR starts the SDK's composite performance collector (options.getCompositePerformanceCollector(), which sentry-android already sets up with AndroidCpuCollector and AndroidMemoryCollector) alongside the Android profiler, and passes its data to endAndCollect. The collector samples on its own timer thread, so the JS thread does no extra work.

Based on the patch suggested by @meshelton in the issue 🙏

💡 Motivation and Context

Fixes #6887

💚 How did you test it?

Screenshot 2026-10-15 at 13 59 10

📝 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.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.
  • No breaking changes.

🔮 Next steps

antonis and others added 2 commits October 15, 2026 10:05
AndroidProfiler.endAndCollect was always passed null, so Android profiles
never carried cpu_usage or memory_footprint. Start the SDK's composite
performance collector alongside the Android profiler and pass its data to
endAndCollect. Collections started by id never time out, so stop it on
every exit path (stop, invalidate, start failure, restart).

Fixes #6887

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 15, 2026 •

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


  • fix(android): Include CPU and memory measurements in Android profiles by antonis in #6891
  • fix(android): Include CPU and memory measurements in Android profiles by antonis in #6891
  • chore(deps): update Cocoa SDK to v9.30.2 by github-actions in #6888
  • test(e2e): iOS crash-handler screenshot no-freeze regression check by antonis in #6839
  • fix(replay): Attach Session Replay buffer to user feedback by antonis in #6870
  • chore(deps): update Android SDK to v8.61.0 by github-actions in #6889
  • chore(deps): bump futureware-tech/simulator-action from 5 to 6 by dependabot in #6878
  • chore(deps): bump getsentry/craft from 2.33.1 to 2.34.1 by dependabot in #6880
  • chore(deps): bump actions/download-artifact from 8.0.1 to 8.0.2 by dependabot in #6879
  • chore(deps): bump ruby/setup-ruby from 1.327.0 to 1.328.0 by dependabot in #6877
  • chore(deps): bump the codeql-action group with 3 updates by dependabot in #6876
  • build(deps): Pin tinypool to patched 2.x to resolve prototype-pollution advisories by antonis in #6869
  • build(deps): Bump sharp, shell-quote and smol-toml to patched versions by antonis in #6868
  • fix(core): Do not mark sendDefaultPii as deprecated in React Native options by alwx in #6864
  • ci(ios): Archive the SwiftPM app to catch xcframework signature collisions by alwx in #6871
  • feat(core): Support applicationKey and moduleMetadata in Metro config by alwx in #6863
  • chore(deps): update JavaScript SDK to v10.76.2 by antonis in #6866
  • ci(core): Guard the "sideEffects": false contract with a lint check by antonis in #6836
  • chore(deps): bump nx from 22.7.7 to 22.7.12 by dependabot in #6857
  • chore(deps): bump compression from 1.7.5 to 1.8.2 by dependabot in #6856
  • chore(deps): bump postcss-selector-parser from 7.1.4 to 7.1.6 by dependabot in #6855
  • chore(deps): bump source-map-js from 1.2.1 to 1.2.2 by dependabot in #6854
  • chore(deps): bump proxy-addr from 2.0.7 to 2.0.8 by dependabot in #6853
  • chore(deps): bump handlebars from 4.7.9 to 4.7.10 by dependabot in #6862

Plus 1 more


🤖 This preview updates automatically when you update the PR.

@antonis antonis added the ready-to-merge Triggers the full CI test suite label Oct 15, 2026

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

invalidate() could claim cleanup after isProfiling was set but before the
collection id was published, leaving an id-based collection that never
times out. Re-check isProfiling after publishing the id, and stop the
collection unconditionally in the startProfiling() failure unwind.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sentry

sentry Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

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

⚙️ sentry-react-native Build Distribution Settings

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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 45d96f3. Configure here.

@github-actions

Copy link
Copy Markdown
Contributor

Android (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 516.59 ms 564.14 ms 47.55 ms
Size 50.56 MiB 56.62 MiB 6.06 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
0307fa4+dirty 454.16 ms 518.35 ms 64.18 ms
4953e94+dirty 442.02 ms 456.52 ms 14.50 ms
bc8f61e+dirty 442.98 ms 506.56 ms 63.58 ms
3817909+dirty 406.67 ms 416.58 ms 9.91 ms
4b87b12+dirty 421.82 ms 413.60 ms -8.22 ms
ef27341+dirty 412.94 ms 443.98 ms 31.04 ms
853723c+dirty 405.54 ms 440.08 ms 34.54 ms
2cac31b+dirty 440.48 ms 466.19 ms 25.71 ms
3b6e9f9+dirty 442.70 ms 486.44 ms 43.74 ms
4e0ba9c+dirty 452.84 ms 473.36 ms 20.52 ms

App size

Revision Plain With Sentry Diff
0307fa4+dirty 49.74 MiB 54.81 MiB 5.07 MiB
4953e94+dirty 43.75 MiB 48.08 MiB 4.33 MiB
bc8f61e+dirty 49.74 MiB 55.09 MiB 5.35 MiB
3817909+dirty 43.75 MiB 48.08 MiB 4.33 MiB
4b87b12+dirty 43.75 MiB 48.14 MiB 4.39 MiB
ef27341+dirty 48.30 MiB 53.54 MiB 5.24 MiB
853723c+dirty 48.30 MiB 53.58 MiB 5.28 MiB
2cac31b+dirty 49.74 MiB 55.37 MiB 5.63 MiB
3b6e9f9+dirty 48.30 MiB 53.54 MiB 5.23 MiB
4e0ba9c+dirty 48.30 MiB 53.49 MiB 5.19 MiB

@github-actions

Copy link
Copy Markdown
Contributor

Android (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 444.48 ms 453.42 ms 8.94 ms
Size 50.56 MiB 56.62 MiB 6.06 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
7ff4d0f+dirty 403.38 ms 427.06 ms 23.68 ms
635676f+dirty 420.43 ms 428.23 ms 7.80 ms
ae37560+dirty 428.96 ms 456.86 ms 27.90 ms
df5d108+dirty 434.82 ms 447.39 ms 12.57 ms
0b5120f+dirty 413.75 ms 468.86 ms 55.11 ms
6acdf1d+dirty 417.34 ms 454.88 ms 37.54 ms
b47fb86+dirty 440.89 ms 500.73 ms 59.84 ms
4966363+dirty 415.67 ms 448.60 ms 32.93 ms
a0a3177+dirty 427.85 ms 473.94 ms 46.09 ms
c0bc3e1+dirty 570.52 ms 632.06 ms 61.54 ms

App size

Revision Plain With Sentry Diff
7ff4d0f+dirty 48.30 MiB 53.60 MiB 5.30 MiB
635676f+dirty 50.56 MiB 56.46 MiB 5.90 MiB
ae37560+dirty 48.30 MiB 53.60 MiB 5.29 MiB
df5d108+dirty 43.94 MiB 48.94 MiB 5.00 MiB
0b5120f+dirty 48.30 MiB 53.58 MiB 5.28 MiB
6acdf1d+dirty 49.74 MiB 55.09 MiB 5.34 MiB
b47fb86+dirty 50.56 MiB 56.59 MiB 6.03 MiB
4966363+dirty 48.30 MiB 53.54 MiB 5.24 MiB
a0a3177+dirty 49.74 MiB 55.37 MiB 5.63 MiB
c0bc3e1+dirty 50.56 MiB 56.62 MiB 6.06 MiB

@antonis
antonis marked this pull request as ready for review October 15, 2026 08:53

@alwx alwx left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For me it's fine but it's 100% Java + Kotlin code.
Might be a good idea to ask someone from Android devs to review this one.

@antonis
antonis merged commit 250db5e into main Oct 15, 2026
92 of 94 checks passed
@antonis
antonis deleted the fix/android-profile-cpu-memory-measurements branch October 15, 2026 11:59
@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

- Include CPU and memory measurements in Android profiles ([#6891](https://github.com/getsentry/sentry-react-native/pull/6891))

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 45d96f3

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.

Android profiles never include CPU/memory measurements: endAndCollect is always passed null

2 participants