Repository navigation
feat(android): [Part 4] Prefer Activity ui.load transactions over Nav3 transactions - #6484
Open
0xadam-brown wants to merge 3 commits into
Open
0xadam-brown wants to merge 3 commits into
0xadam-brown wants to merge 3 commits into
Conversation
…nsactions The Nav3 lease is now also withdrawn when an Activity is created over the leaseholder, not only when it resumes. On API 29+, creation is reported from onActivityPreCreated, before ActivityLifecycleIntegration binds the new Activity's ui.load transaction, so the leaseholder's nav transaction no longer holds the scope's transaction slot and ui.load binds, as with Nav2. Errors and spans from the new Activity's onCreate and onStart are no longer attributed to the leaseholder on any API level. Because ui.load now binds, returning quickly to a nav root while the closed Activity's ui.load is still running would leave the nav root's transaction blocked. The coordinator therefore retries binding the leaseholder's nav transaction once when another Activity is destroyed, within 10s of the blocked attempt. Below API 29, there's no onActivityPreCreated, so the new Activity's ui.load stays unbound as before; this is documented in the package README.
This was referenced Nov 6, 2026
Contributor
|
📲 Install BuildsAndroid
|
…ifecycle-4-ui-load-preference
0xadam-brown
marked this pull request as ready for review
November 6, 2026 12:32
0xadam-brown
requested review from
markushi and
runningcode
and removed request for
a team
November 6, 2026 12:32
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 Lifecycle)
📜 Description
When the user opens an Activity from a Nav3 root, that Activity's
ui.loadtransaction is now bound to the scope instead of being blocked by the Nav3 root's nav transaction (API 29+), matching Nav2. A Nav3 transaction blocked by a closing Activity'sui.loadis retried once.ui.loadtransaction†ui.loadbinds in preference to the nav transaction, as it does with Nav2How this PR fixes things
This PR withdraws the lease when a covering Activity is created. On API 29+ this happens in
onActivityPreCreated, which runs beforeActivityLifecycleIntegrationtries to bindui.load, thereby allowing theui.loadtransaction to beat out the nav transaction.Below API 29 there's no
onActivityPreCreated, so creation is reported fromonActivityCreated, meaning the nav transaction beats out theui.loadtransaction.Known gaps
Documented in the package README.
ui.actiontransaction from the gesture that caused the return can still block the nav transaction.ui.load.Addressing the last two would require updating
ActivityLifecycleIntegrationto unbind a finishing Activity'sui.loadwhen it pauses. That'd change behavior for every app and not just users of Nav3, so I haven't included it here. We could follow-up at some point if we care to. Nicely, tackling things in ActivityLifecycleIntegration would have the happy side effect of simplifying the heuristics we have to use here.💡 Motivation and Context
Nav2 lets an Activity's
ui.loadtransaction take precedence, but Nav3 blocked it whenever the Activity was opened from a Nav3 root, so the Activity's auto-instrumented spans went elsewhere. Withdrawing the lease only on resume (#6483) also left the covering Activity'sonCreate/onStartwork attributed to the previous root.addresses: JAVA-785
💚 How did you test it?
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
Last PR in the stack. Once the stack is merged into the collection branch, squash-merge #6480 into
main.