Skip to content

fix: update scene phase change logic#473

Merged
pwltr merged 3 commits intomasterfrom
fix/scene-phase
Mar 10, 2026
Merged

fix: update scene phase change logic#473
pwltr merged 3 commits intomasterfrom
fix/scene-phase

Conversation

@pwltr
Copy link
Copy Markdown
Contributor

@pwltr pwltr commented Mar 4, 2026

When the app is backgrounded, the process can be either suspended or terminated. (Overdue) Refresh timers for exchange rates and orders will run on resume, so scene phase no longer triggers them and only clears delivered notifications. Peer reconnection is triggered when becoming active so channel peers come back quickly instead of waiting for LDK’s internal timer. The Lightning node is no longer stopped in background, so after a suspend it can resume without a full restart. In case of termination, all of the normal startup logic will run.

Changes

  • remove unnecessary logic on scene phase .background/.foreground (also fixes a case where node fails to start after being backgrounded)
  • explicitly reconnect to peers instead of relying on background timer

Screenshots

Simulator.Screen.Recording.-.iPhone.17.-.2026-03-04.at.11.21.02.mov

QA Notes

Should be able to use the app normally immediately after resuming including Lightning channels.

Inactive only (no background)

  • Example: User opens Control Center or an overlay; scene goes .inactive then .active. Process is not suspended.
  • Expect: App continues normally.

App backgrounded (suspended, not killed)

  • Process: Remains in memory; execution is suspended.
  • Scene phase: Goes to .background. We do not stop the Lightning node; it simply stops receiving CPU.
  • On resume: Scene goes .inactive then .active. Run loop runs again; LDK resumes (e.g. timer_tick, peer handling); (overdue) timers fire (fe. refresh rates, orders).
  • Expect: One refresh wave (rates + orders) when returning. No node stop in logs. Balances and spending work without restart.

App killed (swiped away or terminated by system)

  • Process: Exits. All in-memory state is lost.
  • On next launch (cold start): New process. Wallet/node start via handleWalletExistsChangestartWallet(), not from scene phase. View models perform an initial refresh in init.
  • Expect: App starts normally (cold start).

@pwltr pwltr force-pushed the fix/scene-phase branch from cca0cb5 to 231ab4b Compare March 4, 2026 10:12
@pwltr pwltr changed the title fix: remove stop/start node on app to background fix: update scene phase change logic Mar 4, 2026
@pwltr pwltr force-pushed the fix/scene-phase branch from 231ab4b to 135f7eb Compare March 4, 2026 10:17
@pwltr pwltr marked this pull request as ready for review March 4, 2026 10:17
@pwltr pwltr force-pushed the fix/scene-phase branch from 135f7eb to bf0aff6 Compare March 4, 2026 10:18
@pwltr pwltr self-assigned this Mar 4, 2026
Comment thread Bitkit/Services/LightningService.swift Outdated
@pwltr pwltr requested a review from ben-kaufman March 4, 2026 16:55
Comment thread Bitkit/Services/LightningService.swift Outdated
Comment thread Bitkit/Services/LightningService.swift Outdated
@pwltr pwltr force-pushed the fix/scene-phase branch from 174ea38 to 2a323fd Compare March 9, 2026 12:55
@pwltr pwltr requested a review from ben-kaufman March 9, 2026 12:56
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review

1 issue found. Checked for bugs and CLAUDE.md compliance.

Comment thread Bitkit/AppScene.swift
@pwltr pwltr added this to the 2.2.0 milestone Mar 9, 2026
@pwltr pwltr merged commit d3e8fbe into master Mar 10, 2026
14 checks passed
@pwltr pwltr deleted the fix/scene-phase branch March 10, 2026 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants