Skip to content

ios: write iOS's MetricKit reports into the strap log - #2420

Merged
ryanbr merged 1 commit into
ryanbr:mainfrom
UtkuDenizAltiok:metrickit-daily-report
Sep 27, 2026
Merged

ryanbr merged 1 commit into
ryanbr:mainfrom
UtkuDenizAltiok:metrickit-daily-report

Conversation

@UtkuDenizAltiok

Copy link
Copy Markdown

What this PR does

iOS measures every app on the phone and will hand an app its own numbers through MetricKit: about once a day, what it used the day before (foreground and background time, CPU, peak memory, disk writes, hangs, and why it exited — normally, at the CPU or memory limit, by the watchdog, by a crash), and after a crash, a hang, a CPU or disk-write exception or a slow launch, a report about it. NOOP did not subscribe.

MetricKitLog registers once at launch and writes one line per report into the strap log (MetricKitLine), for example:

MetricKit day 2026-09-22 00:00 → 2026-09-23 00:00 (NOOP 11.8.0): foreground 1h 12m, background 9h 40m, CPU 6m 12s, peak memory 180 MB, disk writes 1.5 GB, hangs 3, exits: normal 4, CPU limit 1
MetricKit CPU exception (NOOP 11.8.0, reported 2026-09-22 20:42): 48s of CPU in 1m 0s

Nothing is sent anywhere. iOS gathers the numbers on the phone and delivers them to the app; the lines go only into the strap log a person exports by hand — no telemetry, no network, no file of its own, no timer. Between reports it costs nothing.

Why: on 22 Sep iOS closed NOOP four times during a session for background CPU (cpu_resource_fatal), and the only evidence was crash reports the tester had to find by hand in Settings → Privacy → Analytics Data. The same facts now arrive in the file testers already send, and the daily line gives battery questions a measured answer.

A line says only what iOS reported: a field MetricKit left out is left out of the line, not printed as a zero. Android has no equivalent API, so this is iOS-only.

Type of change

  • New feature (local diagnostics)

How it was tested

  • MetricKitLineTests (StrandTests), 4 tests: a full day, a day with nothing reported, a diagnostic line, durations and sizes. With a missing value printed as zero, the "not reported" test fails, and the file restored byte-identical (sha256).
  • Full local run on the change (6721e3b2; the head is the same diff rebased onto 8f064df7, whose newer commits touch none of these files), every step passed: WhoopStore 611 · StrandAnalytics 2048 · StrandImport 327 · doc lint · i18n · parity ledger, ratchet, governance (124) · macOS StrandTests 2,121 (only the two locale-dependent TodayCarryOverTests) · iOS build, no warnings in the new files.
  • MetricKit payloads cannot be constructed in a test and arrive only on a device about once a day, so the subscriber's mapping is covered by the build and review; the first real line will be checked in a tester's strap log.

Checklist

  • No UI change
  • Follows the conventions in docs/CONTRIBUTING.md — no data leaves the device
  • I did not commit generated output (Strand.xcodeproj/) or any secrets/keystores

🤖 Generated with Claude Code

iOS measures every app on the phone and will hand an app its own numbers: about once a day, what it
used the day before (foreground and background time, CPU, peak memory, disk writes, hangs, and why it
exited — normally, at the CPU or memory limit, by the watchdog, by a crash), and after a crash, a hang,
a CPU or disk-write exception or a slow launch, a report about it. NOOP did not subscribe.

MetricKitLog registers once at launch and writes one line per report into the strap log
(MetricKitLine). Nothing is sent anywhere: iOS gathers the numbers on the phone and the lines stay in
the log a person exports by hand. No timer, no file, no network; between reports it costs nothing. The
22 Sep investigation of iOS closing NOOP for background CPU needed crash reports found by hand in
Analytics Data; the same facts now arrive in the file a tester already sends.

A line says only what iOS reported: a field MetricKit left out is not printed as a zero. Android has no
equivalent API, so this is iOS-only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
UtkuDenizAltiok added a commit to UtkuDenizAltiok/noop that referenced this pull request Sep 23, 2026
…br#2420 MetricKit opened; off-wrist fix awaiting strap test; build 445fe65
@ryanbr
ryanbr merged commit 4343cf9 into ryanbr:main Sep 27, 2026
4 checks passed
@UtkuDenizAltiok
UtkuDenizAltiok deleted the metrickit-daily-report branch September 28, 2026 07:21
UtkuDenizAltiok added a commit to UtkuDenizAltiok/noop that referenced this pull request Sep 28, 2026
…2437 ryanbr#2444), ryanbr#2446 fixed upstream; logs+backup analysed (BACKLOG A background re-score, B ryanbr#2371 answered); fork tidied; build 0ad5ba9 shipped
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.

2 participants