Skip to content

Reduce Rewind polling by capturing immediately on foreground window changes #8498

Closed

Description

@noaft

Improve Rewind capture cadence with foreground-window triggered snapshots

Current behavior

Rewind currently samples the screen on a fixed interval, defaulting to roughly every 1 second.

The renderer keeps a desktop getUserMedia stream alive, draws the current video frame to a canvas, encodes it as JPEG, then sends it to the main process via rewind:saveFrame.

This works, but it means the app continuously samples/encodes frames even when the user stays on the same unchanged window.

Proposal

Make Rewind capture less frequent by default, for example every 5 seconds, but trigger an immediate capture whenever the active foreground window changes.

Proposed behavior:

  • Periodic capture every ~5 seconds.
  • Immediate capture on foreground window/app change.
  • Keep existing filters:
    • lock screen
    • idle state
    • excluded apps
    • sensitive window titles
    • duplicate-frame hash check
  • Do not bypass privacy/sensitive-window detection for event-triggered captures.

Why

This could reduce CPU/GPU usage and disk writes while preserving the most important Rewind moments.

A window/app switch is usually a meaningful timeline boundary. Capturing immediately on foreground change avoids waiting up to the next interval, while allowing the normal polling interval to be slower.

Relevant code

  • desktop/windows/src/renderer/src/components/rewind/RewindCaptureHost.tsx
    • owns the screen stream, canvas sampling, JPEG encoding
  • desktop/windows/src/main/rewind/captureService.ts
    • receives JPEG frames, applies gating/deduping, writes frame + DB row
  • desktop/windows/src/main/usage/foregroundMonitor.ts
    • already uses foreground change events for app usage tracking
  • desktop/windows/src/main/usage/nativeForeground.ts
    • exposes foreground window detection/subscription

Possible implementation

Since the renderer owns the actual capture stream/canvas, the main process cannot directly grab a frame from captureService.ts.

One possible approach:

  1. Main process listens for foreground window changes.
  2. On change, main sends a lightweight IPC event to renderer, e.g. rewind:captureNow.
  3. RewindCaptureHost receives that event and immediately runs one grabAndSchedule() pass.
  4. Existing ingestRewindFrame() logic still decides whether to save or skip the frame.

Acceptance criteria

  • Rewind periodic capture interval can be increased to around 5s.
  • Switching foreground apps/windows triggers an immediate Rewind sample.
  • Immediate samples still respect existing privacy filters and duplicate-frame detection.
  • No concurrent frame saves stack up if a foreground-change event fires during an existing save.
  • Chat screen context remains reasonably fresh, or the tradeoff is documented.

Activity

  1. added
    p3
    enhancement
    on Jul 1, 2026
  2. added a commit that references this issue on Jul 30, 2026
    6d14b37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    desktopenhancementp3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions