You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(SET): keep the clock of a built-in transition when the layout of its target changes - #11732
When the layout of the target changed during a built-in timed shared transition, the moving view started a new move with a new clock. The move then took the time until the change plus the full duration again, and a spring started again from rest. #11279 kept the clock but made the view jump by progress × change in one frame.
I kept the clock and moved the start of the frame interpolation instead. A running built-in animation now has a frame start shift. On a layout change of the same target, the shift changes by -change × p / (1 - p), so the frame on screen stays and the move ends on time. The clip start moves the same way. This applies up to 80% of the progress, when only the frame of the target changes and the transition of the view stays the same. A later change, a change of an animated style, of the transform as the view draws it or of the transition, and custom or timed progress animations start a new move as before.
Limits: a layout change that also changes the transform of the target as the view draws it starts a new move. This includes a transform that depends on the size (a percent translate, or a rotation or scale around the centre), and a rotated or scaled parent. A spring with dampingRatio below 1 can overshoot more after the change. The default spring has dampingRatio 1.
Alternatives considered:
Store the frame at the change and map the progress to (p - p0) / (1 - p0): the same line, but a reparent must move the stored frame, and each frame needs a division.
Change startView itself: this changes percent translates, the transform origin and the distance of nested carriers.
Keep the restart and document it: repeated changes keep extending the move.
Test plan
New runtime test keeps its clock and its frame when the layout of the target changes: on the base the width at 75% is 97.5 instead of 115 and the run starts two times, on the iPhone 17 Pro simulator and on a Galaxy A57 (Android 17). It passes with the fix.
Four existing tests expected the restart. I moved one change to 85% of the progress, so it still covers the restart, and changed three expectations to the kept clock.
New runtime test starts a new move when the transform of the target changes with its layout: the target changes its width and its rotation at 25%. Without the transform compare the run starts one time instead of two (iPhone 17 Pro simulator). It passes with the fix.
SET suite with the fix: 256 passed on the iPhone 17 Pro simulator, 195 passed on the Galaxy A57, 0 failed. After the transform compare (CodeRabbit), on the top of the stack: 259 passed, 0 failed, 23 skipped on the iPhone 17 Pro simulator. Android not run again.
No benchmark: each geometry frame adds one sum of two rects. The other work runs only on a commit that changes the layout of a target.
Clips: Galaxy A57, Debug build, adb screenrecord at the 120 Hz display rate. A linear 1500 ms transition; the target grows 750 ms after it mounts. Before, the view moves for 2.26 s. After, it moves for 1.49 s, and the width changes by at most 16 px per frame at the change.
Before:
before.mp4
After:
after.mp4
Changelog
I added a changelog fragment with yarn changelog:add for each changed package, or this PR does not change react-native-reanimated or react-native-worklets.
Review was skipped as selected files did not have any reviewable changes.
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 0d2d65a4-2613-4795-8e13-ce8a2a261845
Commits
Reviewing files that changed from the base of the PR and between 1f4e81c and 1f4e81c.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
Eligible built-in time-driven shared transitions now retain their clock when the target layout changes at or before 80% progress. The transition adjusts its starting frame to preserve the on-screen geometry as it follows the updated target. Runtime tests and documentation describe when a transition retains its clock or restarts.
Shared transitions now keep their clock when only the target layout changes before 80% progress, and they restart when the transform or style changes. No concrete merge-blocking risk remains in the reviewed changes. The documented limitations are size-dependent transforms and under-damped springs.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: a built-in shared transition keeps its clock when the target's layout changes. The changeset implements this in SharedTransitions.cpp, LayoutAnimationsProxy, and Share…
Linked Issues check
Objective [#11311]: keep the clock of a built-in timed shared transition when the target layout changes, and shift the start frame so the on-screen frame does not jump. Addressed by #11732 (current PR…
Out of Scope Changes check
The summaries tie each changed file in #11732 to the clock-keeping objective of #11311. C++ files (LayoutAnimationsProxy.h, LayoutAnimationsProxyCommon.cpp/.h, SharedTransitionGeometry.cpp/.h, SharedT…
Description check
The description states that the PR fixes issue #11311 by keeping the clock of a built-in timed shared transition when the target layout changes, by shifting the frame interpolation start (frameStartSh…
Full details: Title check
Explanation
The title names the main change: a built-in shared transition keeps its clock when the target's layout changes. The changeset implements this in SharedTransitions.cpp, LayoutAnimationsProxy, and SharedTransitionGeometry, and the PR objectives state the same goal. The title uses the fix(SET) prefix, which fits the fix and its changelog fragment.
Full details: Linked Issues check
Explanation
Objective [#11311]: keep the clock of a built-in timed shared transition when the target layout changes, and shift the start frame so the on-screen frame does not jump. Addressed by #11732 (current PR), per the attested summaries: frameStartShift in LayoutAnimationsProxyCommon.h, applied in interpolateGeometryOf (LayoutAnimationsProxyCommon.cpp); keepFrameAt and startChangeAt in SharedTransitionGeometry.cpp/.h, where startChangeAt asserts progress below 1; keepsClockOnLayoutChange and followTargetLayoutFromFrameOnScreen in SharedTransitions.cpp, with a 0.8 progress cutoff and fallback to restart for other cases. This matches the issue's proposed shift (start' = (current - progress x newTarget) / (1 - progress)) and its request for a fallback near or above progress 1. The new runtime test keeps its clock and its frame when the layout of the target changes and the updated expectations in the four existing tests cover the behavior. The documented limit (size-dependent target transforms still jump by p x change) is not one of the issue's stated scenarios. Stack note: #11715, #11724, #11728, #11730 and #11731 address other behaviors and do not contribute to this objective. #11737, #11738 and #11739 are uncertain and do not affect it. Limits: the change diff for SharedTransitions.cpp could not be read because the changed blobs are missing from the checkout, so this verdict relies on attested summaries. The tests were not executed.
Full details: Out of Scope Changes check
Explanation
The summaries tie each changed file in #11732 to the clock-keeping objective of #11311. C++ files (LayoutAnimationsProxy.h, LayoutAnimationsProxyCommon.cpp/.h, SharedTransitionGeometry.cpp/.h, SharedTransitions.cpp) implement the frame shift, clip shift and 0.8 cutoff. The interpolateSharedTransitionGeometry signature change passes the start frame that the shift needs. The four runtime test files update expectations from restart to kept clock, or move one change to 85% progress to keep restart coverage. The added targetRotation fixture input supports the new rotation-change test. The limitations doc and the changelog fragment describe the new behavior. The SharedTransitionGeometry.cpp debug compatibility header include has no behavior effect and is not treated as out of scope. Limit: the file diffs could not be read (changed blobs missing from the checkout), so this verdict relies on the summaries.
Full details: Description check
Explanation
The description states that the PR fixes issue #11311 by keeping the clock of a built-in timed shared transition when the target layout changes, by shifting the frame interpolation start (frameStartShift) instead of restarting the move. It lists the changed behavior, its limits, alternatives considered, and the test plan with runtime tests for the layout-animation files in the changeset. It is specific to the changeset, so it is not off-topic or vague.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
This pull request was authored by AI on behalf of @pawicao.
Fixes #11311
Summary
When the layout of the target changed during a built-in timed shared transition, the moving view started a new move with a new clock. The move then took the time until the change plus the full duration again, and a spring started again from rest. #11279 kept the clock but made the view jump by
progress × changein one frame.I kept the clock and moved the start of the frame interpolation instead. A running built-in animation now has a frame start shift. On a layout change of the same target, the shift changes by
-change × p / (1 - p), so the frame on screen stays and the move ends on time. The clip start moves the same way. This applies up to 80% of the progress, when only the frame of the target changes and the transition of the view stays the same. A later change, a change of an animated style, of the transform as the view draws it or of the transition, and custom or timed progress animations start a new move as before.Limits: a layout change that also changes the transform of the target as the view draws it starts a new move. This includes a transform that depends on the size (a percent translate, or a rotation or scale around the centre), and a rotated or scaled parent. A spring with
dampingRatiobelow 1 can overshoot more after the change. The default spring hasdampingRatio1.Alternatives considered:
(p - p0) / (1 - p0): the same line, but a reparent must move the stored frame, and each frame needs a division.startViewitself: this changes percent translates, the transform origin and the distance of nested carriers.Test plan
keeps its clock and its frame when the layout of the target changes: on the base the width at 75% is 97.5 instead of 115 and the run starts two times, on the iPhone 17 Pro simulator and on a Galaxy A57 (Android 17). It passes with the fix.starts a new move when the transform of the target changes with its layout: the target changes its width and its rotation at 25%. Without the transform compare the run starts one time instead of two (iPhone 17 Pro simulator). It passes with the fix.Clips: Galaxy A57, Debug build,
adb screenrecordat the 120 Hz display rate. A linear 1500 ms transition; the target grows 750 ms after it mounts. Before, the view moves for 2.26 s. After, it moves for 1.49 s, and the width changes by at most 16 px per frame at the change.Before:
before.mp4
After:
after.mp4
Changelog
yarn changelog:addfor each changed package, or this PR does not changereact-native-reanimatedorreact-native-worklets.