In ikie, a flagged task gets a border that slowly turns through blue, violet and pink. It's a small flourish meant for the paid plan (Hyper ikie). The day after this shimmer shipped, the whole app started to feel sluggish. Not one slow screen, but everything a bit heavier.
A lot had shipped that day: the shimmer, a queue that holds writes while offline, uploads of the iPhone's calendars, and silent pushes when something changes on another device. Instead of picking one by feel, we measured first.
Ruling out the server
We checked the server first. The home endpoint averaged 135 ms on October 15, 160–180 ms on the 16th, and 96 ms on the 17th, the day we measured. Responses that fetch a month of events were 31–78 ms. The server hadn't slowed down. The problem was on the device.
Three builds, the same gestures
| Item | Detail |
|---|---|
| Builds | A: before the slowdown (October 15), B: the TestFlight build people called sluggish, C: that day's main |
| Account | Demo account, server responses fixed at 0.4 s |
| Gestures | A roughly 100-second scenario: bring the app to the foreground, open and close a sheet five times, switch tabs, scroll a day list, quick capture, check off five tasks |
| Repeats | The three builds alternated, three runs each, median taken |
| Measured separately | 10 seconds of touching nothing |
That last row was the key to this analysis. Measuring what's slow when someone does something wasn't enough. We had to measure what the app does when nobody does anything.
What the numbers pointed at
B did 33% more main-thread work than A (C, that day's main, landed in between at 26.0 s). Yet turning off the shimmer alone made almost all of that increase disappear. UI update time went back to A's level, and wakeups in the idle 10 seconds dropped from 1,859 to 721.
Before asking how much a frame costs, ask whether anything keeps the app from resting. An app that never rests uses up the frames it will need when a person touches it.
Why the shimmer cost so much
On iOS, the shimmer turned a conic gradient with an endless SwiftUI animation (repeatForever), blurred its outer glow, and masked it to the border shape. On screen it's just a thin border turning slowly. But every frame, SwiftUI computed the angle on the main thread and recomposited the blur and the mask. While a single ring was on screen, the app never got a frame off.
And one was nearly always on screen. The shimmer setting is on by default, and with launch still ahead the paywall was off, so it ran for everyone. A task with only a date rolls over to today until it's finished, so one flagged task turned every time the app opened. It also turned where nobody could see it, like the off-screen neighboring pages of the swipeable timeline.
The web had the same shape of problem. The angle animated through a CSS custom property (--hy-a), and that kind of animation can't run on the compositor, so the browser repainted every shimmering row on every frame.
The fix: motion on the GPU, a main thread at rest
There was one direction: get the turning off the main thread.
- On iOS we redrew the ring with Core Animation layers. A conic gradient layer is masked by a border-shaped layer, and the gradient turns with a
CABasicAnimation. The render server does the turning, so the main thread does nothing per frame. The outer glow is a shadow drawn once. When the ring isn't in a window (a previous page, a closed sheet), the animation is removed, and with Reduce Motion on it's a still border. - On the web a box masked down to its border stays still, and only the gradient square inside it turns with
transform: rotate. Each side of the square is 1.5 times the box's long side, so no gap shows as it turns. Transform animations run on the compositor, so nothing is repainted.
The look didn't change: the same border, the same seven seconds per turn. What changed is who does the turning.
Four more fixes along the way
The shimmer was the biggest cause, but not the only one. Other things shipped that day each took a bit of the main thread too.
- Writes waited in a single line. The offline queue lined up every write even while online, so each write waited for the previous one's round trip. Now each item gets its own line.
- Every write and fetch did device work on the main thread. Writing the queue file, reading the keychain and scanning the app group folder ran on every home fetch. Now picking up writes made outside the app happens only when the app comes forward, and file writes happen in the background.
- Every write uploaded all of the iPhone's calendars. After each write, the app rebuilt three years of events, hashed them and sent them. Now uploads wait 3 seconds after the last write and run in the background, and linked calendars the server discards anyway (Google and iCloud calendars added to the phone) aren't uploaded. The 3 seconds is declared in app policy, not written into screen code.
- Every push triggered a refetch. When another device or a connected tool writes, a silent push arrives, and the phone refetched home and up to five months each time, piling up when pushes came in a row. Now the refetch after a write and the refetch from a push are merged, and if one is running, one more runs at the end.
We also narrowed what gets redrawn on a change. One line at the end of the inbox screen read the whole home payload, so every home fetch redrew every inbox row. We split that value out and stopped re-saving values that hadn't changed.
After the fixes
Same scenario, same method, comparing main before and after the fixes.
An idle app rests again. A main thread that woke 1,851 times in 10 seconds now wakes 68 times. UI update time is back to the level of the build without the shimmer, and the shimmer still turns.
What we learned
- Measure the resting state. Had we measured only while someone touched the app, this would have looked like "every gesture is a bit slower". Ten untouched seconds showed right away that the app never rested.
- Turn one thing off and measure again. A single build with only the shimmer off sorted out which of five suspects mattered most.
- A flourish costs "always", not "one frame". Drawing one ring is cheap. Drawing it on every frame while the app is open, even where nobody can see it, was the expensive part. Anything that animates forever should run off the main thread from day one.