Repository navigation
ref(android): [Nav3 Lifecycle 1] Add NavLeaseCoordinator - #6302
0xadam-brown wants to merge 3 commits into
Conversation
📲 Install BuildsAndroid
|
Introduce the lifecycle-aware lease state machine that selects which navigation root may publish shared scope state and bind navigation transactions. Refs JAVA-274
Always forget departing navigation candidates when transaction cleanup or lease handoff fails. Preserve a successor selected before a callback throws. Add regression coverage for cleanup failures and successor lease ownership. Refs JAVA-274 Co-Authored-By: Codex <noreply@openai.com>
transferLeaseTo assigned the lease before clearing the previous owner's published nav data. When that callback threw, the new leaseholder was recorded against a stale publisher, so a later handoff cleared the wrong owner's data and never cleared the leaseholder's own. Always record the incoming candidate as the publisher once it takes the lease. Add regression coverage for handoff cleanup failures. Refs JAVA-274
c2667a5 to
c464ea3
Compare
8292382 to
a010c9e
Compare
runningcode
left a comment
There was a problem hiding this comment.
LGTM! thanks for all the docs. Just a note, i feel like the exception semantics part doesn't really help me understand what I'm supposed to do here when using the class. Like does that mean I'm supposed to catch arbitrary exceptions or just ignore them?
| implementation(projects.sentry) | ||
|
|
||
| compileOnly(libs.androidx.compose.runtime) | ||
| // Provides lifecycle types used to coordinate overlapping navigation roots. Hosts get it at |
There was a problem hiding this comment.
i don't think we need this comment
| * **Thread safety** | ||
| * | ||
| * This class is ***not*** thread-safe. All `NavScopes` instances using this coordinator must | ||
| * confine their access to the same thread. |
There was a problem hiding this comment.
just for my understanding? is this generally the main thread? mostly wondering about performance.
| * confine their access to the same thread. | ||
| */ | ||
| @Suppress("TooManyFunctions") | ||
| internal class NavLeaseCoordinator { |
There was a problem hiding this comment.
i guess i never asked myself this question before but if a class is internal, can we automatically assume it is @ApiStatus.Internal ?
| private var resumeOrder: Long = 0 | ||
|
|
||
| /** | ||
| * Registers [owner] as a candidate for the nav lease. No-ops if `owner` is already registered or |
There was a problem hiding this comment.
nit: owner being already registered is determined by object reference. makes sense! I'm just wondering noting in the doc. i imagine a case where there are many "WebViewScreens" and nobody writes equals/hashcode for those.
PR Stack (Nav3 Lifecycle)
📜 Description
Add the lifecycle-aware lease state machine used to coordinate multiple Navigation 3 roots that share Sentry scope state.
The coordinator selects one eligible lifecycle owner at a time, preserves displaced navigation transactions for restoration, and clears or finishes retained state when owners leave.
💡 Motivation and Context
Overlapping Activities and Fragments can keep multiple
SentryNavEffectinstances alive simultaneously. A deterministic ownership policy is needed before their scope writes can be safely coordinated.addresses: JAVA-785
💚 How did you test it?
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
The next PR adds the lease-aware scope façade that consumes this coordinator.
#skip-changelog