fix(jni): ensure that the ScopesAdapter instance is released after use#3411
Merged
Conversation
…dcrumb and setUser methods This commit refactors the SentryNativeJava class to improve the retrieval of native options in the addBreadcrumb and setUser methods. The changes ensure that the ScopesAdapter instance is obtained once and used consistently, enhancing code clarity and reducing redundancy. Additionally, null checks are maintained to prevent potential runtime errors.
Contributor
Android Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 93b7728 | 475.28 ms | 489.13 ms | 13.86 ms |
| 81f83eb | 471.40 ms | 522.14 ms | 50.74 ms |
| 79f6b41 | 469.66 ms | 525.90 ms | 56.24 ms |
| b6c8720 | 457.41 ms | 519.04 ms | 61.63 ms |
| bfabaf2 | 408.04 ms | 444.38 ms | 36.34 ms |
| 40c8f93 | 417.10 ms | 482.60 ms | 65.50 ms |
| 0fb3800 | 465.64 ms | 536.77 ms | 71.13 ms |
| c26ed0a | 465.52 ms | 476.38 ms | 10.86 ms |
| cf443d2 | 464.64 ms | 479.04 ms | 14.40 ms |
| a10aff4 | 488.19 ms | 515.02 ms | 26.83 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 93b7728 | 6.54 MiB | 7.69 MiB | 1.15 MiB |
| 81f83eb | 6.54 MiB | 7.69 MiB | 1.15 MiB |
| 79f6b41 | 6.54 MiB | 7.69 MiB | 1.15 MiB |
| b6c8720 | 6.54 MiB | 7.69 MiB | 1.15 MiB |
| bfabaf2 | 13.93 MiB | 15.06 MiB | 1.13 MiB |
| 40c8f93 | 13.93 MiB | 15.00 MiB | 1.06 MiB |
| 0fb3800 | 6.54 MiB | 7.69 MiB | 1.15 MiB |
| c26ed0a | 13.93 MiB | 14.93 MiB | 1.00 MiB |
| cf443d2 | 13.93 MiB | 15.00 MiB | 1.06 MiB |
| a10aff4 | 13.93 MiB | 15.06 MiB | 1.13 MiB |
Contributor
iOS Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| f761369 | 1261.69 ms | 1277.82 ms | 16.12 ms |
| 6b69699 | 1254.80 ms | 1273.31 ms | 18.52 ms |
| 819c1e7 | 1250.59 ms | 1249.08 ms | -1.51 ms |
| e0c8591 | 1259.85 ms | 1257.31 ms | -2.54 ms |
| 2cb90b9 | 1272.90 ms | 1285.55 ms | 12.66 ms |
| e04b24b | 1230.22 ms | 1233.90 ms | 3.67 ms |
| 8541716 | 1270.18 ms | 1271.80 ms | 1.62 ms |
| 9b99523 | 1256.06 ms | 1270.33 ms | 14.27 ms |
| 393f8ec | 1256.45 ms | 1259.60 ms | 3.16 ms |
| e45c0e1 | 1269.08 ms | 1278.83 ms | 9.75 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| f761369 | 7.86 MiB | 9.44 MiB | 1.58 MiB |
| 6b69699 | 7.86 MiB | 9.44 MiB | 1.58 MiB |
| 819c1e7 | 5.53 MiB | 6.00 MiB | 479.96 KiB |
| e0c8591 | 5.53 MiB | 5.96 MiB | 444.86 KiB |
| 2cb90b9 | 7.86 MiB | 9.54 MiB | 1.69 MiB |
| e04b24b | 5.53 MiB | 6.00 MiB | 480.00 KiB |
| 8541716 | 5.53 MiB | 6.00 MiB | 479.96 KiB |
| 9b99523 | 7.86 MiB | 9.44 MiB | 1.58 MiB |
| 393f8ec | 5.53 MiB | 6.01 MiB | 488.10 KiB |
| e45c0e1 | 7.86 MiB | 9.44 MiB | 1.58 MiB |
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
Currently it's not being released and may end up causing a crash due to stale references.
💡 Motivation and Context
Fixes #3410
💚 How did you test it?
Hard to test since it relies on GC.
I have been verifying nothing is crashing by stress testing with thousands of added breadcrumbs in a tight loop.
📝 Checklist
sendDefaultPiiis enabled🔮 Next steps