Repository navigation
feat(nav3): Add the built-in SerialNameAndProperties BackStackEntryMapper - #6696
Open
0xadam-brown wants to merge 31 commits into
Open
0xadam-brown wants to merge 31 commits into
0xadam-brown wants to merge 31 commits into
Conversation
This was referenced Nov 20, 2026
Contributor
|
This was referenced Nov 20, 2026
📲 Install BuildsAndroid
|
This was referenced Nov 20, 2026
Closed
3 of 9 tasks
0xadam-brown
marked this pull request as ready for review
November 20, 2026 16:23
This was referenced Nov 23, 2026
docs(android): Document Nav3 built-in SerialName back stack entry mapper
getsentry/sentry-docs#20948
Open
0xadam-brown
force-pushed
the
feat/nav3-serial-name-mappers-base
branch
from
November 24, 2026 10:20
3dc7c0a to
0441799
Compare
This was referenced Nov 24, 2026
0xadam-brown
marked this pull request as draft
November 25, 2026 15:37
…gumentSanitizer The keys and values the Sentry UI shows (context, breadcrumb, and transaction keys, the /unknown name, and the argument drop reasons and limits) now live in one internal contract package, which the lifecycle package may import. A test pins each displayed string. ArgumentSanitizer recurses directly instead of through visit/exit helpers, checks a CharSequence's length before copying it, and has its own test suite.
4 of 9 tasks
Explains that the package holds internal values the Sentry UI displays or that define observable behavior, and that it may not depend on other navigation3 packages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…apper (#6706) Add BackStackEntryMapper.SerialNameAndProperties, which names entries as SerialName does and also records each entry's kotlinx.serialization properties as arguments, through KotlinxArgumentSource. Creating the mapper checks that the properties encoder works with the app's kotlinx.serialization version by encoding a known value with built-in serializers, as the name check does, and comparing the output with its known encoding. Any failure or mismatch keeps entry names but drops every entry's arguments with encoding_failed, since recording wrong arguments is worse than recording none.
…v3 sample app (#6707) The Nav3 samples now record each route's properties with the built-in SerialNameAndProperties mapper instead of pairing SerialName with hand-written arguments. Each property's @SerialName is the Nav2 sample's argument name, and a null campaign is still left out, so both samples send the same data. The performance scenario gains a SerialNameAndProperties mapper mode alongside Custom and SerialName.
…6708) The R8 check now launches each APK once per built-in mapper, chosen with an intent extra, as only one SentryNavEffect records an Activity's back stack. With SerialNameAndProperties, it also checks the arguments SentryNavEffect records for each key, including a key that uses every encoding rule and sensitive-data filtering, and that R8 renamed that key's fields. It fails if the properties encoder's compatibility check reports an incompatible kotlinx.serialization version.
An entry recorded as /unknown didn't say why, so outside debug logs a mapper that threw, returned a blank name, or chose not to name an entry all looked the same. Record the reason next to the entry as unknown_entry_reason in the back stack context and the nav transaction's data, and as to_unknown_entry_reason and from_unknown_entry_reason on breadcrumbs. The values are mapping_failed, blank_name, and unmapped. A mapper that throws now records mapping_failed as its unknown entry reason instead of as its arguments' drop reason, so one cause has one name.
…unknown Fatal errors a BackStackEntryMapper throws, such as an OutOfMemoryError or a LinkageError, propagate instead of falling back to /unknown. The KDoc now says so, and rewords the fallback paragraph to match. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BackStackEntryMapper.SerialName names each back stack entry after its kotlinx.serialization serial name, which R8 doesn't obfuscate, and records no properties. kotlinx-serialization-core is a compileOnly dependency at 1.7.3 or later. If the app's version can't be linked, the mapper falls back to naming every entry /unknown. The mapper returns null, which is public API, for entries it can't name, so it reports why through an internal per-thread side channel that the converter reads around each mapping call. Its reasons are entry_not_annotated, generic_entry_type, serializer_not_found, serializer_access_threw, and kotlinx_serialization_version. Unit tests run against the 1.7.3 floor by default, and against the latest stable release with -Pnav3TestKotlinx=latestStable.
…mapper - Check kotlinx.serialization linkage by looking up the built-in String serializer instead of SDK-owned probe types. The check runs no generated serializer, has no inconclusive result, and needs no consumer keep rule. - Rethrow fatal errors that reflection wraps, from both the serializer lookup and the descriptor read, in one place in the mapper. - Retry a lookup that failed on an interrupted thread instead of caching it. - Add a canary test that fails once kotlinx.serialization can look up a private object's serializer itself, so the private object fallback can then be removed. - Move UnknownEntryReasonReporter and the kotlinx.serialization floor and advice to a new internal.common package, so that the contract package holds only what the Sentry UI shows. Boundary tests keep common from importing anything but contract, or Android or AndroidX. - Document how custom mappers inherit reasons from built-in mappers they delegate to, and name unknown_entry_reason values rather than internal types in the public KDoc. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The anchor doesn't exist in the Navigation docs. Point it at the Troubleshooting Back Stack Mapping section instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The routes are @serializable with the Nav2 sample's route names as their serial names. The single-stack sample names them with BackStackEntryMapper.SerialName and adds each route's own arguments, and the multi-root samples use SerialName directly. The performance scenario can run SerialName itself, to measure its name lookups, as well as the custom mapper.
…nges Switching between the Custom and SerialName mappers kept the previous mapper's timings, so interactive diagnostics could report mapper_mode=SerialName alongside Custom's argument extractions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The adb launch could set a preset, an integration mode, and a run, but not the mapper, so a script couldn't measure the SerialName mapper. Add a nav3_perf_mapper_mode extra, applied after the preset. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add nav3-built-in-back-stack-mappers-r8-check, an app that maps representative back stack keys with BackStackEntryMapper.SerialName in an R8-minified release build and reports whether each name and unknown entry reason is right, and scripts/test-nav3-built-in-back-stack-mappers-r8.sh, which builds it and runs it on a booted emulator or device. Besides names, the app checks that R8 renamed classes, and, through a logger that records the mapper's messages, that the compatibility probe was conclusive. The Nav3 R8 workflow runs the check on API 23 in R8 full mode against the kotlinx.serialization floor and its latest stable release, and in compat mode against the floor, and runs the module's unit tests against the latest stable release. It only runs when files that can affect the check change.
…Effect records The check read each /unknown entry's reason from the warning the mapper logs, so it couldn't tell whether the reason reached the payload, and it broke whenever a warning was reworded. It now shows every key to SentryNavEffect as one back stack and reads names and reasons from the Navigation context of a captured event that beforeSend drops. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Reject a named entry that has an unknown_entry_reason, and any entry that has arguments. - Rename ProbeLogChecks to CompatibilityLogChecks and match the compatibility check's messages. - Drop the README's Dependabot cooldown claim, as dependabot.yml sets no cooldown. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The anchor doesn't exist in the Navigation docs. Point them at the section on named companion objects under R8 instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
0xadam-brown
force-pushed
the
feat/nav3-serial-name-stack-5
branch
from
December 4, 2026 13:36
001bcd0 to
8ab80f1
Compare
…me-mappers-base Brings in the restacked SerialName stack and main. Resolutions: - BackStackEntryMapper.kt: keep the #unknown-destination-names link from #6706 - SerializableKeys.kt: keep the named-companion link and #6708's wording - Nav3PerformanceControls.kt: keep main's imports and the sample's cap import - Nav3PerformanceLaunch.kt: the example preset is now capture_25_of_100 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
0xadam-brown
force-pushed
the
feat/nav3-serial-name-stack-5
branch
from
December 4, 2026 13:56
8ab80f1 to
066309a
Compare
…me-mappers-base Brings in the SerialName stack, restacked after #6801 merged. Its content is unchanged, so this merge keeps the branch's tree as it was. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
PR Stack (Nav3 SerialNameAndProperties Mapper)
This stack follows the
SerialNamestack (#6780) and is based on its last PR, #6783.📜 Description
Introduces
BackStackEntryMapper.SerialNameAndProperties, the second of two built-in mappers for kotlinx.serialization. (See the "Motivation and Context" section below for more info about why we need mappers in the first place.) The first,SerialName, was added by the #6780 PR stack.For an entry like this...
...the two built-in mappers create Sentry data like this:
SerialName(#6780)SerialNameAndPropertiesThe high-level processing path for SerialNameAndProperties
Failure modes
unknown_entry_reason(just like withSerialName).{"dropped_by_sentry": "encoding_failed"}.kotlinx-serialization-coreversion can't run our properties encoder, entries keep their names but the arguments of every entry with properties are dropped with "encoding_failed". (If the version is incompatible with the mapper itself, every entry is recorded as "/unknown" withunknown_entry_reason"kotlinx_serialization_version", as withSerialName.)💡 Motivation and Context
With Nav3, host apps manage their own nav back stack, which they implement as a list of arbitrarily typed entries. In order to be displayed in Sentry, each of those entries has to be mapped to a Sentry name (e.g., ProductDetailScreen) and zero or more arguments (e.g., productId="123abc"). There are two ways for us to get those mappings:
BackStackEntryMapperthe host app implements itself; orSupporting SAGP auto-instrumentation for Nav3 relies on (2). This PR stack and the
SerialNamestack give us the mappers we need. (Nav3 auto-instrumentation will be implemented in subsequent PRs.)addresses: JAVA-787 (link)
Before
Extracting Sentry data from back stack entries was the responsibility of host apps via custom implementations of the
BackStackEntryMapperinterface. Like this:After
Now host apps can use the built-in mapper instead of implementing their own, whether as-is...
Like this:
...or filtering out sensitive / unwanted properties...
...or as a fallback within their own custom mapper:
This PR stack covers all the gory details of what introducing that built-in mapper requires. Have fun!
PR by PR
ArgumentSinkseam back inArgumentSanitizer, andKotlinxPropertiesEncoder, which encodes an entry's properties within the argument limits and filters sensitive keysKotlinxArgumentSource, which encodes an entry's properties lazily, and theencoding_faileddrop reasonSerialNameAndPropertiesmapper and its encoder compatibility checkSerialNameAndProperties, and the Performance tab can measure itSerialNameAndPropertiesaddresses: JAVA-787 (link)
🔍 Due diligence
See the "Callouts" section in #6707 for a discussion of the performance impact of this PR stack, as well as leak memory concerns, and potential for crashing the host app. (Spoiler alert: no issues were found.)
💚 How did you test it?
(See individual PRs.)
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
mainonce feat(nav3): Add the built-in SerialName BackStackEntryMapper #6780 merges.#skip-changelog