Repository navigation
fix(ui): hold the navigation controller weakly in menu pages - #1392
Conversation
SwiftUI pages pushed onto a UIKit navigation controller kept a strong reference to that controller while their own hosting controller sat in its stack. A normal pop breaks that cycle, but a stack that is dropped or rebuilt with the page still on it (for example when MainTabbarController.configureControllers() replaces a tab's navigation controller) was never released. Same fix as the pages converted in #1220: `weak var vc: UINavigationController?` with optional-chained call sites, and a `guard let vc` where the controller is handed to an API that needs a non-optional one. Covers the Settings, Security, Tools, Governance, Explore, Connections, Identities (3 pages), Wallets, Wallet accounts, Wallet account detail, Sync info pages, the main menu (root of its stack) and the Masternode keys overview. UsernameMarketplaceScreen and DevnetSettingsHostingViewController already stored it weakly; their initializers now take an optional. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 54 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
✅ Final review complete — no blockers (commit b5fdaea) · triage: low |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
The weak navigation references are appropriate, but two stored closures still create retain cycles in the menu lifecycle this PR aims to fix. Both issues are confirmed at d1d16e9. Exact-head simulator tests and supporting CI checks passed; this verification was static and did not establish runtime deallocation.
🔴 2 blocking
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
normalbygpt-6.1-sol(effort low) — This is a cross-cutting UI ownership change across 19 files that requires checking weak-reference lifetimes and optional navigation paths, but does not change a critical surface. - 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.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— general (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 `DashWallet/Sources/UI/Menu/Security/SecurityMenuScreen.swift`:
- [BLOCKING] DashWallet/Sources/UI/Menu/Security/SecurityMenuScreen.swift:37-39: Capture Security's initializer navigation parameter weakly
The stored onHide closure captures the initializer parameter vc strongly, not the weak self.vc property. SecurityMenuScreen retains DelegateInternal, which retains onHide, leaving the cycle navigation controller → hosting controller → SecurityMenuScreen → DelegateInternal → onHide → navigation controller. Replacing or dropping a stack containing Security therefore still retains that stack despite the property change. Add [weak vc], matching WalletsScreen's reset delegate, and add a deallocation regression test that drops the containing stack.
In `DashWallet/Sources/UI/Menu/Main/MainMenuViewController.swift`:
- [BLOCKING] DashWallet/Sources/UI/Menu/Main/MainMenuViewController.swift:150-152: Also break the root menu's support-callback retain cycle
Weakening vc removes the direct navigation-controller reference, but MainMenuScreen still retains onContactSupport. setupSwiftUIView() constructs that callback with a strong self capture in both compilation branches (lines 109–110 and 117–118), creating the independent cycle MainMenuViewController → hostingController → MainMenuScreen → onContactSupport → MainMenuViewController. Consequently, a loaded More root and its hosted models remain alive after configureControllers() replaces the tab's stack, even if the navigation controller itself releases. This is part of the root-menu teardown explicitly covered by this PR. Capture [weak self] and call self?.presentSupportEmailController() in both branches; verify that the loaded root and its hosting controller deallocate when the stack is dropped.
- SecurityMenuScreen's onHide captured the init parameter vc strongly, not the weak property; it now captures it weakly. - MainMenuViewController's onContactSupport captured self strongly while the screen storing it is hosted by self; it now captures [weak self]. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
The complete base-to-head diff correctly weakens the menu pages' navigation-controller back-references and updates their call sites without introducing a new ownership or navigation defect. Both prior blocking findings are fixed at this head: the root support callback captures its owner weakly in both compilation branches, and Security's initializer callback captures its navigation parameter weakly. Accessibility, test-membership, workflow-lint, and PR-title checks passed; simulator tests remain queued.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)
Review provenance
Source: reviewer 1: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
lowbygpt-6.1-sol(effort low) — This is a small, well-contained UI ownership fix that changes navigation-controller references from strong to weak without altering business logic or any critical surface. - Phase 1 reviewers:
glm-5.3-flash— general (completed, effort high); agentphase1-reviewer - Phase 1 model:
glm-5.3-flash— zai quota: 5h 81% left, weekly 62% left; passed overgemini-3.8-flash-high(antigravity quota lookup failed) - Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort medium); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.
No unresolved findings remain from the prior review on this head.
romchornyi-pitcrew
left a comment
There was a problem hiding this comment.
Verdict: ready to merge
No blockers or majors. Reviewed at b5fdaea. Static read only, nothing built.
| Level | Verdict |
|---|---|
| 1 · Idea | ✅ A real cycle: each page's hosting controller sits in the stack that its root view held strongly. A normal pop breaks it, but a stack dropped with the page on it leaked |
| 2 · Architecture | ✅ The same weak var vc pattern as #1220 |
| 3 · Completeness | ✅ A search for stored UINavigationController properties at this head finds no strong one left in DashWallet/ |
| 4 · Code | ✅ Clean |
Checked
- Every page receives the stack it is pushed onto, and that stack has a strong owner elsewhere. A tab's
BaseNavigationControlleris held byMainTabbarController, and a modal one by its presenter. Sovcis non-nil whenever the page is on screen, andguard let vc else { return }/vc?.can only no-op once the stack is already gone. Call sites checked:DashConnectHostingControllerHomeViewController+Shortcuts- the
MainMenuScreenNavigationLinks SyncInfoMenuScreen.pushKeysOverviewViewController
- The two pastaclaw blockers are fixed at this head.
SecurityMenuScreen'sonHidecaptures[weak vc], not the strong init parameter.- Both
onContactSupportclosures inMainMenuViewControllercapture[weak self].
- No other captures of the initializer parameter. None of the changed files has a closure that still captures the initializer's
vcparameter strongly.UsernameMarketplaceScreenalready used[weak vc]. - The UI-test fixture keeps its stack alive. It returns its plain
UINavigationControlleras the window root, so the weakvcstays alive there.
Recommendations (non-blocking)
- No deallocation test. The PR keeps to a static fix, as #1220 did. A unit test that replaces a tab's stack, or drops a
UINavigationControllerholding e.g.IdentitiesScreen, and asserts both deallocate would stop the pattern from coming back on the next page that copies the oldlet vc. - Preview
vcis nil. TheConnectionsScreenpreview passesUINavigationController()straight into a weak property (L256), so the preview'svcis nil from the start. That is harmless for a preview, butvc: nilsays it honestly. - Merge order with #1394. The two PRs conflict in 9 files (
MainMenuViewController,SettingsScreen,IdentitiesScreen,ToolsMenuScreen, …), because #1394 deletes thehidesBottomBarWhenPushedlines next to the call sites this PR rewrites. The resolution is mechanical (keepvc?., drop the flag), but whichever merges second needs a rebase.
🤖 Reviewed with Claude Code
Summary
Follow-up to #1220, as promised in its review: SwiftUI pages pushed onto a UIKit
UINavigationControllerkept a strong reference to that controller while their own hosting controller sat in its stack. A normal pop breaks the cycle, but a stack dropped or rebuilt with the page still on it (e.g.MainTabbarController.configureControllers()replacing a tab's navigation controller) was never released.Same pattern as #1220:
weak var vc: UINavigationController?withvc?.call sites, andguard let vcwhere the controller is handed to an API that needs a non-optional one.Pages changed
MainMenuScreen— it is not the stack's owner but the content of its root view controller, so it formed the same cycleKeysOverviewContentView(Masternode keys overview)UsernameMarketplaceScreenandDevnetSettingsHostingViewControlleralready stored the controller weakly; their initializers now just accept an optional.Testing
dashpayscheme builds for the simulatorscripts/a11y_audit.py --checkpasses🤖 Generated with Claude Code