fix(breadcrumbs): Unregister SystemEventsBroadcastReceiver when entering background#4338
Merged
fix(breadcrumbs): Unregister SystemEventsBroadcastReceiver when entering background#4338
Conversation
romtsn
commented
Apr 15, 2025
| SentryLevel.INFO, | ||
| "androidx.lifecycle is not available, AppLifecycleIntegration won't be installed", | ||
| e); | ||
| SentryLevel.WARNING, |
Member
Author
There was a problem hiding this comment.
Unrelated to this PR, but I just noticed while testing no androidx.lifecycle case that it's noisy and decided to change that
Contributor
Performance metrics 🚀
|
markushi
approved these changes
Apr 16, 2025
Member
markushi
left a comment
There was a problem hiding this comment.
Awesome, I left two small comments!
...ry-android-core/src/main/java/io/sentry/android/core/SystemEventsBreadcrumbsIntegration.java
Outdated
Show resolved
Hide resolved
...ry-android-core/src/main/java/io/sentry/android/core/SystemEventsBreadcrumbsIntegration.java
Show resolved
Hide resolved
romtsn
added a commit
that referenced
this pull request
Jul 8, 2025
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
Some background
Android 14 introduced new behavior for broadcast receivers, and our SystemEvents receiver (used to add breadcrumbs like screen on/off, airplane mode change, etc.) is falling under this. What's happening is the process gets cached for some period of time (can be hours or days) and after getting uncached it receives all those pending broadcasts in a quick succession which most likely causes ANRs. This also correlates with the numbers we see in SDKCD where the biggest number of ANRs is coming from Android 14+.
I did some tests locally and it is indeed happening as described on the screenshot.
SystemEventsBreadcrumbsIntegrationis now lifecycle-aware:💡 Motivation and Context
Closes #4294
Internal customer case
💚 How did you test it?
Manually + automated
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps