Repository navigation
fix(startup): keep screens responsive while a large wallet loads - #1772
Conversation
Every launch loads the wallet off the main thread, and each new activity waited for that load in onActivityPreCreated on the main thread. On a large wallet the wait lasts seconds, and a Back press during it is an input-dispatch ANR, which counts toward safe mode. Screens marked WalletLoadAware no longer wait there. They check isLaunchWalletLoadInProgress() before anything reads the wallet: - OnboardingActivity shows the splash and recreates itself once the load has finished; - LockScreenActivity (every subclass) and the shortcut screens hand over to it, and a fresh start keeps its intent (a payment or App Connect link, a shortcut) to open once the wallet is loaded; a restored screen comes back on the home screen; - the transparent link and share handlers wait in place without blocking, so a caller's result and a share's grant are kept. Any other screen still waits before it is created, as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nts restore Pre-review of the responsive-loading change: - a screen started for a result, or whose intent carries content access, no longer hands over to the loading screen: finishing it would cancel its caller's result or drop the grant. It waits for the load as before; - the hand-over is decided before super.onCreate, which restored saved fragments that read the wallet as they attach (the address book's lists, the network monitor's block list); a screen that hands over restores none; - Back on the loading screen discards the link it was waiting to open, so a later launch does not open it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…dles onNewIntent handled getIntent(), which is still the first intent, so a second link delivered while the wallet loaded was lost and the first one handled twice. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review: 2
Please check the settings in the CodeRabbit UI or the
|
|
⛔ Final review complete — 2 blocking finding(s) (commit ca17501) · triage: normal |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
Changes requested: 6 blockers
- A restored payment request is discarded during cold-start handover —
wallet/src/de/schildbach/wallet/ui/LockScreenActivity.kt:201-205(new)
Impact: If Android restores SendCoinsActivity after killing the wallet process while its launch load is running, the payment request is replaced by the home screen and any caller receives cancellation instead of the request being reviewed. - Back can leave a cancelled entry link queued after loading completes —
wallet/src/de/schildbach/wallet/ui/OnboardingActivity.kt:206-214(new)
Impact: If the user presses Back after the load callback clearsloadingEntryIntentbut before the recreated onboarding activity claims the pending intent, the cancelled payment or shortcut can open on a later unrelated launch. - The handed-over entry link is lost if the loading process is killed —
wallet/src/de/schildbach/wallet/ui/OnboardingActivity.kt:160-168(new)
Impact: If Android reclaims the process while the onboarding splash is backgrounded, the recreated wallet opens normally but drops the payment, invite, or shortcut that initiated the launch. - External payment screens still freeze while the wallet loads —
wallet/src/de/schildbach/wallet/ui/LockScreenActivity.kt:201-214(new; not shown inline, see below)
Impact: A payment opened through BitcoinIntegration.requestForResult() or a content-backed request can still block the main thread for the full wallet parse and trigger the startup input-dispatch ANR. - Deferred entry links disappear when the one-time security upgrade is required —
wallet/src/de/schildbach/wallet/ui/OnboardingActivity.kt:444-449(new; not shown inline, see below)
Impact: A payment, App Connect, or shortcut link received during wallet loading is lost when the wallet requires the PIN/security upgrade, so the user reaches an ordinary home screen instead of the requested flow. - A second wallet URI can produce a result for the previous URI —
wallet/src/de/schildbach/wallet/ui/WalletUriHandlerActivity.kt:63-69(new; not shown inline, see below)
Impact: When an existing URI handler receives another payment, master-key, or address request through onNewIntent(), the caller can receive a result containing the first URI's request data even though the second URI was handled.
This change lets selected entry activities avoid the main-thread wallet-load wait and routes fresh launches through a responsive onboarding splash, while preserving caller-sensitive handlers in place. The build and check CI jobs passed, CodeRabbit passed, and the review check is still in progress; no device verification was performed.
🔴 6 blocking
3 finding(s) not shown inline (the lines are not part of this PR's diff)
🔴 Blocking: External payment screens still freeze while the wallet loads
Impact: A payment opened through BitcoinIntegration.requestForResult() or a content-backed request can still block the main thread for the full wallet parse and trigger the startup input-dispatch ANR.
wallet/src/de/schildbach/wallet/ui/LockScreenActivity.kt:201-214
These supported payment flows still become unresponsive during a large-wallet launch. handsOverWhileWalletLoads() deliberately returns false when the activity has a calling activity or carries content access, so the original activity and its result/grant are retained; however, this path then reaches isWalletLoadDegraded and walletData.wallet, both of which synchronously wait for the deferred load, and restored fragments may read the wallet during super.onCreate() even earlier. Keep the original activity and its caller/grants, but add an asynchronous lifecycle-aware readiness path in LockScreenActivity that defers wallet-dependent setup and fragment restoration until the load completes.
source: gpt-6.2-sol (phase2-reviewer: general, security-auditor)
🔴 Blocking: Deferred entry links disappear when the one-time security upgrade is required
Impact: A payment, App Connect, or shortcut link received during wallet loading is lost when the wallet requires the PIN/security upgrade, so the user reaches an ordinary home screen instead of the requested flow.
wallet/src/de/schildbach/wallet/ui/OnboardingActivity.kt:444-449
pendingEntryIntent is consumed only by startMainActivity(). When SecurityGuard.isConfiguredQuickCheck() is false, this branch starts AppUpgradeActivity without transferring the pending entry; AppUpgradeActivity.onCorrectPin() then starts a plain MainActivity, leaving the request stranded in the onboarding instance underneath. Keep the pending entry associated with the upgrade flow and dispatch it exactly once after successful PIN setup, discarding it if the upgrade is cancelled.
source: gpt-6.2-sol (phase2-reviewer: general, security-auditor)
🔴 Blocking: A second wallet URI can produce a result for the previous URI
Impact: When an existing URI handler receives another payment, master-key, or address request through onNewIntent(), the caller can receive a result containing the first URI's request data even though the second URI was handled.
wallet/src/de/schildbach/wallet/ui/WalletUriHandlerActivity.kt:63-69
The new onNewIntent() path passes the delivered intent to handleIntent(), but it never calls setIntent() or otherwise associates the delivered request with the result callbacks. Those callbacks still read intent.data from the activity's original stored intent at lines 67, 182, and 199. Consequently, the second request can be launched while the result is constructed from the first request. Track the request data alongside the specific operation, or update and consistently use the delivered intent for the matching callback.
source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.2-sol (phase2-reviewer: general, security-auditor)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 5: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
normalbygpt-6.2-sol(effort low) — This is a substantial, cross-cutting Android lifecycle and startup-routing change with concurrency, intent handoff, state restoration, and activity-result behavior, but it does not modify consensus, funds movement, cryptography, key handling, peer-facing deserialization, or storage migrations. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - Second Phase-2 pass: on this first full review every Phase-2 reviewer also ran a second, independent time, and the verifier weighed both sets
- Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— security-auditor (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `wallet/src/de/schildbach/wallet/ui/LockScreenActivity.kt`:
- [BLOCKING] wallet/src/de/schildbach/wallet/ui/LockScreenActivity.kt:201-214: External payment screens still freeze while the wallet loads
Impact: A payment opened through BitcoinIntegration.requestForResult() or a content-backed request can still block the main thread for the full wallet parse and trigger the startup input-dispatch ANR.
These supported payment flows still become unresponsive during a large-wallet launch. `handsOverWhileWalletLoads()` deliberately returns false when the activity has a calling activity or carries content access, so the original activity and its result/grant are retained; however, this path then reaches `isWalletLoadDegraded` and `walletData.wallet`, both of which synchronously wait for the deferred load, and restored fragments may read the wallet during `super.onCreate()` even earlier. Keep the original activity and its caller/grants, but add an asynchronous lifecycle-aware readiness path in `LockScreenActivity` that defers wallet-dependent setup and fragment restoration until the load completes.
- [BLOCKING] wallet/src/de/schildbach/wallet/ui/LockScreenActivity.kt:201-205: A restored payment request is discarded during cold-start handover
Impact: If Android restores SendCoinsActivity after killing the wallet process while its launch load is running, the payment request is replaced by the home screen and any caller receives cancellation instead of the request being reviewed.
The handover branch passes `null` to `super.onCreate()` and sets `keepIntent` from `savedInstanceState == null`. A restored SendCoinsActivity therefore does not pass its saved state to the subclass, which is where `PaymentIntent` is restored, and it does not copy the original intent into the application handoff; `redirectWhileWalletLoads()` then clears the task. Preserve the restored payment state through an asynchronous wait in the original activity, or use a private saved-state-backed handoff that restores the same request without trusting exported launcher extras.
In `wallet/src/de/schildbach/wallet/ui/OnboardingActivity.kt`:
- [BLOCKING] wallet/src/de/schildbach/wallet/ui/OnboardingActivity.kt:444-449: Deferred entry links disappear when the one-time security upgrade is required
Impact: A payment, App Connect, or shortcut link received during wallet loading is lost when the wallet requires the PIN/security upgrade, so the user reaches an ordinary home screen instead of the requested flow.
`pendingEntryIntent` is consumed only by `startMainActivity()`. When `SecurityGuard.isConfiguredQuickCheck()` is false, this branch starts `AppUpgradeActivity` without transferring the pending entry; `AppUpgradeActivity.onCorrectPin()` then starts a plain `MainActivity`, leaving the request stranded in the onboarding instance underneath. Keep the pending entry associated with the upgrade flow and dispatch it exactly once after successful PIN setup, discarding it if the upgrade is cancelled.
- [BLOCKING] wallet/src/de/schildbach/wallet/ui/OnboardingActivity.kt:206-214: Back can leave a cancelled entry link queued after loading completes
Impact: If the user presses Back after the load callback clears `loadingEntryIntent` but before the recreated onboarding activity claims the pending intent, the cancelled payment or shortcut can open on a later unrelated launch.
The completion callback sets `loadingEntryIntent = null` before calling `recreate()`. If Back finishes the old splash in that window, `onDestroy()` has no identity to pass to `discardPendingEntryIntent()`, so the application-level pending intent remains queued. Retain the cancellation identity until the replacement activity actually claims the entry, and explicitly discard it when Back is handled.
- [BLOCKING] wallet/src/de/schildbach/wallet/ui/OnboardingActivity.kt:160-168: The handed-over entry link is lost if the loading process is killed
Impact: If Android reclaims the process while the onboarding splash is backgrounded, the recreated wallet opens normally but drops the payment, invite, or shortcut that initiated the launch.
The handed-over request exists only in `WalletApplication.pendingEntryIntent` and the activity-local `loadingEntryIntent`; neither is saved in instance state or persisted. After process death, the new application has no pending entry, and the recreated onboarding screen therefore takes null at line 221 and routes to home. Persist a sanitized app-owned representation through the loading screen's saved state and restore it into the in-process handoff before normal routing.
In `wallet/src/de/schildbach/wallet/ui/WalletUriHandlerActivity.kt`:
- [BLOCKING] wallet/src/de/schildbach/wallet/ui/WalletUriHandlerActivity.kt:63-69: A second wallet URI can produce a result for the previous URI
Impact: When an existing URI handler receives another payment, master-key, or address request through onNewIntent(), the caller can receive a result containing the first URI's request data even though the second URI was handled.
The new `onNewIntent()` path passes the delivered intent to `handleIntent()`, but it never calls `setIntent()` or otherwise associates the delivered request with the result callbacks. Those callbacks still read `intent.data` from the activity's original stored intent at lines 67, 182, and 199. Consequently, the second request can be launched while the result is constructed from the first request. Track the request data alongside the specific operation, or update and consistently use the delivered intent for the matching callback.
| val handOver = handsOverWhileWalletLoads(walletApplicationBeforeInjection()) | ||
| super.onCreate(if (handOver) null else savedInstanceState) | ||
|
|
||
| if (handOver && redirectWhileWalletLoads(walletApplication, keepIntent = savedInstanceState == null)) { | ||
| finishedForNoWallet = true |
There was a problem hiding this comment.
✅ Resolved at
ca175015; see the replies below.
🔴 Blocking: A restored payment request is discarded during cold-start handover
Impact: If Android restores SendCoinsActivity after killing the wallet process while its launch load is running, the payment request is replaced by the home screen and any caller receives cancellation instead of the request being reviewed.
The handover branch passes null to super.onCreate() and sets keepIntent from savedInstanceState == null. A restored SendCoinsActivity therefore does not pass its saved state to the subclass, which is where PaymentIntent is restored, and it does not copy the original intent into the application handoff; redirectWhileWalletLoads() then clears the task. Preserve the restored payment state through an asynchronous wait in the original activity, or use a private saved-state-backed handoff that restores the same request without trusting exported launcher extras.
source: gpt-6.2-sol (phase2-reviewer: general, security-auditor)
There was a problem hiding this comment.
Fixed in 3ad9e98: a screen the system restores no longer hands over. handsOverWhileWalletLoads takes restoring = savedInstanceState != null, so a restored SendCoinsActivity keeps its saved state and its caller and waits in place, as before this PR. Test: while the launch load runs a restored screen waits in place and keeps its saved state. That restored screen still waits on the main thread; that part is known gap 1 in the description.
There was a problem hiding this comment.
Resolved (re-reviewed at ca175015): The restoring check you added keeps the original activity and passes the saved bundle through to the payment restoration code. The synchronous wait is separate from the loss of saved payment state.
| if (loading && walletApplication.isLaunchWalletLoadInProgress) { | ||
| log.info("the wallet is still loading — showing the splash until it has loaded") | ||
| loadingEntryIntent = walletApplication.peekPendingEntryIntent() | ||
| afterLaunchWalletLoad(walletApplication) { | ||
| // Created again with the wallet loaded: the link it waits for | ||
| // now belongs to the new screen. | ||
| loadingEntryIntent = null | ||
| recreate() | ||
| } |
There was a problem hiding this comment.
🔴 Blocking: Back can leave a cancelled entry link queued after loading completes
Impact: If the user presses Back after the load callback clears loadingEntryIntent but before the recreated onboarding activity claims the pending intent, the cancelled payment or shortcut can open on a later unrelated launch.
The completion callback sets loadingEntryIntent = null before calling recreate(). If Back finishes the old splash in that window, onDestroy() has no identity to pass to discardPendingEntryIntent(), so the application-level pending intent remains queued. Retain the cancellation identity until the replacement activity actually claims the entry, and explicitly discard it when Back is handled.
source: gpt-6.2-sol (phase2-reviewer: general, security-auditor)
There was a problem hiding this comment.
Fixed in 3ad9e98: the load callback no longer clears loadingEntryIntent before recreate(). The identity stays set until the recreated screen takes the link, so a Back that finishes the splash in between still discards it in onDestroy; recreate() is not a finish, so it discards nothing. Since ca17501 the recreation also waits until the screen is in front.
There was a problem hiding this comment.
Still applies (re-reviewed at ca175015): Keeping the cancellation identity fixes the case where finishing wins, but the resumed check does not make Android's Back finish synchronous. The framework can post the finish behind the relaunch, so the replacement can still claim the link before the old instance sees isFinishing.
| /** The intent of a screen that handed over to this one while the wallet loaded. See [onCreate]. */ | ||
| private var pendingEntryIntent: Intent? = null | ||
|
|
||
| /** | ||
| * On the loading screen: the pending entry intent it is waiting to open. | ||
| * Discarded when the user closes the loading screen (Back), so the link | ||
| * does not open on a later, unrelated launch. | ||
| */ | ||
| private var loadingEntryIntent: Intent? = null |
There was a problem hiding this comment.
🔴 Blocking: The handed-over entry link is lost if the loading process is killed
Impact: If Android reclaims the process while the onboarding splash is backgrounded, the recreated wallet opens normally but drops the payment, invite, or shortcut that initiated the launch.
The handed-over request exists only in WalletApplication.pendingEntryIntent and the activity-local loadingEntryIntent; neither is saved in instance state or persisted. After process death, the new application has no pending entry, and the recreated onboarding screen therefore takes null at line 221 and routes to home. Persist a sanitized app-owned representation through the loading screen's saved state and restore it into the in-process handoff before normal routing.
source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.2-sol (phase2-reviewer: general, security-auditor)
There was a problem hiding this comment.
Deferred to #1777 (section 2): keeping the handed-over link through process death needs a saved-state hand-off on the loading screen, a new mechanism outside this PR's scope. Listed as known gap 2 in the description.
There was a problem hiding this comment.
Still applies (re-reviewed at ca175015): Section 2 of #1777 describes the right saved-state follow-up, but the new task replacement is what removes Android's original entry intent, and waiting for resume extends the memory-only window. I’ve lowered this to a suggestion because the user can reopen the link and no payment was submitted.
…let-load-screens-stay-responsive # Conflicts: # wallet/test/de/schildbach/wallet/WalletApplicationStartWalletLoadTest.kt
…d link is the one answered - A screen the system restores (a payment under review after the process died) no longer hands over to the loading screen: its saved state is not in its intent. It waits in place, as before. - The loading screen keeps its link's identity until the recreated screen takes it, so a Back in between still discards the link. - WalletUriHandlerActivity makes a delivered request its intent when it handles it, so the result callbacks answer that request. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lash routes only in front - WalletUriHandlerActivity.onNewIntent handles getIntent() again, as before the wallet-load wait: a request still in flight is answered with its own data, never a later request's. - The loading screen recreates itself only once resumed, so a load that ends after the user switched apps does not bring the wallet back over them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
QA run 56 — PASS, including the mid-load linkTested on a wallet whose parse takes ~4 seconds (73,724,772 bytes), which is what makes the race reachable at all. Screens stay usable while it loadsCold start: the wallet is handed off 38 ms in, parsed on A link delivered to a waiting handlerThis is the commit I wanted to see fail and couldn't. Force-stop, launch, then fire the link 1,256 ms into the 4-second parse — the window where there is no wallet yet to hand it to: After the load finished, the Send screen carried exactly that payee and amount: Not dropped, not substituted, not a stale intent. Backed out with BACK without sending; nothing was broadcast (0 matches for any broadcast marker). Run twice, on both the int42 and the final int43 cut — the link arrived intact at +1322 ms and +1256 ms respectively. This PR carries #1765, so the two merged as one. QA run 56, 2026-11-30. Build 12000305 (12.0.3-qa05), branch |
afterLaunchWalletLoad runs its callback, after a wait, only once the screen is resumed, and InviteHandlerActivity routes only in front after reading the invite: a load that ends while the user is in another app no longer brings the wallet back over it. OnboardingActivity's own gate moves into the helper. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Fixed in 56579b3: "A second wallet URI can produce a result for the previous URI" ( Also in ca17501 (from a local review round): after a wait, the deferred handlers and the loading screen go on only with their screen in front, so a load that ends while the user is in another app no longer brings the wallet back over it. |
|
Deferred to #1777, as new mechanisms outside this PR's scope (known gaps 1 and 3 in the description):
|
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Changes requested: 2 blockers
- A second wallet URI can replay or cancel the first request during a cold start —
wallet/src/de/schildbach/wallet/ui/WalletUriHandlerActivity.kt:78-101(new; not shown inline, see below)
Impact: A user whose app redelivers a URI to a waiting wallet handler can lose the first request or see two send screens for it and pay twice if they approve both. - Back can leave a cancelled entry link queued after loading completes —
wallet/src/de/schildbach/wallet/ui/OnboardingActivity.kt:208-225(thread, carried)
Impact: A user who presses Back on the loading splash as the wallet finishes loading can still see the payment or shortcut they cancelled open.
New on this head: This revision keeps restored payment screens in place, ties wallet URI results to the original request, and waits for deferred screens to resume before navigating. The build and check jobs passed on the assigned head; CodeRabbit was skipped for this base branch, and PastaClaw review was pending.
🔴 2 blocking | 🟡 2 suggestion(s)
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🔴 Blocking: A second wallet URI can replay or cancel the first request during a cold start
Impact: A user whose app redelivers a URI to a waiting wallet handler can lose the first request or see two send screens for it and pay twice if they approve both.
wallet/src/de/schildbach/wallet/ui/WalletUriHandlerActivity.kt:78-101
One payment request can produce two send screens or close without being shown. The exported handler can receive another delivery on the same top instance via FLAG_ACTIVITY_SINGLE_TOP. During the load, onCreate() and onNewIntent() both register callbacks, and since 56579b30f both dispatch the original intent. If the handler is resumed at completion, both callbacks can run in the same main-thread delivery before the first child launch pauses it. Neither launch marks the request as dispatched, and each send activity has its own confirmation and send guard. Conversely, since ca1750158, if the handler is paused when the load finishes, the first callback still awaits resume. Android can deliver a new intent before resume, for example to the top activity while the device is asleep. That delivery skips the wait because the application load is done, but the activity's wallet field is still null, so it finishes with RESULT_CANCELED. Keep the original intent for result construction and use one pending/in-flight state so only the initialization callback can dispatch it, at most once.
Confirmed by an independent pass: An exported WalletUriHandlerActivity can receive a second ACTION_VIEW with FLAG_ACTIVITY_SINGLE_TOP while the first instance is waiting for the launch wallet load, registering two completion callbacks. When the load finishes while the handler is resumed, both callbacks can execute before the activity pauses and each calls handleIntent(getIntent()), launching duplicate SendCoinsActivity instances for the same request; alternatively, if completion occurs while the handler is paused, a subsequent onNewIntent sees the load as finished and calls handleIntent immediately while wallet is still null, causing RESULT_CANCELED and losing the request.
source: gpt-6.2-sol (phase2-reviewer: general, security-auditor)
Still open from earlier rounds (2)
- 🔴 Blocking: Back can leave a cancelled entry link queued after loading completes —
wallet/src/de/schildbach/wallet/ui/OnboardingActivity.kt:208-225(thread) - 🟡 Suggestion: The handed-over entry link is lost if the loading process is killed —
wallet/src/de/schildbach/wallet/ui/OnboardingActivity.kt:206-225(thread)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
normalbygpt-6.2-sol(effort low) — This is a substantial, cross-cutting Android lifecycle and startup-flow change with concurrency, state restoration, intent routing, and UI responsiveness implications, but it does not modify funds movement, cryptography, key handling, consensus, peer-facing deserialization, or storage migrations. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - New since the last final review (
57d075c0): 1 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 1 confirmed - Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `wallet/src/de/schildbach/wallet/ui/WalletUriHandlerActivity.kt`:
- [BLOCKING] wallet/src/de/schildbach/wallet/ui/WalletUriHandlerActivity.kt:78-101: A second wallet URI can replay or cancel the first request during a cold start
Impact: A user whose app redelivers a URI to a waiting wallet handler can lose the first request or see two send screens for it and pay twice if they approve both.
One payment request can produce two send screens or close without being shown. The exported handler can receive another delivery on the same top instance via `FLAG_ACTIVITY_SINGLE_TOP`. During the load, `onCreate()` and `onNewIntent()` both register callbacks, and since `56579b30f` both dispatch the original intent. If the handler is resumed at completion, both callbacks can run in the same main-thread delivery before the first child launch pauses it. Neither launch marks the request as dispatched, and each send activity has its own confirmation and send guard. Conversely, since `ca1750158`, if the handler is paused when the load finishes, the first callback still awaits resume. Android can deliver a new intent before resume, for example to the top activity while the device is asleep. That delivery skips the wait because the application load is done, but the activity's `wallet` field is still null, so it finishes with `RESULT_CANCELED`. Keep the original intent for result construction and use one pending/in-flight state so only the initialization callback can dispatch it, at most once.
_Confirmed by an independent pass: An exported WalletUriHandlerActivity can receive a second ACTION_VIEW with FLAG_ACTIVITY_SINGLE_TOP while the first instance is waiting for the launch wallet load, registering two completion callbacks. When the load finishes while the handler is resumed, both callbacks can execute before the activity pauses and each calls handleIntent(getIntent()), launching duplicate SendCoinsActivity instances for the same request; alternatively, if completion occurs while the handler is paused, a subsequent onNewIntent sees the load as finished and calls handleIntent immediately while wallet is still null, causing RESULT_CANCELED and losing the request._
In `wallet/src/de/schildbach/wallet/ui/OnboardingActivity.kt`:
- [SUGGESTION] wallet/src/de/schildbach/wallet/ui/OnboardingActivity.kt:429-469: Deferred entry links disappear when the one-time security upgrade is required
Impact: A user who opens a payment link during a cold start on a wallet that still needs a security upgrade reaches home after setup and must reopen the link.
Completing the required security upgrade does not reopen the request that launched the wallet. Before this PR, the direct entry activity kept the request while waiting for the wallet. The handoff now finishes that activity and leaves its request in `OnboardingActivity`, where only `startMainActivity()` replays it. Both `AppUpgradeActivity` and the unencrypted-wallet `SetPinActivity` path start a plain `MainActivity` on success. Keep the request with the handoff until setup succeeds, then replay it once; discard it if setup is cancelled.
- [BLOCKING] wallet/src/de/schildbach/wallet/ui/OnboardingActivity.kt:208-225: Back can leave a cancelled entry link queued after loading completes
(carried; thread: https://github.com/dashpay/dash-wallet/pull/1772#discussion_r4746752668)
- [SUGGESTION] wallet/src/de/schildbach/wallet/ui/OnboardingActivity.kt:206-225: The handed-over entry link is lost if the loading process is killed
(carried; thread: https://github.com/dashpay/dash-wallet/pull/1772#discussion_r4746752674)
| val intent = Intent(this, MainActivity::class.java).apply { | ||
| putExtras([email protected] ?: Bundle()) | ||
| } | ||
| startActivity(intent) | ||
| val entry = pendingEntryIntent | ||
| pendingEntryIntent = null | ||
| when { | ||
| entry == null -> startActivity(intent) | ||
| // The home screen itself, started by a link (App Connect, a key | ||
| // import): open it with that link. | ||
| entry.component?.className in MAIN_ACTIVITY_CLASS_NAMES -> startActivity(entry) | ||
| // Another screen (a payment link, a shortcut) opens on top of the | ||
| // home screen, so Back from it lands in the wallet. | ||
| else -> startActivities(arrayOf(intent, entry)) |
There was a problem hiding this comment.
🟡 Suggestion: Deferred entry links disappear when the one-time security upgrade is required
Impact: A user who opens a payment link during a cold start on a wallet that still needs a security upgrade reaches home after setup and must reopen the link.
Completing the required security upgrade does not reopen the request that launched the wallet. Before this PR, the direct entry activity kept the request while waiting for the wallet. The handoff now finishes that activity and leaves its request in OnboardingActivity, where only startMainActivity() replays it. Both AppUpgradeActivity and the unencrypted-wallet SetPinActivity path start a plain MainActivity on success. Keep the request with the handoff until setup succeeds, then replay it once; discard it if setup is cancelled.
source: gpt-6.2-sol (phase2-reviewer: general, security-auditor)
| val handOver = handsOverWhileWalletLoads(walletApplicationBeforeInjection()) | ||
| super.onCreate(if (handOver) null else savedInstanceState) | ||
|
|
||
| if (handOver && redirectWhileWalletLoads(walletApplication, keepIntent = savedInstanceState == null)) { | ||
| finishedForNoWallet = true |
There was a problem hiding this comment.
Resolved (re-reviewed at ca175015): The restoring check you added keeps the original activity and passes the saved bundle through to the payment restoration code. The synchronous wait is separate from the loss of saved payment state.
| if (loading && walletApplication.isLaunchWalletLoadInProgress) { | ||
| log.info("the wallet is still loading — showing the splash until it has loaded") | ||
| loadingEntryIntent = walletApplication.peekPendingEntryIntent() | ||
| afterLaunchWalletLoad(walletApplication) { | ||
| // Created again with the wallet loaded: the link it waits for | ||
| // now belongs to the new screen. | ||
| loadingEntryIntent = null | ||
| recreate() | ||
| } |
There was a problem hiding this comment.
Still applies (re-reviewed at ca175015): Keeping the cancellation identity fixes the case where finishing wins, but the resumed check does not make Android's Back finish synchronous. The framework can post the finish behind the relaunch, so the replacement can still claim the link before the old instance sees isFinishing.
| /** The intent of a screen that handed over to this one while the wallet loaded. See [onCreate]. */ | ||
| private var pendingEntryIntent: Intent? = null | ||
|
|
||
| /** | ||
| * On the loading screen: the pending entry intent it is waiting to open. | ||
| * Discarded when the user closes the loading screen (Back), so the link | ||
| * does not open on a later, unrelated launch. | ||
| */ | ||
| private var loadingEntryIntent: Intent? = null |
There was a problem hiding this comment.
Still applies (re-reviewed at ca175015): Section 2 of #1777 describes the right saved-state follow-up, but the new task replacement is what removes Android's original entry intent, and waiting for resume extends the memory-only window. I’ve lowered this to a suggestion because the user can reopen the link and no payment was submitted.
ca17501
into
fix/foreground-start-wallet-load-off-main
|
GitHub marked this PR merged because its commits are now on its base branch: it was folded into #1765 (now at e680151). #1765 replaces this PR's hand-over with a wait in place. While the launch's wallet load runs, a screen keeps its own activity, caller, grants, intent and saved state, then recreates itself once the load has finished. The details are in #1765's description. The open findings here, as they stand in #1765:
|
Issue being fixed or feature implemented
Stacked on #1765, which loads the wallet off the main thread on every launch. That PR's blocking review finding: each new activity still waited for the load in
WalletApplication.onActivityPreCreated, on the main thread. On a large wallet the wait lasts seconds (a 12.0.2 report: a 61.6 MB wallet file), and a Back press during it starts Android's 5-second "no focused window" timer. That ends in an input-dispatch ANR, which counts toward safe mode.What was done?
Screens marked with a new
WalletLoadAwareinterface skip the pre-create wait. Before anything reads the wallet they checkWalletApplication.isLaunchWalletLoadInProgress(), which never waits. While the load runs:OnboardingActivity(the launcher) is the loading screen. It shows only the splash (its theme's window background), so Back closes it. When the load finishes, either way, it recreates itself and routes as usual.LockScreenActivity(every subclass) and the shortcut screens hand over to it (redirectWhileWalletLoads).dash:payment link, App Connect, NFC, a shortcut) and opens it on top of the home screen once the wallet is loaded.WalletApplicationmemory, never in an extra, becauseOnboardingActivityis exported. The copy names this app's own component and carries no flags and no ClipData.SendCoinsActivity's payment under review) is not in its intent. It waits in place, as before this PR.super.onCreate, and a screen that hands over passes a null state. Otherwise saved fragments that read the wallet inonAttach(the address book lists, the network monitor's block list) would block during restore.afterLaunchWalletLoad):WalletUriHandlerActivity,InviteHandlerActivityandImportSharedImageActivity. A calling app keeps its result, and a share keeps its content grant. After a wait they go on only with their screen in front, and the invite handler routes only in front after reading the invite.WalletUriHandlerActivity.onNewIntentre-handles its first request, as before, so a request still in flight is answered with its own data.Known gaps (from the last local review round), tracked in #1777
SendCoinsActivityrestored after process death, a payment another app started withBitcoinIntegration.requestForResult(), or a BIP70content:request. Handing those over would lose the saved payment, cancel the caller's result or drop the grant, so they keep the old behaviour. Fixing it needs a non-blocking wait insideLockScreenActivitywhile its subclasses run, which is a larger design change.AppUpgradeActivity, orSetPinActivityfor an unencrypted wallet) instead of straight toMainActivity. It would need to be carried through the upgrade.Related PR's and Dependencies
Stacked on #1765; retarget to
feat/kotlin-sdk-phase-1once that merges. Same 12.0.2 report as #1766 and #1767.Screenshots / Videos
None.
How Has This Been Tested?
New tests:
WalletApplicationStartWalletLoadTest,LockScreenActivityCreateGateTest,WalletLoadAwareEntryTest,RecoveredWalletPersistenceTest,DeferredWalletLoadTest,SafeModeRetryWaitersTestand the invite tests pass on_testNet3Debug. ktlint reports nothing on the changed files.Local pre-review: two rounds before the first push, and two more after thepastaclaw's first review. Fixed from those: callers and grants, fragment restore, cancelled links, restored payments, the Back race at the end of the load, URI results, and navigation while in the background. What the last round still lists is the known gaps above.
New tests since the first push: a restored screen waits in place and keeps its saved fragments; a fresh screen hands over and a restored one never does; a load that ends while the user is in another app goes on only once the screen is back in front (fails without the gate).
Not tested on a device. Not yet covered:
OnboardingActivity's loading path (it can't be built without Hilt in Robolectric);The planned check: cold-start a large testnet wallet and send
adb shell input keyevent KEYCODE_BACKduring the splash; open adash:link and an invite link during the load; restore after the process is killed.QA (Mobile Team)
Checklist:
🤖 Generated with Claude Code