Skip to content

fix(android): identify and correctly structure Java/Kotlin frames…#5116

Closed
supervacuus wants to merge 13 commits into
mainfrom
fix/android/id_java_kotlin_frames_tombstone
Closed

fix(android): identify and correctly structure Java/Kotlin frames…#5116
supervacuus wants to merge 13 commits into
mainfrom
fix/android/id_java_kotlin_frames_tombstone

Conversation

@supervacuus

@supervacuus supervacuus commented Feb 25, 2026

Copy link
Copy Markdown
Collaborator

…in mixed Tombstone stack traces.

📜 Description

This PR adds:

  • identification of platform="java" in mixed platform Tombstone stack frames
  • restructuring of those platform="java" frames to the expected backend format (using module, function, and platform: "java" instead of package, function, instruction_addr as used for native frames)
  • a snapshot test against the tombstone that checks the identification of Java frames and in-app doesn't regress

💡 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

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

@linear

linear Bot commented Feb 25, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Feb 25, 2026

Copy link
Copy Markdown
Contributor

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Bug Fixes 🐛

  • (android) Identify and correctly structure Java/Kotlin frames… by supervacuus in #5116

🤖 This preview updates automatically when you update the PR.

@supervacuus

Copy link
Copy Markdown
Collaborator Author

While testing this manually, it became apparent that the SDK-level inApp detection and the one on the server disagree. See here: https://sentry-sdks.sentry.io/issues/7288803722/events/af5e7573571f4cd98616f947e081ad09/

In the event, only the JNI frame is kept as inApp because it is a native frame. The Java frames from the package are marked as "framework" -> "system (see the data property for evidence of an overwrite):

image

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.

@github-actions

github-actions Bot commented Feb 25, 2026

Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 369.93 ms 463.70 ms 93.77 ms
Size 0 B 0 B 0 B

Baseline results on branch: main

Startup times

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

@sentry

sentry Bot commented Mar 13, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.47.0 (1) release

⚙️ sentry-android Build Distribution Settings

@markushi markushi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice!, I'll not marked it as approved, as we should get the frontend changes in first.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 null module values, matching production behavior when no module can be extracted.

Create PR

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)
   }
 
   @Test

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

cursoragent and others added 3 commits March 13, 2026 10:39
* 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>
@supervacuus supervacuus force-pushed the fix/android/id_java_kotlin_frames_tombstone branch from 4324585 to f7473a5 Compare March 13, 2026 12:11

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Double normalizeFunctionName call for same input
    • The Java frame path now normalizes frame.functionName once and reuses that normalized value for both module and function extraction.

Create PR

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.

@supervacuus

supervacuus commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator Author

@0xadam-brown and @runningcode, you were added as reviewers only because it was merged from main to check whether the branch had diverged too far. This is currently blocked by decisions outside this PR, primarily related to https://linear.app/getsentry/team/JAVA/projects/view/roadmap-f1c601612fba.

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).

@supervacuus

Copy link
Copy Markdown
Collaborator Author

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).

@supervacuus supervacuus closed this Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants