Repository navigation
fix(feedback): Stop shake detection from leaking the first resumed Activity - #6686
Merged
Merged
Conversation
…tivity SentryShakeDetector caches its SensorManager the first time it initializes. When an Activity resumed before the background warm-up ran, that manager came from the Activity, and an Activity's SensorManager keeps a reference to it. The long-lived FeedbackShakeIntegration then held the destroyed Activity for the rest of the process. Always resolve the SensorManager from the application context. Fixes JAVA-847 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
PR risk: mediumFor commit Main concerns: reach. This label is a hint for reviewers, not an approval. |
runningcode
marked this pull request as ready for review
November 19, 2026 16:58
runningcode
requested review from
markushi and
romtsn
and removed request for
a team
November 19, 2026 16:58
📲 Install BuildsAndroid
|
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
SentryShakeDetectornow gets itsSensorManagerfrom the application context, whichever context the caller passes in.💡 Motivation and Context
LeakCanary found a destroyed
MainActivityin the Android sample, held throughFeedbackShakeIntegration.shakeDetector→SentryShakeDetector.sensorManager→SystemSensorManager.mContext.The detector caches its
SensorManagerthe first time it initializes. An Activity'sgetSystemService(SENSOR_SERVICE)returns a manager tied to that Activity. So when an Activity resumed before the background warm-up from #5784 ran, the app-lifetime integration held that Activity forever.💚 How did you test it?
Added a unit test that starts the detector with an Activity-like context.
📝 Checklist
sendDefaultPIIis enabled.🤖 Generated with Claude Code