Skip to content

fix(SET): keep the clock of a built-in transition when the layout of its target changes - #11732

Draft
pawicao wants to merge 6 commits into
@pawicao/set-timed-progress-keysfrom
@pawicao/set-layout-change-keeps-clock
Draft

pawicao wants to merge 6 commits into
@pawicao/set-timed-progress-keysfrom
@pawicao/set-layout-change-keeps-clock

Conversation

@pawicao

@pawicao pawicao commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

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 × 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.
  • Follow only the new end, as in fix(SET): keep the clock of a built-in shared transition when the layout of its target changes #11279: a visible jump.
  • 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.

@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

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.

Possibly related PRs

Suggested labels: lib: Reanimated

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: Minimal · up to 1f4e8

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: Passed 4

Check name Status Explanation
Title check Passed 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 Passed 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 Passed 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 Passed 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.

Share

Recent review info

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: adb24521-141f-4986-9df7-9200b7bb04a0
Commits

Reviewing files that changed from the base of the PR and between 840ddd9 and 1f4e81c.

Files selected for processing: 3

  • apps/common-app/runtime-tests/reanimated/tests/layoutAnimations/sharedTransitionMovingTarget.test.tsx
  • docs/docs-reanimated/docs/shared-element-transitions/limitations.mdx
  • packages/react-native-reanimated/Common/cpp/reanimated/LayoutAnimations/SharedTransitions.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments

Minor 1
  1. Layout and color changes together can leave the old color on screen until the move lands.
Review info

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: cc1b18c4-fbcb-4431-b380-410b58b56a7d
Commits

Reviewing files that changed from the base of the PR and between 6ec8b16 and a890bb5.

Files selected for processing: 12

  • apps/common-app/runtime-tests/reanimated/tests/layoutAnimations/sharedTransitionCarrier.test.tsx
  • apps/common-app/runtime-tests/reanimated/tests/layoutAnimations/sharedTransitionCarrierRetarget.test.tsx
  • apps/common-app/runtime-tests/reanimated/tests/layoutAnimations/sharedTransitionMovingTarget.test.tsx
  • apps/common-app/runtime-tests/reanimated/tests/layoutAnimations/sharedTransitionNested.test.tsx
  • docs/docs-reanimated/docs/shared-element-transitions/limitations.mdx
  • packages/react-native-reanimated/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.h
  • packages/react-native-reanimated/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.cpp
  • packages/react-native-reanimated/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.h
  • packages/react-native-reanimated/Common/cpp/reanimated/LayoutAnimations/SharedTransitionGeometry.cpp
  • packages/react-native-reanimated/Common/cpp/reanimated/LayoutAnimations/SharedTransitionGeometry.h
  • packages/react-native-reanimated/Common/cpp/reanimated/LayoutAnimations/SharedTransitions.cpp
  • packages/react-native-reanimated/changelog/set-layout-change-keeps-clock.fix.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments

Minor 1
  1. Restart when the target explicitly changes its transform.
Review info

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: 5c8e49a0-7c90-4581-bb5a-512629c4f5cd
Commits

Reviewing files that changed from the base of the PR and between a890bb5 and 9049ce0.

Files selected for processing: 2

  • packages/react-native-reanimated/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.h
  • packages/react-native-reanimated/Common/cpp/reanimated/LayoutAnimations/SharedTransitions.cpp
Files with no reviewable changes: 1

  • packages/react-native-reanimated/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.h

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@pawicao
pawicao force-pushed the @pawicao/set-layout-change-keeps-clock branch from 9049ce0 to 840ddd9 Compare December 3, 2026 03:01
@pawicao
pawicao force-pushed the @pawicao/set-layout-change-keeps-clock branch from 840ddd9 to 1f4e81c Compare December 3, 2026 03:27
@pawicao
pawicao added this pull request to stack #11741 December 3, 2026 10:44

This branch has not been deployed

No deployments
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.

[SET] A layout change of the target during a built-in transition starts the move again

1 participant