Repository navigation
fix(profiling): Don't crash when ProfilingManager can't be loaded - #6742
Merged
Merged
Conversation
Co-Authored-By: Roman Zavarnitsyn <roman.zavarnitsyn@sentry.io>
Contributor
PR risk: mediumFor commit Main concerns: reach, host performance, data sent to Sentry. This label is a hint for reviewers, not an approval. |
…g-manager-ncdfe Co-Authored-By: Roman Zavarnitsyn <roman.zavarnitsyn@sentry.io> # Conflicts: # CHANGELOG.md
📲 Install BuildsAndroid
|
…ndary Co-Authored-By: Roman Zavarnitsyn <roman.zavarnitsyn@sentry.io>
romtsn
marked this pull request as ready for review
November 23, 2026 14:24
romtsn
requested review from
0xadam-brown and
markushi
and removed request for
a team
November 23, 2026 14:25
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 090fa0f. Configure here.
markushi
approved these changes
Nov 23, 2026
Merged
1 task done
3 tasks done
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.

📜 Description
PerfettoProfilernow getsProfilingManagerthrough a guarded helper. IfgetSystemServicefails, the helper logs a warning and returnsnull.start()already handles anullmanager by returningfalse, so Perfetto continuous profiling turns itself off on that device instead of crashing the app.The catches follow the exception-handling rules in
AGENTS.md.getSystemServiceis a system-service boundary, so it gets a broad catch that callsExceptionUtils.rethrowIfFatalfirst.rethrowIfFatalrethrows everyLinkageError, so a separateLinkageErrorcatch comes before it. That catch covers the failure seen in the wild (NoClassDefFoundError) and a framework whoseProfilingManagerfails to initialize (ExceptionInInitializerError). Other fatal errors, such asOutOfMemoryError, still propagate. Comments at both catches say why they exist, and the Javadoc says what happens on failure: no profiles are recorded on that device.💡 Motivation and Context
Datadog found that some API 36 devices throw
NoClassDefFoundError: android.os.ProfilingManagerwhen their SDK resolves the service, and the error takes down the host app (DataDog/dd-sdk-android#4168). We have the same exposure. On API 35+,AndroidOptionsInitializeralways installsPerfettoContinuousProfiler, and its factory buildsPerfettoProfiler, which castcontext.getSystemService(Context.PROFILING_SERVICE)toProfilingManagerwith nothing to catch the error. That path runs fromstartProfiler()and from the chunk restart, and neither has a catch around it.Open question for review: on affected devices, failing to load
ProfilingManageris visible only in debug logs, andPerfettoContinuousProfilingis still reported as an integration. Is that enough, or should we surface it some other way?📝 Checklist
sendDefaultPIIis enabled.via roman.
--
View Session [Sentry]