Title: Support use of SentryNavEffect in multi-Activity and multi-Fragment applications · Issue #6345 · getsentry/sentry-java · GitHub
Open Graph Title: Support use of SentryNavEffect in multi-Activity and multi-Fragment applications · Issue #6345 · getsentry/sentry-java
X Title: Support use of SentryNavEffect in multi-Activity and multi-Fragment applications · Issue #6345 · getsentry/sentry-java
Description: Summary Extend the Android Nav3 integration to support applications with multiple NavDisplay <> SentryNavEffect pairs hosted by different lifecycle owners. Our initial Nav3 implementation assumed that only one SentryNavEffect would be ac...
Open Graph Description: Summary Extend the Android Nav3 integration to support applications with multiple NavDisplay <> SentryNavEffect pairs hosted by different lifecycle owners. Our initial Nav3 implementation assumed t...
X Description: Summary Extend the Android Nav3 integration to support applications with multiple NavDisplay <> SentryNavEffect pairs hosted by different lifecycle owners. Our initial Nav3 implementation ass...
Opengraph URL: https://github.com/getsentry/sentry-java/issues/6345
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Support use of SentryNavEffect in multi-Activity and multi-Fragment applications","articleBody":"### Summary\n\nExtend the Android Nav3 integration to support applications with multiple `NavDisplay` \u003c> `SentryNavEffect` pairs hosted by different lifecycle owners.\n\nOur initial Nav3 implementation assumed that only one `SentryNavEffect` would be active at a time. (Under the hood, `SentryNavEffect` writes to a shared, mutable `IScope`.) That's fine for single-Activity apps with singly-rooted nav graphs, but it won't work for multi-Activity or multi-Fragment applications where each Activity or Fragment has its own nav subgraph. (Usually, each subgraph will have its own `NavDisplay` \u003c> `SentryNavEffect` pair.) \n\nIn particular, multiple `SentryNavEffect` instances may try to update the shared `IScope` when the host app transitions from one Activity / Fragment to the next. Under the current implementation, that can cause nav data to become stale or nav transactions to interfere with each other.\n\nThis issue tracks the work needed to extend Sentry Nav3 support to multi-Activity and multi-Fragment applications.\n\n### Setups to support\n\n- A single-Activity app with one `NavDisplay` \u003c> `SentryNavEffect` pair. (Already supported by the existing `SentryNavEffect` implementation.)\n- A multi-Activity app where each Activity has at most one `NavDisplay` \u003c> `SentryNavEffect` pair.\n- A multi-Fragment app where each Fragment has at most one `NavDisplay` \u003c> `SentryNavEffect` pair (and the host Activity or Activities have no `SentryNavEffect`(s) of their own).\n- A `ViewPager2` whose pages are Fragments, each with at most one `NavDisplay` \u003c> `SentryNavEffect` pair.\n- An Activity or Fragment with its own `NavDisplay` \u003c> `SentryNavEffect` pair that stays visible beneath a `DialogFragment` or translucent Activity with its own pair.\n\n### Setups that will remain unsupported\n\n- Sibling `NavDisplay` and `SentryNavEffect` pairs in the same Activity or Fragment.\n- Nested `NavDisplay` and `SentryNavEffect` pairs in the same Activity or Fragment. (If you nest `NavDisplay`s, consider using `SentryNavEffect` only with the outermost one.)\n- `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](https://developer.android.com/develop/ui/views/layout/support-multi-window-mode#multi-resume), or an Activity and hosted Fragments where the Activity and Fragments each have their own `NavDisplay` and `SentryNavEffect` pairs.\n- `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 that are kept in the composition when inactive. (Those pages or tabs share one `LifecycleOwner`, so at most one can call `SentryNavEffect`.)\n\n### Proposed implementation\n\nSupporting the new setups listed above requires coordinating multiple, simultaneously active `SentryNavEffect`s and their updates to the current (mutable + shared) `IScope` vended by `IScopes`. \n\nWe can do so by replacing the `IScopes` instance our `BackStackObserver` already talks to with a smarter version (`NavScopes`) that can toggle between the shared underlying scope and a per-instance staged version, depending on whether the observer is associated with an incoming or outgoing SentryNavEffect. (Under the hood, NavScopes can use lease-based ownership to decide which effect can update the scope.)\n\nThat^^ let us keep updates to SentryNavEffect, BackStackObserver, etc. to a minimum. And it will make 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).\n\n### Follow-up\n\nUpdate the Android Navigation documentation to describe the supported multi-root lifecycle scenarios and current limitations.\n\n### References\n\n- PR stack: [#6301](https://github.com/getsentry/sentry-java/pull/6301), [#6302](https://github.com/getsentry/sentry-java/pull/6302), [#6304](https://github.com/getsentry/sentry-java/pull/6304), [#6305](https://github.com/getsentry/sentry-java/pull/6305), [#6307](https://github.com/getsentry/sentry-java/pull/6307), [#6309](https://github.com/getsentry/sentry-java/pull/6309)","author":{"url":"https://github.com/0xadam-brown","@type":"Person","name":"0xadam-brown"},"datePublished":"2026-10-21T12:10:45Z","url":"https://github.com/getsentry/sentry-java/issues/6345"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b8acd0ff-6fb6-3983-12b3-960d2a2e41e8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A496:271798:88AF8:BE2C6:6B04626D |
| html-safe-nonce | 8cc5e077424c05c186b1258af5a6c49e09ddf3c45cc658e01279cb439ebd475d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNDk2OjI3MTc5ODo4OEFGODpCRTJDNjo2QjA0NjI2RCIsInZpc2l0b3JfaWQiOiIyMDc3MTEzODI3NTgwOTk0MTU3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 28bd69274b81ee7698b646d9fe270ebb54be7049c4cbde98d61729a0df98fbe0 |
| hovercard-subject-tag | issue:5960211453 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-java/6345/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2a7f5eb9053203660396c9663475199b21aff94a2c6b35f759081b5247cd7a5f/getsentry/sentry-java/issues/6345 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2a7f5eb9053203660396c9663475199b21aff94a2c6b35f759081b5247cd7a5f/getsentry/sentry-java/issues/6345 |
| og:image:alt | Summary Extend the Android Nav3 integration to support applications with multiple NavDisplay <> SentryNavEffect pairs hosted by different lifecycle owners. Our initial Nav3 implementation assumed t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | 0xadam-brown |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2d58451b4bcb73c33c67bfb6b28fb75fe6d5e279daf9b560fa4fd832f3d8c9a6 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-java git https://github.com/getsentry/sentry-java.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3368190 |
| octolytics-dimension-repository_nwo | getsentry/sentry-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3368190 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 03e114520787ad27289207f153520ef97461127c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width