Skip to content

fix(android): Deobfuscate PlatformException frames - #4081

Merged
buenaflor merged 6 commits into
getsentry:mainfrom
xelarich:fix/platformexception-proguard-debug-meta
Oct 15, 2026
Merged

buenaflor merged 6 commits into
getsentry:mainfrom
xelarich:fix/platformexception-proguard-debug-meta

Conversation

@xelarich

@xelarich xelarich commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

📜 Description

Attach the ProGuard debug image to Dart-captured PlatformException events on Android, so their Java frames get deobfuscated.

  • SentryNativeBinding.proguardUuid: new internal getter. SentryNativeJava reads ScopesAdapter.instance.options.proguardUuid through JNI and releases both references in finallyFn. The other bindings return null.
    • The UUID is read on use rather than in init(), because init() is skipped when autoInitializeNativeSdk is disabled. It is cached once found, and a null read is retried on the next PlatformException, since the native SDK may not have resolved it yet (from SentryFlutterOptions.proguardUuid or the sentry-debug-meta.properties asset). The retry only costs a JNI field read on non-minified builds, where no UUID is ever found.
  • AndroidPlatformExceptionEventProcessor: once it adds Java frames, it adds DebugImage(type: 'proguard', uuid: …) to debugMeta. Existing images are kept, and no image is added if a proguard image with the same UUID is already there. Nothing changes when no UUID is available.
  • LoadNativeDebugImagesIntegration: appends the native images to debugMeta instead of replacing it. That processor runs after the Android one, so on obfuscated or --split-debug-info builds it would otherwise drop the proguard image.

💡 Motivation and Context

Fixes #4080. Discussed in #4067.

AndroidPlatformExceptionEventProcessor parses the Java stack trace into java frames, but the event has no proguard image. The Android SDK only adds that image to the events it captures itself; a Dart-built event is sent as-is through captureEnvelope. As a result the frames stay minified (h5.q.<init>), and since minified names change between builds, each release splits the same defect into a new issue. Related: #2841.

As suggested in #4067, the fix is on the Dart side and needs no native code change: the getter already exists in the generated JNI bindings.

💚 How did you test it?

  • Unit tests, written first and failing before the fix:
    • AndroidPlatformExceptionEventProcessor: adds the proguard image, keeps existing images, no duplicate, nothing without Java frames, nothing without a UUID.
    • LoadNativeDebugImagesIntegration: keeps existing debug images.
    • flutter test on packages/flutter: all passing. dart format and dart analyze --fatal-infos are clean with the stable Flutter-bundled Dart (3.13.4).
  • Android integration test: the existing init test now also sets options.proguardUuid and checks both the native options and SentryFlutter.native?.proguardUuid. integration_test/all.dart passes on a physical device (Samsung SM-X216B).
  • End to end on a production app, using this branch through dependency_overrides. The app's own workaround processor was disabled, so the image could only come from the SDK.
    • Setup: minified release build with the Sentry Android Gradle Plugin, which embedded b0d5c2ce-495c-390d-a0c9-a5280a07329c and uploaded the mapping under it.
    • Trigger: a real Flutter engine PlatformException (TextInputChannel rejecting setEditingState, IndexOutOfBoundsException: invalid selection start).
    • The event arrived with debug_meta: [{type: proguard, uuid: b0d5c2ce-…}] and no processing errors.
    • Its frames were fully deobfuscated: io.flutter.embedding.engine.systemchannels.TextInputChannel$TextEditState.<init> (TextInputChannel.java:820) instead of h5.q.<init>.
    • It grouped into the existing issue, alongside events from other builds.

📝 Checklist

  • I reviewed submitted code
  • I added tests to verify changes
  • No new PII added or SDK only sends newly added PII if sendDefaultPii is enabled
  • I updated the docs if needed
  • All tests passing
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec
  • No breaking changes

No public API change: SentryNativeBinding is @internal.

🔮 Next steps

None.

Changelog Entry

Deobfuscate the Java frames of Dart-captured PlatformException events on Android by attaching the ProGuard debug image, and keep existing debug images when loading native ones.

The Java frames parsed from a Dart-captured PlatformException stayed
minified: the Android SDK only attaches the proguard debug image to
the events it captures itself, so Sentry could not find the R8
mapping and every build split the defect into a new issue.

- Expose the native SDK's ProGuard UUID on SentryNativeBinding, read
  once through JNI on first use and cached, so it also works when
  autoInitializeNativeSdk is disabled
- AndroidPlatformExceptionEventProcessor attaches a proguard debug
  image when it adds Java frames, keeping existing images and
  skipping duplicates
- LoadNativeDebugImagesIntegration appends native images instead of
  replacing debug_meta, which dropped the proguard image on
  obfuscated or split-debug-info builds

Fixes getsentry#4080

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@xelarich
xelarich marked this pull request as ready for review October 14, 2026 08:47

@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 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f647019. Configure here.

The UUID was cached on first read, null included. With
autoInitializeNativeSdk disabled, a PlatformException processed before
the native SDK resolved the UUID left Java frames minified for the
rest of the process. Cache the UUID once found and retry null reads.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

@buenaflor buenaflor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nice 👍

@codecov

codecov Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.85714% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.90%. Comparing base (e77adf4) to head (1f76d1e).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...ckages/flutter/lib/src/native/c/sentry_native.dart 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4081      +/-   ##
==========================================
+ Coverage   88.77%   92.90%   +4.13%     
==========================================
  Files         348      114     -234     
  Lines       12577     4596    -7981     
==========================================
- Hits        11165     4270    -6895     
+ Misses       1412      326    -1086     
Flag Coverage Δ
sentry ?
sentry_dio ?
sentry_drift ?
sentry_file ?
sentry_firebase_remote_config 100.00% <ø> (ø)
sentry_flutter 92.62% <92.85%> (-0.01%) ⬇️
sentry_grpc ?
sentry_hive ?
sentry_isar ?
sentry_link ?
sentry_logging ?
sentry_sqflite ?
sentry_supabase 97.48% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@xelarich

Copy link
Copy Markdown
Contributor Author

Thanks for the approval @buenaflor! 🙏

The merge is currently blocked because the CI hasn't run on the latest commit: since the branch comes from a fork, the workflows are waiting for maintainer approval. Sorry about the extra "Update branch" merges on my side, each one reset that approval, so I'll leave the branch as is from now on.

A couple of questions so I know what to expect:

  1. Could you approve the workflows so the CI can run? Is there anything else needed from my side before it can be merged?
  2. Who takes it from here for the merge, you or @denrase?
  3. Do you know which release it's likely to land in? We'd like to plan removing our workaround on our side once it ships.

@buenaflor
buenaflor enabled auto-merge (squash) October 15, 2026 09:43
@buenaflor

Copy link
Copy Markdown
Contributor

I'll take care of merging.

It will land in release 10.1.0

@buenaflor
buenaflor merged commit 86cc3b5 into getsentry:main Oct 15, 2026
62 of 65 checks passed
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.

PlatformException Java frames lack ProGuard metadata

2 participants