fix(android): identify and correctly structure Java/Kotlin frames…#5116
fix(android): identify and correctly structure Java/Kotlin frames…#5116supervacuus wants to merge 13 commits into
Conversation
…mixed Tombstone stack traces
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. Bug Fixes 🐛
🤖 This preview updates automatically when you update the PR. |
|
While testing this manually, it became apparent that the SDK-level In the event, only the JNI frame is kept as
Not sure if this is really a problem, but it certainly was unexpected. Please also keep in mind that this PR should be blocked for merging/releasing until UI issues are fixed here: getsentry/sentry#107318. For instance, currently, there is no stable rendering between native and Java frames. |
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| abfcc92 | 309.54 ms | 380.32 ms | 70.78 ms |
| 4e3e79d | 328.10 ms | 395.64 ms | 67.54 ms |
| 8c1fb22 | 316.62 ms | 352.78 ms | 36.16 ms |
| b67bb28 | 307.59 ms | 341.24 ms | 33.65 ms |
| d15471f | 361.89 ms | 378.07 ms | 16.18 ms |
| 22f4345 | 313.52 ms | 364.96 ms | 51.44 ms |
| 6727e14 | 337.22 ms | 373.94 ms | 36.71 ms |
| fc5ccaf | 322.49 ms | 405.25 ms | 82.76 ms |
| 22f4345 | 314.79 ms | 375.02 ms | 60.23 ms |
| 2195398 | 319.02 ms | 342.38 ms | 23.36 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| abfcc92 | 1.58 MiB | 2.13 MiB | 557.31 KiB |
| 4e3e79d | 0 B | 0 B | 0 B |
| 8c1fb22 | 0 B | 0 B | 0 B |
| b67bb28 | 0 B | 0 B | 0 B |
| d15471f | 1.58 MiB | 2.13 MiB | 559.54 KiB |
| 22f4345 | 1.58 MiB | 2.29 MiB | 719.83 KiB |
| 6727e14 | 1.58 MiB | 2.28 MiB | 718.64 KiB |
| fc5ccaf | 1.58 MiB | 2.13 MiB | 557.54 KiB |
| 22f4345 | 1.58 MiB | 2.29 MiB | 719.83 KiB |
| 2195398 | 0 B | 0 B | 0 B |
📲 Install BuildsAndroid
|
markushi
left a comment
There was a problem hiding this comment.
LGTM, nice!, I'll not marked it as approved, as we should get the frontend changes in first.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Tests expect empty string but production code returns null
- Updated both bare-function Tombstone parser tests to assert
nullmodule values, matching production behavior when no module can be extracted.
- Updated both bare-function Tombstone parser tests to assert
Or push these changes by commenting:
@cursor push 59609e9828
Preview (59609e9828)
diff --git a/sentry-android-core/src/test/java/io/sentry/android/core/internal/tombstone/TombstoneParserTest.kt b/sentry-android-core/src/test/java/io/sentry/android/core/internal/tombstone/TombstoneParserTest.kt
--- a/sentry-android-core/src/test/java/io/sentry/android/core/internal/tombstone/TombstoneParserTest.kt
+++ b/sentry-android-core/src/test/java/io/sentry/android/core/internal/tombstone/TombstoneParserTest.kt
@@ -13,6 +13,7 @@
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
+import kotlin.test.assertNull
import org.mockito.kotlin.mock
class TombstoneParserTest {
@@ -496,7 +497,7 @@
val frame = event.threads!![0].stacktrace!!.frames!![0]
assertEquals("java", frame.platform)
assertEquals("myMethod", frame.function)
- assertEquals("", frame.module)
+ assertNull(frame.module)
}
@Test
@@ -505,7 +506,7 @@
val frame = event.threads!![0].stacktrace!!.frames!![0]
assertEquals("java", frame.platform)
assertEquals("myMethod", frame.function)
- assertEquals("", frame.module)
+ assertNull(frame.module)
}
@TestThis Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
Applied via @cursor push command
* test(android): add proguard tombstone test cases * remove esr from the expected register set (used only for hard-faults) * Format code * re-enable sentryCompose and disable auto-installation in the gradle plugin * adapt parseTombstoneWithJavaFunctionName in TombstoneParserTest to epitaph and make the snapshot test independent of order. --------- Co-authored-by: Sentry Github Bot <bot+github-bot@sentry.io>
4324585 to
f7473a5
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Double
normalizeFunctionNamecall for same input- The Java frame path now normalizes
frame.functionNameonce and reuses that normalized value for both module and function extraction.
- The Java frame path now normalizes
Or push these changes by commenting:
@cursor push 44ba30fd16
Preview (44ba30fd16)
diff --git a/sentry-android-core/src/main/java/io/sentry/android/core/internal/tombstone/TombstoneParser.java b/sentry-android-core/src/main/java/io/sentry/android/core/internal/tombstone/TombstoneParser.java
--- a/sentry-android-core/src/main/java/io/sentry/android/core/internal/tombstone/TombstoneParser.java
+++ b/sentry-android-core/src/main/java/io/sentry/android/core/internal/tombstone/TombstoneParser.java
@@ -152,8 +152,9 @@
final SentryStackFrame stackFrame = new SentryStackFrame();
if (isJavaFrame(frame)) {
stackFrame.setPlatform("java");
- final String module = extractJavaModuleName(frame.functionName);
- stackFrame.setFunction(extractJavaFunctionName(frame.functionName));
+ final String normalizedFunctionName = normalizeFunctionName(frame.functionName);
+ final String module = extractJavaModuleName(normalizedFunctionName);
+ stackFrame.setFunction(extractJavaFunctionName(normalizedFunctionName));
stackFrame.setModule(module);
// For Java frames, check in-app against the module (package name), which is what
@@ -217,21 +218,19 @@
return normalized;
}
- private static @Nullable String extractJavaModuleName(String fqFunctionName) {
- final String normalized = normalizeFunctionName(fqFunctionName);
- if (normalized.contains(".")) {
- return normalized.substring(0, normalized.lastIndexOf("."));
+ private static @Nullable String extractJavaModuleName(String normalizedFunctionName) {
+ if (normalizedFunctionName.contains(".")) {
+ return normalizedFunctionName.substring(0, normalizedFunctionName.lastIndexOf("."));
} else {
return null;
}
}
- private static @Nullable String extractJavaFunctionName(String fqFunctionName) {
- final String normalized = normalizeFunctionName(fqFunctionName);
- if (normalized.contains(".")) {
- return normalized.substring(normalized.lastIndexOf(".") + 1);
+ private static @Nullable String extractJavaFunctionName(String normalizedFunctionName) {
+ if (normalizedFunctionName.contains(".")) {
+ return normalizedFunctionName.substring(normalizedFunctionName.lastIndexOf(".") + 1);
} else {
- return normalized;
+ return normalizedFunctionName;
}
}This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
|
@0xadam-brown and @runningcode, you were added as reviewers only because it was merged from Long story short: no need to review beyond any individual interests (and also no approval, please; if this PR is a problem, let's just close it for now). |
Maybe that is the solution to begin with. The corresponding UI PR was also closed (getsentry/sentry#107318). |



…in mixed Tombstone stack traces.
📜 Description
This PR adds:
platform="java"in mixed platform Tombstone stack framesplatform="java"frames to the expected backend format (usingmodule,function, andplatform: "java"instead ofpackage,function,instruction_addras used for native frames)💡 Motivation and Context
This is a planned item of the "wrap-up" UI improvements in https://linear.app/getsentry/project/tombstone-support-android-0024cb6e3ffd/
It covers the SDK part of https://linear.app/getsentry/issue/ANDROID-265/improve-ux-for-mixed-stacktraces (getsentry/sentry#107318).
💚 How did you test it?
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps