Repository navigation
fix(android): Include CPU and memory measurements in Android profiles - #6891
Conversation
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>
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog.
Plus 1 more 🤖 This preview updates automatically when you update the PR. |
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>
📲 Install BuildsAndroid
|
There was a problem hiding this comment.
✅ 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.
Android (legacy) Performance metrics 🚀
|
| 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 |
Android (new) Performance metrics 🚀
|
| 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 |
alwx
left a comment
There was a problem hiding this comment.
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.
Instructions and example for changelogPlease add an entry to 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 |
📢 Type of change
📜 Description
This PR starts the SDK's composite performance collector (
options.getCompositePerformanceCollector(), which sentry-android already sets up withAndroidCpuCollectorandAndroidMemoryCollector) alongside the Android profiler, and passes its data toendAndCollect. 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?
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps