r/iOSProgramming • u/retro_game_r • 17d ago
Question Scrolling ticker pins GPU at ~50% on a rich screen, ~0% on a blank one. What am I missing?
I'm building a SwiftUI clock-radio app (iPhone, ProMotion). The face is a rich layered screen — glass, gradients, shadows — with one 340×46pt text ticker that scrolls continuously.
The GPU behaviour (Xcode gauge, relative within-session reads; cadence from an in-app pacing log):
- Ticker scrolling: GPU plateaus at ~50%. Binary — one scroller or three, same cost.
- Frames are never dropped (16.7ms median). The GPU bills heavily for frames it renders on time.
- Same strip scrolling on a blank screen: ~0%.
- Ticker visible but static: 0%. Motion is the trigger, and the cost scales with what's *around* the strip, not the strip.
Already tried, all identical on the full face: SwiftUI offset animation; a severed Canvas leaf on its own CADisplayLink (0% alone on blank, still pegged on the face); pre-rendered bitmap instead of text; the strip in a separate UIWindow; pinning preferredFrameRateRange to exactly 30 (min=max=preferred); .compositingGroup() on the panel (modest help only).
What works: killing the motion duty — scroll once, then park. Also, elsewhere in the app, replacing a publish-driven visualiser with a pull-model one made its cost vanish; severing the ticker the same way didn't.
Is this just WWDC22 10083 (display rate set by the fastest animation) × whole-tree compositing per frame? Would a 15–24Hz rate range behave any differently from the hard 30 pin? And does anyone know a construction for a continuously scrolling ticker that lets the GPU idle between updates?
The app is iOS native version of https://tunerva.app
3
u/Background_Pie_5682 17d ago
One thing I'd test is whether any ancestor has a material, mask, shadow, or other effect that forces a large offscreen surface to be recomposited whenever the ticker invalidates; a standalone layer can still dirty a costly enclosing render pass. Try toggling those effects one at a time and inspect the render passes with Instruments' Core Animation or Metal System Trace, rather than only comparing FPS. For genuinely continuous motion the display still has to present frames, so a lower preferred range may reduce work, but it won't let the GPU idle between updates unless you accept quantized or paused motion.
2
u/brkaydev 17d ago
compositingGroup only groups for blending, it doesn't cache anything, so I wouldn't read much into that test. A quick way to confirm the surroundings are the bill: take a one-off ImageRenderer snapshot of the static part of the face and show it as a plain Image while the ticker runs. Live glass can't be flattened that way, so if the cost falls off you'll know it's the blur being resampled and can fake it in the baked layer.
1
u/kokerali 16d ago
Your suspicion about WWDC22 10083 combined with full-screen compositing is right on the mark. Three specific mechanisms explain the behavior you observed and why the quantized step fixed it:
Your quantized 2 cells/s ticker plus glide-and-park is the cleanest architectural solution because it lets ProMotion drop the display back to its 10Hz idle floor between steps rather than holding a continuous high-frequency render loop open.
1
u/Needle_In_Red 16d ago
id check if anything under the ticker has blur, materials or shadows, those can get recomposited every frame when something animates on top of them. maybe try flattening the background into a static image and see if the number drops, and the Core Animation instrument should show you whats actually being redrawn
1
u/mrdzyn 16d ago
That pattern (zero on a blank screen, expensive on the full face) usually means the moving layer forces everything around it to recomposite every frame, especially blurs and materials that sample what's behind them. Moving the ticker into its own window won't help if any glass or shadow still overlaps or sits behind its region. I'd try flattening all the static decoration into a single prerendered image and keeping the ticker over an opaque backing, then check the Core Animation template in Instruments for offscreen passes. You could also step the scroll in small discrete jumps at a low rate instead of a continuous animation, so there are real idle frames between updates.
0
u/Capital_File_8386 16d ago
I haven't hit this exact case, so this is what I'd check, not something I've lived through. Your one-vs-three result says the bill is compositing the whole face on any frame where something moves. On 15-24Hz, I'd expect the cost to drop roughly with the frame rate, not behave differently. preferredFrameRateRange is only a hint, and ProMotion can still snap to a rate the hardware likes. So log the cadence you actually get, not the range you asked for. Your 2 cells/s stepped ticker is the closest thing I know to a scroller that lets the GPU idle.
1
u/[deleted] 17d ago
[removed] — view removed comment