fix: Rare battery breadcrumbs crash#3582
Merged
Merged
Conversation
We see rare crashes in getBatteryStatus of SentrySystemEventBreadcrumbs. The object of an NSNotification can be nil, and we didn't check for that edge case. This PR fixes that problem and uses dictionaryWithCapacity to slightly reduce the memory footprint for getBatteryStatus. This change is not guaranteed to fix these rare crashes, but it won't do any harm.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3582 +/- ##
=============================================
+ Coverage 89.285% 89.289% +0.003%
=============================================
Files 529 529
Lines 57753 57764 +11
Branches 20670 20673 +3
=============================================
+ Hits 51565 51577 +12
- Misses 5277 5281 +4
+ Partials 911 906 -5
... and 14 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Contributor
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| e324230 | 1225.84 ms | 1250.40 ms | 24.57 ms |
| 31208ed | 1258.36 ms | 1263.86 ms | 5.50 ms |
| 16450b8 | 1196.33 ms | 1217.26 ms | 20.93 ms |
| 56ec5d0 | 1194.39 ms | 1236.94 ms | 42.55 ms |
| 7cd187e | 1229.02 ms | 1233.06 ms | 4.04 ms |
| 407ff99 | 1190.89 ms | 1237.18 ms | 46.29 ms |
| d413317 | 1203.27 ms | 1215.02 ms | 11.75 ms |
| 881a955 | 1242.24 ms | 1247.85 ms | 5.61 ms |
| 98cca71 | 1226.66 ms | 1242.94 ms | 16.28 ms |
| b9a9ffd | 1221.18 ms | 1235.37 ms | 14.19 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| e324230 | 22.85 KiB | 408.87 KiB | 386.02 KiB |
| 31208ed | 20.76 KiB | 435.26 KiB | 414.50 KiB |
| 16450b8 | 22.85 KiB | 410.98 KiB | 388.13 KiB |
| 56ec5d0 | 20.76 KiB | 414.44 KiB | 393.68 KiB |
| 7cd187e | 20.76 KiB | 401.65 KiB | 380.89 KiB |
| 407ff99 | 20.76 KiB | 427.86 KiB | 407.10 KiB |
| d413317 | 20.76 KiB | 420.71 KiB | 399.95 KiB |
| 881a955 | 22.85 KiB | 407.63 KiB | 384.78 KiB |
| 98cca71 | 22.85 KiB | 411.14 KiB | 388.29 KiB |
| b9a9ffd | 21.58 KiB | 418.43 KiB | 396.85 KiB |
Previous results on branch: fix/battery-notification-nil-check
Startup times
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 33e820d | 1210.41 ms | 1231.75 ms | 21.34 ms |
| ae790ff | 1241.92 ms | 1261.14 ms | 19.22 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 33e820d | 21.58 KiB | 417.94 KiB | 396.36 KiB |
| ae790ff | 21.58 KiB | 418.00 KiB | 396.42 KiB |
kahest
reviewed
Jan 29, 2024
kahest
left a comment
Contributor
There was a problem hiding this comment.
LGTM, just one small suggestion
thx for the good PR description and the opportunistic refactor 👍
kahest
approved these changes
Jan 29, 2024
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
We see rare crashes in getBatteryStatus of SentrySystemEventBreadcrumbs. The object of an NSNotification can be nil, and we didn't check for that edge case. This PR fixes that problem and uses dictionaryWithCapacity to slightly reduce the memory footprint for getBatteryStatus. This change is not guaranteed to fix these rare crashes, but it won't do any harm.
Internal SDK crashes
💡 Motivation and Context
Came up while investigating #3341.
💚 How did you test it?
Unit testing.
📝 Checklist
You have to check all boxes before merging:
sendDefaultPIIis enabled.🔮 Next steps