Add setup_profiling_device.sh to disable the profiling rate limiter - #253
Merged
Conversation
On API 35+ the Sentry SDK uses the platform ProfilingManager (Perfetto) backend. The Android Framework rate limits profiling requests there and does not guarantee they are fulfilled, so profiles come back sparse or missing when testing locally or generating automated demo data. This wraps the workaround from the Sentry profiling docs: adb shell device_config put profiling_testing rate_limiter.disabled true The script adds the bits that are easy to miss by hand: - skips API < 35, where the legacy profiler is used and the framework rate limiter does not apply - pins the namespace with set_sync_disabled_for_tests first, so the platform config updater cannot silently revert the flag mid-session - reads the flag back and fails loudly if it did not stick, which some locked-down retail devices will do - handles device selection when more than one is attached Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #253 +/- ##
=====================================
Coverage 0.00% 0.00%
=====================================
Files 16 16
Lines 883 883
Branches 67 67
=====================================
Misses 883 883 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
markushi
approved these changes
Aug 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
setup_profiling_device.sh, a one-shot helper that disables the Android Framework profiling rate limiter on a connected device or emulator.On API 35+ the Sentry SDK uses the platform
ProfilingManager(Perfetto) backend. The framework rate limits profiling requests there — per the profiling limitations docs, they are "not guaranteed to be fulfilled." The result is sparse or missing profiles when testing locally or generating automated demo data, which reads as a broken SDK when it isn't.The docs give a one-line workaround:
adb shell device_config put profiling_testing rate_limiter.disabled trueThis script wraps it with the parts that are easy to get wrong by hand:
minSdkVersionis 21.device_config set_sync_disabled_for_tests persistentfirst, so the platform config updater can't resync and silently revert the flag mid-session.$ANDROID_HOME,$ANDROID_SDK_ROOT, thesdk.dirinlocal.propertiesthat Gradle already reads, and the default macOS SDK path — Android Studio doesn't putplatform-toolsonPATH.Why this matters now
This is the same framework rate limiter that gates the Perfetto profiling path newly enabled by SDK 8.51.0 (#247). This app leans on profiling harder than most demos —
io.sentry.traces.profiling.session-sample-rate,.lifecycle, and.start-on-app-startin the manifest, plusInitContentProviderwriting an app-start profiling config so the profiler runs beforeSentry.init.Also
Adds a step to the README Run section pointing at the script.
Note on automated data generation
The TDA harness that drives the released APK lives outside this repo, so this script can't wire itself in there. If that harness runs on a managed device farm (Firebase Test Lab, SauceLabs, BrowserStack) where arbitrary pre-launch
adbisn't available, API 35+ profiling data will stay rate-limited regardless — worth knowing before treating it as an SDK problem.Testing
Verified against two live emulators — a
google_apisAPI 36 AVD and an existing API 34 one:device_configcalls run; flag reads backtruenull)PATH,ANDROID_HOMEunsetlocal.propertiesConfirmed independently of the script's own output:
Two bugs were caught and fixed during this verification: adb resolution failing when
platform-toolsisn't onPATH(the common Android Studio setup), and a typo'd serial hanging forever inadb wait-for-devicewith no output.🤖 Generated with Claude Code