You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e2a270b
Browse filesBrowse the repository at this point in the historyBrowse files
feat(android): Nav3 support for multi-Activity and multi-Fragment applications (JAVA-785) (#6301)
Introduces Nav3 support for app architectures involving multiple NavDisplay <> SentryNavEffect pairs, subject to certain limitations (see the "Still not supported" list below). Prior to this commit, we assumed only one NavDisplay <> SentryNavEffect pair would be active at a time.
Supported
-----------
- A single-Activity app with one NavDisplay <> SentryNavEffect pair.
- A multi-Activity app where each Activity has its own NavDisplay <> SentryNavEffect pair.
- A multi-Fragment app where each Fragment has its own NavDisplay <> SentryNavEffect pair.
- A ViewPager2 whose pages are Fragments, each with its own NavDisplay <> SentryNavEffect pair.
- An Activity or Fragment with its own NavDisplay that stays visible beneath a DialogFragment or translucent Activity with its own NavDisplay.
Before this PR stack, we only supported (1) and its functional equivalents.
Still not supported
------------------
- Nested NavDisplay <> SentryNavEffect pairs in the same Activity or Fragment.
- Side-by-side NavDisplay <> SentryNavEffect pairs in the same Activity or Fragment.
- SentryNavEffect instances in multiple Activities or Fragments that users can interact with at the same time, such as two Activities from the same app in multi-resume mode.
- SentryNavEffect instances in pages or tabs that share their host's lifecycle, such as Compose HorizontalPager pages, ViewPager2 pages that aren't Fragments, or tabs kept in the composition at once. (Those pages or tabs share one LifecycleOwner, so at most one can call SentryNavEffect.)
The basic approach
-------------------
Supporting the new setups listed above requires coordinating multiple, simultaneously active SentryNavEffects and their updates to the current (mutable + shared) IScope vended by IScopes.
Like all forms of state management around Android lifecycles + shared mutable state, that code isn't exactly simple. To keep things manageable (and easy to update), we were careful to sequester all coordination logic to a new .navigation3.lifecycle package.
The basic idea was to replace the IScopes instance our BackStackObserver already talked to with a smarter version (NavScopes) 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. (Under the hood, NavScopes relies on lease-based ownership to decide who can update the scope, which is overseen by the new NavLeaseCoordinator.)
That^^ let us 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).
Copy file name to clipboardExpand all lines: CHANGELOG.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,11 @@
2
2
3
3
## Unreleased
4
4
5
+
### Improvements
6
+
7
+
- Support Navigation 3 integration for multi-Activity and multi-Fragment applications, where each Activity or Fragment has its own `SentryNavEffect` ([#6305](https://github.com/getsentry/sentry-java/pull/6305))
8
+
- See the [Navigation for Android docs](https://docs.sentry.io/platforms/android/integrations/navigation/#supported-setups) for a detailed list of supported vs unsupported app setups.
9
+
5
10
### Fixes
6
11
7
12
- Always remove the first-draw listener after the first frame, even if no layout pass follows it ([#6152](https://github.com/getsentry/sentry-java/pull/6152))
0 commit comments