fix(filter): suppress subscription renewal in background mode#1303
Closed
xAlisher wants to merge 1 commit into
Closed
fix(filter): suppress subscription renewal in background mode#1303xAlisher wants to merge 1 commit into
xAlisher wants to merge 1 commit into
Conversation
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>
Author
|
Wrong repo — resubmitting to correct target. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On mobile (Android/iOS), Waku filter subscriptions have a relay-side TTL of ~13.5 minutes (observed). When a subscription expires, the
closingchannel fires insubscriptionLoop,checkAndResubscriberuns, and a newwf.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.BooltoSuband aSetBackgroundMode(bool)method to bothSubandFilterManager.When
background=true(screen locked):closingchannel are dropped without resubscriptionWhen
background=false(app returns to foreground):SetBackgroundMode(false)immediately sends toclosingto trigger a resubscriptionImpact
Messages sent while backgrounded are still delivered via the mailserver on foreground — not lost.
Usage (status-go)
Companion status-go PR: status-im/status-go#7508
🤖 Generated with Claude Code