Skip to content

perf(quiescence): visibility-gate perpetual background timers (modalManager scan, email/tasks polls) #118

Description

@jdmanring

Problem (audit D1 + D2)

Several timers run perpetually regardless of whether the window is visible — keeping the app awake when backgrounded/idle:

  • D1: modalManager.js setInterval(_scanAndWire, 1000) runs forever, looping auto-wire modal IDs and calling an idempotent injectMinimizeButton — nearly every tick is wasted, and the 1s wakeup never stops.
  • D2: emailInbox.js unread refresh (60s) and tasks.js notif poll (30s) fire network/work even when the tab is hidden. calendar.js already gates on document.visibilityState — the others should match.

Fix

  • modalManager: pause the 1s interval when document.hidden, resume on visibilitychange (identical behaviour when visible; no wakeups when hidden).
  • email/tasks polls: early-return when document.visibilityState !== 'visible' (same pattern calendar already uses).

Aligns with the idle-quiescence rule (#117). Affected: static/js/modalManager.js, static/js/emailInbox.js, static/js/tasks.js.

Metadata

Metadata

Assignees

No one assigned

    Labels

    upstream-candidateBug or feature suitable for contributing to upstream

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions