Issue 3: How an Animation Gets to the Screen
Apple UI Insider, Issue 3: How an Animation Gets to the Screen
How UIKit and AppKit animate, and how SwiftUI does it on a Mac, an iPhone and an iPad. What Apple documents, what I measured, and how each claim is known.

This is the short version. The full issue, with 37 charts, 41 diagrams, the recordings and the evidence for every number, is on the site: How an Animation Gets to the Screen.
Welcome back.
Issue 1 drew the map and issue 2 proved one small piece of Core Graphics. This issue takes one thing you do every day, animate a view, and follows it from your line of code to the pixels, in two frameworks that look alike and are not.
One dot, two machines
The test case is one dot. Move it across a view, once with UIKit or AppKit and once with SwiftUI. On screen the two look the same. Underneath they are different machines, and the SwiftUI machine is different again on a Mac and on an iPhone.
Here is a real iPad Pro, recorded over USB, replayed at half speed. The framework's own animation is on the top row and SwiftUI on the bottom. The blue square marks the stretch in which my test app blocks the main thread.

Every claim in the issue carries one of six labels, in words, next to the claim: documented (Apple's own document or session, which I name), measured (my probe ran it), observed (read from a call stack, a breakpoint or a captured message while it ran), read from code (from a disassembly, so it shows what a function can do and not what it did), my reading (an inference, said to be one) and open (I do not know).
The probe is a small app. One property moves at a time: opacity, offset, width, scale or rotation. Four kinds of animation: linear, ease in and out, a spring, and a custom callback. That is 20 SwiftUI cases on each of five platforms: macOS 27.0.1, an iPhone and an iPad simulator, a real iPhone 17 Pro Max and a real iPad Pro. The same properties move with UIKit or AppKit as the control.
UIKit and AppKit: describe it, hand it over
This is the call the control makes for opacity:
UIView.animate(withDuration: 0.5, delay: 0, options: .curveLinear) {
view.alpha = 0.2
}
The Core Animation Programming Guide (Apple, 2015) says an app using Core Animation has three sets of layer objects. The model layer tree is where your app works: its objects "store the target values for any animations". The presentation tree contains "the in-flight values for any running animations", the values "as they appear onscreen". You only read it. The render tree is where the work happens: its objects "perform the actual animations and are private to Core Animation".

One more sentence in the same guide is the whole UIKit story: reading the presentation tree "differs from the layer tree, which always reflects the last value set by your code and is equivalent to the final state of the animation". From the moment you set it, the layer's value is the end of the animation. What is on screen is a different value, held elsewhere.

Here is what I measured for UIKit and AppKit against what Apple says:
| Apple says | Mac | iPhone and iPad |
|---|---|---|
| the animation lives on the layer | one added per case | one added per case (15 of 15 cases on each iOS platform) |
| the property is not set destructively | the model was written once, at the call; the animation is a separate object | the same |
| another process runs it | blocking the main thread did not stop the AppKit dot | blocking the main thread did not stop the UIKit dot; the render server's frame counter held |
Two limits. I did not test that adding an animation alone leaves the property unchanged. And the third row is consistent with another process running the animation; it does not show it. The Mac cell shows only "not the main thread".
The process is a hand-off. You set the property in a block, UIKit adds one animation to the layer, the main thread commits once, and from then on the render server, another process, works out every frame. The app is not in the loop. My reading is that this is what makes UIKit animation robust: a busy app does not stop it.

SwiftUI: what Apple says
WWDC 2023, session 10156, "Explore SwiftUI animation", is the main source. The sentence this issue tests is this one:
"For built-in animatable attributes like scaleEffect, SwiftUI is very efficient. It's able to do this work off the main thread and without calling into any of your view code."
The documentation for withAnimation says it "sets the given Animation as the animation property of the thread's current Transaction". My reading is that withAnimation therefore does not animate anything itself. The animation travels in the transaction, and SwiftUI works out the value as time passes.
A custom animation shows that most clearly, because it is a callback: SwiftUI hands you a time and expects a value. This is the one I used, and the probe's version also records which thread each call came on:
struct LinearCallback: CustomAnimation {
let duration: TimeInterval
func animate<V: VectorArithmetic>(
value: V, time: TimeInterval, context: inout AnimationContext<V>
) -> V? {
time < duration ? value.scaled(by: time / duration) : nil
}
}
UIKit says it once and never asks again. SwiftUI asks at every time.
Three platforms, measured
First, no animation is added to a layer through the public call in any SwiftUI case: 0 in 80 cases on the four iOS and iPadOS platforms and 0 in 20 on the Mac. Beyond that the three platforms differ.
On the Mac, on every pass the main thread works out a value and writes it to the layer. The stack I observed runs through AppKit's display cycle into SwiftUI's own render code, all on the main thread. The thread SwiftUI uses on the iPhone does not appear anywhere in the Mac's output.

On the iPhone and the iPad, SwiftUI has a thread of its own, named com.apple.SwiftUI.AsyncRenderer, observed on two real devices and the iPhone simulator. It works out the value, writes it into a block of shared memory held by a private Core Animation object, and sends a small message. The layer's own model value barely changes. The render server reading that memory on every frame I read from code, and could not watch.

Then the test that tells them apart: block the main thread for half a second in the middle of the motion and watch the screen.
On the Mac, the SwiftUI dot stayed in one place for 586 ms in the longest wait, against 120 ms for AppKit, and the custom animation's callbacks inside the block were 0. That is one build of the Mac and two usable blocks; the capture ran at about 14 frames a second.

On the iPhone 17 Pro Max the SwiftUI dot kept moving at 262 pixels a second, as the UIKit dot did, and the custom animation's callbacks, 32 inside the block, were none of them on the main thread. Stop SwiftUI's own thread instead, and the SwiftUI dot froze for 467 to 500 ms while the UIKit dot did not.

So the first half of Apple's sentence, off the main thread, matched the iPhone and the iPad and did not match the Mac in these runs. The sentence says SwiftUI is "able to" do this, a capability, so the Mac result shows it was not taken here, not that it cannot be. The second half, without calling your view code, I did not test.
What I got wrong
I read model values only at first, and my early iOS runs showed almost nothing happening. The motion appeared when I read presentation values too. Then I counted my own probe: reading layer.presentation() builds a copy of the layer, and building the copy calls the setters I was hooking. That gave 54 setter calls for an opacity case on the iPhone where the app made 4.
A test that fails on the case whose answer you know does not measure what you wanted. I first tested the blocked main thread by reading presentation values from a background thread. It said UIKit's own animation had stalled too, which I knew was false, so I dropped the test. The issue lists seven mistakes in all.
What I do not know
I do not know why SwiftUI works the value out itself, on a thread of its own, instead of handing a description to the render server as UIKit does, or why the Mac differs from the iPhone. No source I have says. I do not know why the real iPhone ran at about 60 passes a second when it reports 120 Hz; the probe sets no ProMotion key, which I have not confirmed as the cause. I do not know why one property, offset, behaved differently on that phone. And I could not watch the render server read the shared memory; that part is read from code.
Not tested: transitions, matched geometry, keyframe and phase animators, Canvas, TimelineView, how an interruption behaves on iOS, and scaleEffect with the main thread blocked. Those are the next things to measure. The Mac numbers come from macOS 27.0.1; I rebuilt the probe in Release and ran it on 27.2.1, and the verdicts were the same.
If your own measurements disagree on any platform or build, I want to see them. A different answer on a different OS version is the most useful report I can get.
The whole issue, with every chart, diagram and number, is here: How an Animation Gets to the Screen.
Mihaela