Repository navigation
ref(android): [Nav3 support for ViewPager2 – Part 1] Give each SentryNavEffect a lease registration and a transaction handle - #6399
Conversation
…ansaction handle NavLeaseCoordinator now observes each candidate's lifecycle itself, via register(), and publishes and unpublishes its nav state through LeasedNavState. NavScopes folds the old NavScope into an inner class and publishes its StagedNavData and nav transaction through a single publisher. Each NavScopes instance now keeps its nav transaction in a StagedNavTransaction handle, which INavScope.startNavTransaction and finishNavTransaction drive, rather than BackStackObserver binding and unbinding transactions itself and the coordinator retaining them. StagedNavTransaction alone decides whether the scope's transaction slot is free. No behavior change: nav transactions still start only with the nav lease and a free slot, and an owner that regains the lease still gets its unfinished transaction back. The integration tests are unchanged. This prepares for deferring transactions requested without the lease. Refs JAVA-785 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
📲 Install BuildsAndroid
|
runningcode
left a comment
There was a problem hiding this comment.
Thanks for putting this together along with the docs and diagrams!
This was a long one so I'll just note that I didn't review the tests.
My only thought is that it seems like a lot of code for just adding ViewPager2 support :O
| * and any work performed is associated with it† – the idea being that start-up logic is more likely | ||
| * to cause a crash or produce interesting spans than an outgoing destination's steady state. | ||
| * | ||
| * † Associating work with the incoming transaction means spans produced by the outgoing owner may |
There was a problem hiding this comment.
†
I noticed you used these a few times. Is that a javadoc/kdoc thing?
| * | ||
| * † Associating work with the incoming transaction means spans produced by the outgoing owner may | ||
| * appear as if they were produced by the incoming owner (or vice versa, were our policy reversed). | ||
| * A possible solution would be to implement a parent span delivery system similar to |
There was a problem hiding this comment.
but that's a task for another day.
Alternative solutions are great for PR reviews! But I'm not sure we want to have that in our docs 😄
Since the class is internal, though, i think its fine.
| * │ | ||
| * ▼ | ||
| * | ||
| * NavScopes A + Lifecycle A Shared state NavScopes B + Lifecycle B |
There was a problem hiding this comment.
This took me a couple of reads to understnad what was going on but once I got it, it makes a lot of sense and helps a ton with understanding!!
PR Stack (Nav3 Deferred Transactions)
📜 Description
Refactors
.navigation3.lifecycleahead of staging nav transactions in the next PR.Lets us separate three responsibilities:
Behavior is unchanged save for one corner case: when a SentryNavEffect regains the lease, its unfinished transaction is now also re-bound if the scope holds a finished transaction. Before, it was only re-bound into an empty scope. The update matches the rule for starting a transaction, and in practice shouldn't occur, since a finished
SentryTracerremoves itself from the scope.See the PR description in #6398 for more details.
💡 Motivation and Context
Splits out structural refactoring from the meaningful behavioral changes which follow.
addresses: JAVA-785
💚 How did you test it?
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
The next PR stages nav transactions requested without the nav lease.
#skip-changelog