iOS: avoid full widget rebuilds for live-only updates - #1055
Conversation
|
Reviewed. The design holds up under the checks I could make, and I found nothing wrong with the logic. The gap is verification. Checked rather than assumedThe dedup covers everything the widget renders. Score changes cannot be lost to the fast path. Only the three genuinely live-only hooks moved to The The Effort-scale hook is a genuine catch, not padding. Without it a Settings scale change would leave It composes with today's widget work. I test-merged onto current main: clean, with #887's Minor
VerificationNo checks have run on this branch at all — the fork / first-time-contributor approval gate, same as your #1056 and #1057. And I ran what is available, So it compiles against today's tree. That is the whole of what CI currently says about this PR, and it says nothing about whether the dedup behaves correctly at runtime — which is exactly what your tests would establish if anything ran them. Nice writeup on the motivation, incidentally: "up to roughly 60 full Rest-series reads per hour" is the kind of number that makes the case without overselling it. |
What changed
Why
The foreground heart-rate hook is admitted once per minute, but each admitted update called the full publisher. That path asks
exploreSeriesfor the Rest metric with the default 4,000-day window even though a live HR, battery, or connection change cannot alter any score field. It then rewrote the shared snapshot and requested a WidgetKit timeline reload even when the rendered values were identical.This keeps the widget's displayed behavior intact while removing repeated database/computation work. During a live session it can avoid up to roughly 60 full Rest-series reads per hour, plus reads triggered by battery and connection events.
Validation
git diff --checkA full iOS build/test run was not available because the local environment has Command Line Tools rather than full Xcode.