Skip to content

fix(android): Backfill pre-init ANR and native crash metadata#5762

Open
romtsn wants to merge 4 commits into
mainfrom
romtsn/fix/validate-app-update-timestamp
Open

fix(android): Backfill pre-init ANR and native crash metadata#5762
romtsn wants to merge 4 commits into
mainfrom
romtsn/fix/validate-app-update-timestamp

Conversation

@romtsn

@romtsn romtsn commented Jul 14, 2026

Copy link
Copy Markdown
Member

📜 Description

Backfill release, environment, distribution (dist), and app version/build on ANR and native crash events from the current SDK options when persisted values are unavailable.

This covers exits that happen before SDK initialization, when the SDK has not yet persisted those options. Current values are used only when the app has not been updated since the exit. A missing or invalid package update timestamp is treated conservatively so historical events are not attributed to a newer app version.

💡 Motivation and Context

ANR and native crash events are reported from ApplicationExitInfo on the next SDK initialization. If the terminated process exited before initializing the SDK, release-related options were never persisted and the reported event can be missing useful metadata.

The reporting process already has the same values in its current options when the package has not been updated. Comparing the exit timestamp with PackageInfo.lastUpdateTime allows those values to be used without attaching metadata from a newer app version.

Closes #4227
Closes #3287

💚 How did you test it?

  • ./gradlew ':sentry-android-core:testDebugUnitTest' --tests='*ApplicationExitInfoEventProcessorTest*' --info (42 tests passed)
  • ./gradlew spotlessApply apiDump

📝 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.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

None.

Use current options when persisted values are missing and the app has not been updated since the exit. Avoid attributing historical crashes to a newer app version.
@sentry

sentry Bot commented Jul 14, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

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

⚙️ sentry-android Build Distribution Settings

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 323.59 ms 368.29 ms 44.70 ms
Size 0 B 0 B 0 B

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
6b019b7 403.90 ms 546.09 ms 142.19 ms
e63ad34 310.20 ms 366.84 ms 56.63 ms
5865051 319.74 ms 365.60 ms 45.86 ms
a1eadfa 345.67 ms 411.26 ms 65.59 ms
b193867 319.59 ms 403.09 ms 83.50 ms
0eaac1e 316.82 ms 357.34 ms 40.52 ms
22ff2c7 306.60 ms 336.65 ms 30.05 ms
d15471f 286.65 ms 314.68 ms 28.03 ms
05aa61d 310.43 ms 372.40 ms 61.97 ms
fcec2f2 311.35 ms 384.94 ms 73.59 ms

App size

Revision Plain With Sentry Diff
6b019b7 0 B 0 B 0 B
e63ad34 0 B 0 B 0 B
5865051 0 B 0 B 0 B
a1eadfa 0 B 0 B 0 B
b193867 1.58 MiB 2.19 MiB 620.00 KiB
0eaac1e 1.58 MiB 2.19 MiB 619.17 KiB
22ff2c7 0 B 0 B 0 B
d15471f 1.58 MiB 2.13 MiB 559.54 KiB
05aa61d 0 B 0 B 0 B
fcec2f2 1.58 MiB 2.12 MiB 551.51 KiB

Previous results on branch: romtsn/fix/validate-app-update-timestamp

Startup times

Revision Plain With Sentry Diff
d4ce194 321.51 ms 369.29 ms 47.78 ms

App size

Revision Plain With Sentry Diff
d4ce194 0 B 0 B 0 B

@romtsn romtsn changed the title fix(android): Backfill exit options when app is unchanged fix(android): Backfill pre-init ANR and native crash metadata Jul 15, 2026
@romtsn romtsn marked this pull request as ready for review July 15, 2026 07:58

@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 is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 4555c88. Configure here.

romtsn and others added 2 commits July 15, 2026 11:22
Populate app version and build for historical ANR and native crash events when the current package metadata is safe to use.

Co-Authored-By: Codex <noreply@openai.com>
Backfill only app version and build for historical exits. Avoid attaching current localized app names, identifiers, or split APK state to older events.

Co-Authored-By: Codex <noreply@openai.com>
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.

Auto release detection not working Enrich ANRs happened before Sentry.init

1 participant