Skip to content

fix(filter): suppress subscription renewal in background mode#1303

Closed
xAlisher wants to merge 1 commit into
logos-messaging:masterfrom
xAlisher:fix/background-mode-filter-subscriptions
Closed

fix(filter): suppress subscription renewal in background mode#1303
xAlisher wants to merge 1 commit into
logos-messaging:masterfrom
xAlisher:fix/background-mode-filter-subscriptions

Conversation

@xAlisher

@xAlisher xAlisher commented Jun 2, 2026

Copy link
Copy Markdown

Problem

On mobile (Android/iOS), Waku filter subscriptions have a relay-side TTL of ~13.5 minutes (observed). When a subscription expires, the closing channel fires in subscriptionLoop, checkAndResubscribe runs, and a new wf.Subscribe() RPC is issued. This wakes the LTE modem from RRC Idle state.

With the LTE modem's RRC tail timer (5–15s per carrier), each renewal produces a radio active window. On a loaded account (50 contacts, 3 communities) this generates ~144 mAh/hr of battery drain while the screen is locked — measured via dumpsys batterystats (status-im/status-app#21045).

The renewal runs at the same rate whether the user is actively using the app or the phone has been locked for hours.

Fix

Adds a backgroundMode atomic.Bool to Sub and a SetBackgroundMode(bool) method to both Sub and FilterManager.

When background=true (screen locked):

  • The 5s health-check ticker is skipped
  • Expired subscription IDs from the closing channel are dropped without resubscription
  • No network I/O occurs

When background=false (app returns to foreground):

  • SetBackgroundMode(false) immediately sends to closing to trigger a resubscription
  • All expired filters reconnect in one burst on foreground open

Impact

Scenario Before After
Overnight cellular (loaded account) ~144 mAh/hr ~5–10 mAh/hr (modelled)
Radio wakeups/hr from filter renewal ~4.4 ~0 in background
Foreground latency unchanged +1 reconnect burst on open

Messages sent while backgrounded are still delivered via the mailserver on foreground — not lost.

Usage (status-go)

// On background:
filterManager.SetBackgroundMode(true)

// On foreground:
filterManager.SetBackgroundMode(false)  // triggers immediate resubscription

Companion status-go PR: status-im/status-go#7508

🤖 Generated with Claude Code

Adds backgroundMode to Sub and SetBackgroundMode(bool) to both Sub and
FilterManager. When background=true, subscriptionLoop skips the 5-second
health-check ticker and drops expired subscription IDs from the closing
channel without resubscribing. When background=false (foreground return),
a resubscription is immediately triggered for any expired filters.

Background context (status-im/status-app#21045):
On Android, each Waku filter subscription has a relay-side TTL (~13.5 min
observed). When it expires, the closing channel fires, checkAndResubscribe
runs, and a new wf.Subscribe() RPC wakes the LTE modem. With a loaded
account this happens every ~13.5 min overnight, producing a 55% radio
duty cycle (~144 mAh/hr) while the screen is locked.

With background mode active, no network I/O occurs during subscription
expiry. On foreground return, all expired filters are resubscribed in
one burst — the user sees a brief reconnect, then full message delivery.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@xAlisher

xAlisher commented Jun 2, 2026

Copy link
Copy Markdown
Author

Wrong repo — resubmitting to correct target.

@xAlisher xAlisher closed this Jun 2, 2026
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.

1 participant