Skip to content

iOS: draw paints requested during a display callback in that callback - #50

Merged
corepunch merged 2 commits into
mainfrom
ios-paint-cadence
Oct 28, 2026
Merged

corepunch merged 2 commits into
mainfrom
ios-paint-cadence

Conversation

@corepunch

Copy link
Copy Markdown
Owner

Summary

The iOS message queue freezes a batch per CADisplayLink callback so a touch can reach UIKit between animation steps. The paint an animation step requests was posted inside that batch and therefore waited for the next callback, so callbacks alternated between "step, no draw" and "draw", halving every animation's paint rate on iPhone.

Once a callback's batch has drained, the paints queued so far are now delivered in the same callback, so each animation step and touch is shown in the frame that handled it. Other messages still wait for the next callback (touch priority unchanged), and a paint posted by a paint waits too, so a repainting handler cannot starve the run loop.

ios_paint_count() exposes delivered paints for ORCA's frame profiler.

Verification

ORCA's test-ios-message-frame (rewritten to mirror the application loop and assert one paint per step) passes, and ORCA's merged corepunch/orca#404 points its submodule at this commit; on the simulator, turnstile and inertia now paint on every display callback.

🤖 Generated with Claude Code

corepunch and others added 2 commits October 28, 2026 10:06
Messages posted while a display callback's batch runs still wait for the
next callback, so a touch can reach UIKit between animation steps. The
paints those messages request no longer wait: once the batch has drained,
the paints queued so far are delivered in the same callback, so each
animation step and touch is shown in the frame that handled it instead of
one display interval later. Before, callbacks alternated between stepping
and drawing, halving the paint rate of every animation. A paint posted by
a paint still waits, so a repainting handler cannot starve the run loop.

ios_paint_count() reports delivered paints for frame profiling.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@corepunch
corepunch merged commit 3c3cf61 into main Oct 28, 2026
6 checks passed
corepunch added a commit to corepunch/orca that referenced this pull request Oct 28, 2026
The submodule referenced the pre-rebase commit of corepunch/platform#50;
main there now carries it as 5ce73ca plus its test update 3c3cf61.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.

1 participant