Repository navigation
feat(composition): Tick per-frame motion from a frame clock - #24735
Conversation
|
Claude finished @MartinZikmund's task in 8m 20s —— View job Review complete
Verdict: ship (with minor follow-ups) — the core design (frame clock, pre-layout 3 inline findings posted, all low/medium severity:
Cross-cutting observations (not filed inline, no specific line to anchor to):
No blocking issues found. |
c8357ab to
99c15a3
Compare
|
Claude finished @MartinZikmund's task in 1m 56s —— View job Review complete
Verdict: ship (with minor follow-ups) — same verdict as the prior pass. Status of the 3 previously-flagged inline findings — all still open in the current code:
The CodeQL findings (constant conditions in Newly reviewed for this pass (files not covered by inline findings before): No new blocking issues found. |
|
Claude finished @MartinZikmund's task in 1m 55s —— View job Review complete
Verdict: ship — commit
No regressions: the Still open, not from this review: the CodeQL findings from the No new inline findings to post. |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Sparse-frame sampling, cross-window animation timing, and post-close driver registration can produce incorrect motion or leaked animation state.
Review effort: Balanced
Findings: 2
Open (3)
What changed in this PR
Adds a frame-clock-driven composition pipeline so motion and animations use consistent per-frame timestamps before recording.
Changes:
- Adds frame timestamp sampling and pre-record frame ticks.
- Aligns keyframe animations and inertia with frame time.
- Adds lifecycle cleanup and extensive runtime coverage.
Review: 3 correctness issues identified.
| File | Description |
|---|---|
CompositionTarget.RenderScheduling.cs |
Samples and arms frame ticks. |
CompositionTarget.Rendering.cs |
Moves rendering events before recording. |
CompositionTarget.FrameClock.cs |
Implements frame-driver scheduling. |
CoreServices.cs |
Raises ticks before layout. |
GestureRecognizer.Manipulation.InertiaProcessor.cs |
Uses frame-based inertia timing. |
Given_CompositionTarget.cs |
Tests frame-driver behavior. |
Given_Compositor.cs |
Tests clocks and animation timing. |
MacOSWindowHost.cs |
Unregisters closed roots. |
KeyFrameEvaluator.cs |
Evaluates animations against frame time. |
FrameClock.skia.cs |
Implements phase-locked timestamps. |
Compositor.skia.cs |
Tracks frame drivers and recording timestamps. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
|
Claude finished @MartinZikmund's task in 4m 18s —— View job Review complete
Verdict: ship — no new inline findings. The 11 commits since the last review pass (
Also landed in this batch: Rendering is now raised after the tick's layout pass rather than before ( Still open, not new: Copilot's third (medium) finding — Incidentally, the CodeQL "constant condition" previously reported on the No skipped/ CI for this push is still in progress at review time (no failures yet). |
|
|
A record from the layout tick reused the last vsync's timestamp, so an animation started after an idle gap played the whole gap out at once. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01R7whDzJCaLmBZnEXFfgeC1
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01R7whDzJCaLmBZnEXFfgeC1
Match WinUI's NWDrawTree order: frame drivers still run before layout, but Rendering now follows layout and Loaded, and the tick lays out again what its handlers change before recording. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01R7whDzJCaLmBZnEXFfgeC1
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01R7whDzJCaLmBZnEXFfgeC1
The tick was gated on the first content root's bounds, so a minimized main window stopped layout, frame drivers and Rendering for every other window. Windows without bounds are still not laid out. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01R7whDzJCaLmBZnEXFfgeC1
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01R7whDzJCaLmBZnEXFfgeC1
X11 raises Closed before it unregisters the XamlRoot, which it does from a task continuation, and the frame drivers are then dropped on the UI thread. A driver subscribed in between was counted, so the test failed on every Linux run. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014tR98SJixdXBRVuRo69Pek
The framebuffer host is not vsync-paced, so its measured frame interval is a fraction of a millisecond and a bound of three intervals failed on an ordinary 2ms frame. The regression being guarded played out a 300ms pause, so bound the step at 100ms instead. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014tR98SJixdXBRVuRo69Pek
Also take the latest frame time across windows for Rendering, resolve the unregistered target on the UI thread and assert balanced frame drivers. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0136gN41Ffj5s48DUW4jDJYN
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0136gN41Ffj5s48DUW4jDJYN
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0136gN41Ffj5s48DUW4jDJYN
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0136gN41Ffj5s48DUW4jDJYN
f2da994 to
efead73
Compare
|
Claude finished @MartinZikmund's task in 14s —— View job Review: no new changes since the last passThe branch head is still Verdict: ship Still open from Copilot's last round (none blocking):
CI: the screenshot-comparison diffs (about 100–140 per platform, in unrelated samples such as |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24735/wasm-skia-net9/index.html |
|
The build 237627 found UI Test snapshots differences: Details
|
|
This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again. |
Restores the grid tests split out of #24735: even steps under jitter, no drift, a dropped frame stepping twice, re-anchoring after idle, never stepping back, and no freeze after a hitch or a slower motion. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014tR98SJixdXBRVuRo69Pek
Restores the grid tests split out of #24735: even steps under jitter, no drift, a dropped frame stepping twice, re-anchoring after idle, never stepping back, and no freeze after a hitch or a slower motion. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014tR98SJixdXBRVuRo69Pek
Restores the grid tests split out of #24735: even steps under jitter, no drift, a dropped frame stepping twice, re-anchoring after idle, never stepping back, and no freeze after a hitch or a slower motion. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014tR98SJixdXBRVuRo69Pek


GitHub Issue: Part of #23985
PR Type:
✨ Feature
What changed? 🚀
Before
On Skia, per-frame motion has no shared frame clock:
CompositionTarget.Renderingis raised on the render thread after the present and then enqueued back to the UI thread. By the time a handler runs, the next frame has already been recorded, so whatever it moves (touch inertia, dispatcher animators) lands one frame late.Renderingagain, so inertia gets extra ticks.v·Δtposition error. The faster the motion and the higher the refresh rate, the worse the judder.Power(Out, 10)ChangeViewease that is about two frames of its fastest part in one step.After
Each native frame callback now arms one UI-thread tick, and that tick runs the frame in WinUI's
NWDrawTreeorder:FrameClock(new, internal): hands out the frame times, never stepping back, and estimates the frame interval from the median of the last 32 intervals for motion that needs a nominal step. Gaps longer than 50 ms or 4 intervals are idle time and are left out of the median. The times themselves are the raw clock sampled once per native frame: snapping them to the display interval is split out to feat(composition): Snap frame times to the display interval #24966, and native vsync timestamps are tracked in [Skia] Drive the frame clock from native vsync timestamps #24963.CompositionTarget.FrameStarting(new, internal): per-target event for frame drivers. Drivers count towardsCompositor.IsAnimating, a newly subscribed driver is ticked from the next frame (not immediately, so a driver swapped between frames isn't ticked twice), and drivers are dropped when theirXamlRootunregisters (the macOS host now unregisters itsXamlRooton close so this also happens there). The target's running animations are stopped at the same point, since they only evaluate on its own record.Renderingis raised once per tick, from the UI thread, after layout and before the record, withRenderingTime= the frame time. It is no longer raised on re-presents. A throwing handler is reported throughRaiseRecoverableUnhandledExceptionand no longer skips the layout and record after it.Compositor.AnimationTimestampInTicks), and start at the first frame that evaluates them, as a DComp commit does.Resumewaits for the next frame the same way. Animations are evaluated only by their own target's record, so a second window doesn't advance them on its own frame clock.GestureRecognizer) usesRenderingTimeinstead of a privateStopwatch, so every step after the first is exactly one frame interval.Renderingfor the other windows. Windows without bounds are still not laid out.Fixes found during validation (each with a fails-before test)
ScrollViewwheel notch jumped its full 48 px).How this compares to other frameworks
RefreshAlignedClock)TimeManager.Tick→ layout → Loaded → layout →Rendering→ layout → render walkhandleBeginFrame)Tickerstart time = first tick's timestampMediaContextstopwatch, sampled once per render passChoreographervsync time, snapped back to the vsync grid when lateFrameStarting→ layout → Loaded →Rendering→ layout → recordWhere this PR still differs is the source of the time: the others take it from the vsync signal, while Uno reads the clock on the UI thread after a dispatcher hop, so it carries a few ms of jitter. #24966 smooths that by snapping to the display interval, and #24963 replaces it with native vsync timestamps.
Validation and behaviour changes
The smoothness numbers in the PRs above were measured with the scroll-smoothness probe from #24711 (
sample=Scrolling/ScrollSmoothnessTester&scrollprobe=...). newFps = presented frames showing a newly recorded frame per second; judder = RMS residual of the offset against a local quadratic through neighbouring presented frames.Given_Compositortests (frame interval under bursts and sparse frames, keyframe evaluation at frame time, per-target evaluation) and 12Given_CompositionTargettests (tick order, frame drivers, window close, animations of a closed window, minimized main window, idle gaps).Given_Compositor+Given_CompositionTarget: 21/21 pass locally on Skia Win32.Compositor.IsAnimatingis now true while any frame driver is subscribed, andRenderingis no longer raised on a re-present without a new record.PR Checklist ✅
Screenshots Compare Test Runresults.🤖 Generated with Claude Code
https://claude.ai/code/session_014tR98SJixdXBRVuRo69Pek