#7364·screenpipe

[bug] home activity ledger re-requests a 7-day /activity-summary every ~4 s; 20–60 s per run on a migrated hybrid DB → 4 cores, 100→5% battery in 107 min

Author: pleasedodisturbCreated Sep 29, 2026Updated Oct 1, 2026

AI assistance and human ownership read the AI-assisted contribution policy.

  • AI tool(s) used: Claude Code (log analysis, profiling, drafting)
  • autonomy level: agent
  • what you personally verified: the battery drain (100% → 5% in 107 min on a healthy 93%-capacity battery), the CPU numbers in Activity Monitor, and that the app's own home window is the client making the requests.
  • I personally submitted this issue; its problem statement and rationale are my own.

describe the bug

The home page's activity ledger requests /activity-summary for the whole history of the install (start = earliest accessible frame, end = now) about every 4 seconds. On a database that went through the SQLite+Parquet migration (~9.5 GB index, 148k frames, 454k ui_events, ~19M elements) each of those requests takes 20–63 s, so 5–6 of them are always in flight. The app sits at 370–440% CPU on AC and, because the power manager's Saver profile does not touch this path, on battery too. Net effect today: unplugged at 100%, hit 5% after 107 minutes, with the log showing the app moving through Saver → AudioPaused → FullPause on schedule while the query loop kept running.

Numbers from one day's log (2026-09-29, app uptime 12:49–15:20 UTC):

slow statement warnings for the WITH frame_fallback AS MATERIALIZED … query 1,968
distinct requests (grouped by BETWEEN range) 1,399
of which start = first frame of the install (2026-09-22T07:43:10Z), end = "now" 1,378
cadence of those one every ~4 s (end timestamps 14:55:11, :15, :19 …)
statement time avg 27.9 s, max 63.4 s, min 2.4 s
total time inside that statement 52,114 s = 14.5 CPU-hours in 2.5 h wall clock
activity summary: frame summary query failed … payload read deadline exceeded 3

The other 21 requests (1-hour, 24-hour, 48-hour ranges from pipes / the pi agent) cost 17–30 s each, so the query itself is slow on this DB independent of the loop; the loop is what turns it into a permanent 4-core load.

Who is calling: lsof -i :3030 shows the app's WebKit networking process holding 11 concurrent connections to the API the whole time, plus one connection from the pi agent runtime. The loop rate is constant from the first minute after boot (12 statements/min at 12:50 UTC), before any MCP client or pipe had run. The range shape (earliest accessible frame → now, no include_* extras) matches buildActivitySummaryPath in apps/screenpipe-app-tauri/components/activity-ledger.tsx, which is mounted on app/(main)/home/page.tsx. ACTIVITY_HISTORY_REFRESH_INTERVAL_MS there is 10 minutes, so something in the coverage / "recent activity" scheduling re-issues the request far more often than intended when the previous one is slow or times out. I have not traced the exact branch.

What the query does on this DB (EXPLAIN QUERY PLAN, one-hour range): frame_fallback does two correlated scalar subqueries per frame that has an empty app_name (28,516 such frames here), the second one a range search on idx_ui_events_timestamp with a USE TEMP B-TREE FOR ORDER BY; then _bulk_logical_ui_events is materialized with a full SCAN e and joined via an automatic covering index. On the 7-day range that is the whole ledger, every 4 seconds.

Profile of the app process (3-second sample, two runnable threads at ~77% each plus the SQLite work): one thread in whisper_full (local WhisperLargeV3Turbo transcription, ~240 chunks/h), one in VNRecognizeText (OCR), and a tokio-rt-worker inside sqlx for the statement above. The resource monitor logged screenpipe_app=1p/3.7GB/373–443%cpu while I was measuring.

system info

  • os: macOS 26.7 (25G229), Apple M1 Max, 64 GB
  • screenpipe version: app 2.7.76, CLI 0.4.50
  • storage: hybrid-parquet-v1 (parquet-frame-v1, contentless-delete-fts5, durable-wal, parquet-bulk-v1); storage/<gen>/index.sqlite 9.5 GB, payloads/ 1.3 GB. The DB was restored from a classic-layout backup of another Mac (17.6 GB db.sqlite, history since 2026-05-04) and converted in-app on 2026-09-24. Migration receipt: frames 135,671, ui_events 442,318, elements 19,402,939 at conversion time.
  • power: macOS Low Power Mode on for battery; screenpipe power profile auto (log shows Performance ↔ Saver ↔ AudioPaused ↔ FullPause transitions as expected).

expected

  • The home ledger should not re-request an all-history summary every few seconds; a single-flight fetch with backoff (or simply honouring the 10-minute interval when the previous request is still running / failed) would cap this at one query in flight.
  • A 7-day activity summary should not need 30–60 s; the per-frame correlated subqueries against ui_events are the obvious place to look (a covering index on (timestamp, app_name) for the fallback window, or resolving app_name once at write time).
  • Saver / on-battery profiles could also throttle or skip this route, since it is the dominant consumer here and it is invisible to the capture-side throttles.

additional context

Log excerpts (sanitized: user and host names replaced):

# power manager (UTC), 2026-09-29
12:49:39 power profile changed: FullPause -> Saver (on_ac=false, battery=Some(100), os_low_power=true, thermal=Nominal, reason=os_low_power)
12:50:20 power profile changed: Saver -> Performance (on_ac=true, battery=Some(100), os_low_power=false, thermal=Nominal, reason=ac_power)
13:03:01 power profile changed: Performance -> Saver (on_ac=false, battery=Some(100), os_low_power=true, thermal=Nominal, reason=os_low_power)
14:26:46 power profile changed: Saver -> AudioPaused (on_ac=false, battery=Some(20), os_low_power=true, thermal=Nominal, reason=os_low_power)
14:26:46 battery low (<=20%) — pausing audio transcription, vision capture continues; battery=Some(20)
14:42:49 power profile changed: AudioPaused -> FullPause (on_ac=false, battery=Some(10), os_low_power=true, thermal=Nominal, reason=os_low_power)
14:49:30 power profile changed: FullPause -> Performance (on_ac=true, battery=Some(5), os_low_power=false, thermal=Nominal, reason=battery_critical)

# resource monitor, on AC right after the drain
15:12:11 WARN resource_monitor process breakdown pressure: screenpipe_app=1p/3.70GB/388%cpu, screenpipe_app_child=1p/0.04GB/0%cpu, screenpipe_mcp_external=6p/0.31GB/0%cpu
15:12:41 WARN resource_monitor process breakdown pressure: screenpipe_app=1p/3.71GB/443%cpu, …

# one of the 1,968 slow-statement warnings
WARN sqlx::query: slow statement: execution time exceeded alert threshold summary="WITH frame_fallback AS MATERIALIZED …" elapsed=62.465699917s slow_threshold=1s

# the deadline error
ERROR screenpipe_engine::routes::activity_summary: activity summary: frame summary query failed: encountered unexpected or invalid data: frame storage: payload read deadline exceeded

pmset -g log for the discharge: 15:02 100% → 15:31 78% → 16:01 48% → 16:23 24% → 16:49 5% (local time), no display-off dip.

Happy to run EXPLAIN QUERY PLAN variants, a screenpipe diagnose bundle, or a patched build against this database.