Repository navigation
ref(android): Support Nav3 for multi-Activity applications - #6229
Draft
0xadam-brown wants to merge 1 commit into
Draft
0xadam-brown wants to merge 1 commit into
0xadam-brown wants to merge 1 commit into
Conversation
📲 Install BuildsAndroid
|
5 of 9 tasks
0xadam-brown
force-pushed
the
ref/sentry-nav-effect-lifecycle
branch
5 times, most recently
from
October 13, 2026 11:44
72119f1 to
54924cc
Compare
0xadam-brown
force-pushed
the
ref/sentry-nav-effect-lifecycle
branch
from
October 13, 2026 12:01
54924cc to
b1ebe22
Compare
Introduce Nav3 support for multi-Activity applications by managing shared SentryNavEffect state so that multiple instances can overlap during Activity transitions without interfering with one another. Basic approach was to replace the IScopes instance that BackStackObserver already talks to with a a smarter version that can toggle between the shared underlying scope and a per-instance staged version, depending on whether the observer is associated with the incoming our outgoing SentryNavEffect. Doing so let's us keep modifications to SentryNavEffect, BackStackObserver, etc. to a minimum, and makes it easy to swap out our implementation in the future, should we eventually hide our IScopes API behind a LocalSentrySpan-esque system (or any of a number of other possibilities).
0xadam-brown
force-pushed
the
ref/sentry-nav-effect-lifecycle
branch
from
October 13, 2026 12:02
b1ebe22 to
06c7bd8
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📜 Description
PR allows separate
SentryNavEffectinstances to overlap during Activity or Fragment 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
NavScopesfile. The basic idea was simply to replace theIScopesinstanceBackStackObserveralready talked to with a smarter version that could toggle between the shared underlying scope and a per-instance staged version, depending on whether the observer was associated with the incoming or outgoing SentryNavEffect.That^^ let me keep updates to SentryNavEffect, BackStackObserver, etc. to a minimum, and it makes it easy to swap out our implementation in the future, should we ever hide our IScopes API behind a
LocalSentrySpan-esque system (or any of a number of other possibilities) 🎉 .See the NavScopes KDoc for more details, including some helpful diagrams.
💡 Motivation and Context
Lets us support multi-Activity or multi-Fragment apps, where each Activity / Fragment 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?
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps