Skip to content

ref(android): Support updates to nav state across multiple SentryNavEffect instances - #6229

Draft
0xadam-brown wants to merge 1 commit into
mainfrom
ref/sentry-nav-effect-lifecycle
Draft

0xadam-brown wants to merge 1 commit into
mainfrom
ref/sentry-nav-effect-lifecycle

Conversation

@0xadam-brown

@0xadam-brown 0xadam-brown commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

📜 Description

PR allows separate SentryNavEffect instances to overlap during Activity transitions without stale cleanup clobbering the active observer.

Like all forms of state management around Android lifecycles, this code isn't exactly simple. To keep things manageable (and easy to update!), I've been careful to sequester all state management to the INavScopes file.

That let me keep updates to SentryNavEffect, BackStackObserver, etc. to a minimum 🎉 .

💡 Motivation and Context

Lets us support multi-Activity apps, where each Activity has its own SentryNavEffect <> NavDisplay pair. That setup is common, and without the changes here, spans and nav state would be incorrect for the initial destination in each newly-launched Activity.

That's worrisome, because Activity startup logic is a common source of bugs / crashes, so properly attributing Sentry data there is especially worthwhile.

addresses: JAVA-274

💚 How did you test it?

  • Unit tests
  • Had my clanker use the new Nav3 sample app tab introduced in this PR to verify that nav data was interleaved and garbled when switching between Activity <> SentryNavEffect pairs prior to this PR, and fixed after.

📝 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

  • Remove the @ApiStatus.Internal annotations from SentryNavEffect, SentryNavOptions, BackStackEntryMapper once we're ready to release publicly + add an appropriate CHANGELOG entry + publish the module via craft (link).

#skip-changelog

@sentry

sentry Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

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

⚙️ sentry-android Build Distribution Settings

@0xadam-brown 0xadam-brown mentioned this pull request Oct 7, 2026
5 of 9 tasks
@0xadam-brown
0xadam-brown force-pushed the ref/sentry-nav-effect-lifecycle branch 3 times, most recently from 011d126 to eca83dc Compare October 12, 2026 10:55
…ffect instances (JAVA-274)

Allow separate SentryNavEffect instances to overlap during Activity transitions without stale cleanup clobbering the active observer.
@0xadam-brown
0xadam-brown force-pushed the ref/sentry-nav-effect-lifecycle branch from eca83dc to 72119f1 Compare October 12, 2026 15:31

This branch has not been deployed

No deployments
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.

1 participant