Skip to content

fix: crash when returning to foreground#875

Open
jvsena42 wants to merge 5 commits intomasterfrom
fix/crash-return-foreground
Open

fix: crash when returning to foreground#875
jvsena42 wants to merge 5 commits intomasterfrom
fix/crash-return-foreground

Conversation

@jvsena42
Copy link
Copy Markdown
Member

@jvsena42 jvsena42 commented Mar 30, 2026

Fixes #871

This PR:

  1. Fixes a crash (IndexOutOfBoundsException) when returning the app to the foreground on the Receive screen
  2. Shows a loading state on the Spending tab when the node is not running instead of displaying a stale invoice

Description

When the app goes to the background, the Lightning node stops and channels become unavailable. On return, the AUTO tab is removed from visible tabs but selectedTab still references it, causing an index of -1 to be passed to the tab row — triggering the crash.

The fix resets the selected tab when it's no longer in the visible tabs list and adds a defensive index clamp in the tab row component. Additionally, the Spending tab now returns an empty invoice when the node is not running, showing the QR placeholder loading state instead of a stale bolt11 invoice.

Preview

bg-qr-code.webm

QA Notes

  1. Open the Receive screen with a Lightning channel active (AUTO tab visible)
  2. Select the AUTO tab
  3. Background the app and wait a few seconds for the node to stop
  4. Return the app to foreground
  5. Verify: no crash occurs and the tab resets to Savings
  6. Navigate to the Spending tab while the node is still restarting
  7. Verify: the Spending tab shows a loading placeholder instead of a QR code
  8. Wait for the node to finish starting
  9. Verify: the Spending tab shows the Lightning invoice QR code

Note: only happens when FG service is disabled

jvsena42 and others added 5 commits March 30, 2026 14:48
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jvsena42 jvsena42 self-assigned this Mar 30, 2026
@jvsena42 jvsena42 added this to the 2.2.0 milestone Mar 30, 2026
@claude
Copy link
Copy Markdown

claude bot commented Mar 30, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@jvsena42 jvsena42 requested a review from ovitrif March 30, 2026 18:15
@jvsena42 jvsena42 enabled auto-merge March 30, 2026 18:16
@ovitrif
Copy link
Copy Markdown
Collaborator

ovitrif commented Mar 30, 2026

Can you also please fix the issue with the transition from Spending to Auto always showing when there are lightning channel the moment user opens the Receive Sheet?!
there should be a way to "not transition"/ start on "auto" from the start.

Thx in advance 🙏🏻

@ovitrif
Copy link
Copy Markdown
Collaborator

ovitrif commented Mar 30, 2026

Can you also please fix the issue with the transition from Spending to Auto always showing when there are lightning channel the moment user opens the Receive Sheet?! there should be a way to "not transition"/ start on "auto" from the start.

Thx in advance 🙏🏻

Nvm I opened a new issue to be fixed in a separate PR:

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.

[Bug]: Crash when returning app to foreground

2 participants