Skip to content

fix: update scene phase change logic#473

Open
pwltr wants to merge 2 commits intomasterfrom
fix/scene-phase
Open

fix: update scene phase change logic#473
pwltr wants to merge 2 commits intomasterfrom
fix/scene-phase

Conversation

@pwltr
Copy link
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
@pwltr pwltr requested a review from ben-kaufman March 4, 2026 16:55
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.

2 participants