Skip to content

fix: debounce tunnel tile updates to prevent notification flicker#1195

Closed
naonak wants to merge 1 commit into
wgtunnel:masterfrom
naonak:fix/notification-tile-flicker
Closed

fix: debounce tunnel tile updates to prevent notification flicker#1195
naonak wants to merge 1 commit into
wgtunnel:masterfrom
naonak:fix/notification-tile-flicker

Conversation

@naonak
Copy link
Copy Markdown
Contributor

@naonak naonak commented Mar 10, 2026

Problem

TunnelServiceHandler calls updateTunnelTile() on every activeTunnels emission. Because stats are polled every ~1 second, this causes Android to continuously redraw the foreground service notification, producing visible flicker in the notification shade even when no meaningful state has changed.

Fix

Map activeTunnels to status-only before collecting, then distinctUntilChanged() to suppress emissions where nothing changed. updateTunnelTile() now only fires on actual tunnel state transitions (tunnel added/removed, status change) — not on stats or ping updates.

activeTunnels
    .map { tunnels -> tunnels.mapValues { it.value.status } }
    .distinctUntilChanged()
    .collect { ... }

Impact

  • No behavior change for service start/stop logic
  • Tile and notification only update when tunnel status actually changes
  • Verified on 4.3.1 where the flicker was reproducible with an active tunnel

🤖 Generated with Claude Code

TunnelServiceHandler was calling updateTunnelTile() on every activeTunnels
emission, including high-frequency stats updates (every ~1 second). This
caused Android to continuously redraw the foreground service notification,
producing visible flicker in the notification shade.

Fix: map activeTunnels to status-only before collecting, then
distinctUntilChanged() to skip emissions where nothing meaningful changed.
updateTunnelTile() now only fires on actual tunnel state transitions
(added, removed, status change), not on stats or ping updates.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@naonak
Copy link
Copy Markdown
Contributor Author

naonak commented Mar 10, 2026

need more testing

@naonak naonak closed this Mar 10, 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