Skip to content

feat: Resolve CSS transition timelines for Android and bridge them over JNI - #10060

Merged
MatiPl01 merged 7 commits into
mainfrom
@matipl01/android-css-platform-transition-backend
Aug 12, 2026
Merged

MatiPl01 merged 7 commits into
mainfrom
@matipl01/android-css-platform-transition-backend

Conversation

@MatiPl01

@MatiPl01 MatiPl01 commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Owns the per-property state CSS reversing needs: it detects a reversal against the in-flight transition's start value, reverse-shortens the duration through the easing curve, and hands the resolved timeline to the Kotlin animator from #10090.

Elapsed time crosses the boundary instead of an absolute start. Reverse-shortening backdates the start and transition-delay pushes it forward, and computing it here keeps Kotlin off a second clock that would drift from the loop's timestamp.

Easings cross as the same normalized point arrays the loop uses, so nothing reimplements the easing spec on the other side of the boundary.

Nothing routes to this yet; it is inert until the next PR flips the gate.

Stacked on #10090.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: f3a3adb7-a633-4453-ac89-aaf64ec47f21

📥 Commits

Reviewing files that changed from the base of the PR and between 0ec3bc1 and d87aa6d.

📒 Files selected for processing (1)
  • packages/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/css/CSSPlatformTransitionsManager.kt

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added Android support for CSS transitions on scalar properties.
    • Supports cubic-bezier, steps, and linear-stop easing configurations.
    • Transitions can preserve their final animated values after completion.
    • Added smooth handling for transition reversals and value reconciliation.
  • Bug Fixes

    • Improved transition lifecycle management, including reliable cleanup when transitions are removed or replaced.

Walkthrough

Adds Android C++ CSS transition management with easing conversion, scalar transition application, reversal handling, and removal. Wires transition callbacks through NativeProxy JNI to the Kotlin manager, which preserves completed values for persistent transitions.

Changes

Android CSS transitions

Layer / File(s) Summary
Transition contract and easing representation
packages/react-native-reanimated/android/src/main/cpp/reanimated/android/CSS/CSSPlatformTransitions.h, packages/react-native-reanimated/android/src/main/cpp/reanimated/android/CSS/CSSPlatformTransitions.cpp
Defines PlatformEasing, transition callbacks, active-transition storage, and CSS easing conversion.
Transition application and removal
packages/react-native-reanimated/android/src/main/cpp/reanimated/android/CSS/CSSPlatformTransitions.cpp
Applies scalar transitions, handles reversals, stores active state, and removes transitions by view and property.
NativeProxy and Java manager wiring
packages/react-native-reanimated/android/src/main/cpp/reanimated/android/NativeProxy.h, packages/react-native-reanimated/android/src/main/cpp/reanimated/android/NativeProxy.cpp, packages/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NativeProxy.kt, packages/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/css/CSSEasing.kt
Forwards transition values, easing points, persistence, and removal operations between C++ and Kotlin.
Persistent transition lifecycle
packages/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/css/CSSPlatformTransitionsManager.kt
Retains completed values for persistent transitions and removes animator state for non-persistent transitions.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CSSPlatformTransitions
  participant NativeProxy
  participant CSSPlatformTransitionsManager
  participant AndroidAnimator
  CSSPlatformTransitions->>NativeProxy: cssAnimateTransition with values and easing
  NativeProxy->>CSSPlatformTransitionsManager: animateTransition
  CSSPlatformTransitionsManager->>AndroidAnimator: start transition
  AndroidAnimator-->>CSSPlatformTransitionsManager: completion callback
  CSSPlatformTransitionsManager->>CSSPlatformTransitionsManager: retain or remove completed state
  CSSPlatformTransitions->>NativeProxy: cssRemoveTransition
  NativeProxy->>CSSPlatformTransitionsManager: removeTransition
Loading

Possibly related PRs

Suggested reviewers: pawicao

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the Android CSS transition timeline resolution and JNI bridging implemented by the pull request.
Description check ✅ Passed The description accurately explains per-property state, reversal handling, timeline resolution, easing transfer, and the planned follow-up activation.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch @matipl01/android-css-platform-transition-backend

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

Comment @coderabbitai help to get the list of available commands.

@MatiPl01 MatiPl01 self-assigned this Jul 27, 2026
@MatiPl01
MatiPl01 force-pushed the @matipl01/android-css-platform-transition-backend branch 3 times, most recently from fc321a9 to a1a4c84 Compare July 27, 2026 11:48
Base automatically changed from @matipl01/collapse-css-platform-apply-hooks to main July 27, 2026 13:41
@MatiPl01
MatiPl01 force-pushed the @matipl01/android-css-platform-transition-backend branch from 5045268 to 7eee6dd Compare July 29, 2026 10:29
@MatiPl01
MatiPl01 changed the base branch from main to @matipl01/android-css-transition-player July 29, 2026 10:29
@MatiPl01 MatiPl01 changed the title feat: Add the Android CSS platform transition backend feat: Resolve CSS transition timelines for Android and bridge them over JNI Jul 29, 2026
@MatiPl01
MatiPl01 force-pushed the @matipl01/android-css-platform-transition-backend branch 2 times, most recently from 94063c7 to 1357669 Compare July 29, 2026 18:39
@MatiPl01
MatiPl01 changed the base branch from @matipl01/android-css-transition-player to @matipl01/android-css-transition-reconciliation July 29, 2026 18:39
@MatiPl01
MatiPl01 force-pushed the @matipl01/android-css-platform-transition-backend branch from 1357669 to 1e0895d Compare July 29, 2026 22:41
@MatiPl01
MatiPl01 force-pushed the @matipl01/android-css-platform-transition-backend branch from 1e0895d to db219a6 Compare July 29, 2026 23:01
@MatiPl01
MatiPl01 force-pushed the @matipl01/android-css-platform-transition-backend branch 3 times, most recently from 8681967 to 2cd0923 Compare July 30, 2026 13:50
@MatiPl01
MatiPl01 marked this pull request as ready for review July 30, 2026 16:38

@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 posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@packages/react-native-reanimated/android/src/main/cpp/reanimated/android/CSS/CSSPlatformTransitions.cpp`:
- Around line 94-103: In the transition loop around animate_, remove or cancel
the existing platform transition for the current key before returning false when
animate_ fails. Ensure both the prior animator and its active_ entry are cleaned
up so loop fallback cannot conflict with the old Android animator or stale
reversal state.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a6563d7c-8083-404d-a0ba-7b6bf6789f16

📥 Commits

Reviewing files that changed from the base of the PR and between 102d063 and 224ada3.

📒 Files selected for processing (5)
  • packages/react-native-reanimated/android/src/main/cpp/reanimated/android/CSS/CSSPlatformTransitions.cpp
  • packages/react-native-reanimated/android/src/main/cpp/reanimated/android/CSS/CSSPlatformTransitions.h
  • packages/react-native-reanimated/android/src/main/cpp/reanimated/android/NativeProxy.cpp
  • packages/react-native-reanimated/android/src/main/cpp/reanimated/android/NativeProxy.h
  • packages/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NativeProxy.kt

@MatiPl01
MatiPl01 force-pushed the @matipl01/android-css-platform-transition-backend branch 2 times, most recently from 942016e to 35ec2e7 Compare August 11, 2026 16:47
@MatiPl01
MatiPl01 force-pushed the @matipl01/android-css-platform-transition-backend branch from 35ec2e7 to 43c2fd7 Compare August 11, 2026 23:56
@MatiPl01
MatiPl01 force-pushed the @matipl01/android-css-platform-transition-backend branch from a06bc94 to d87aa6d Compare August 12, 2026 08:56
Base automatically changed from @matipl01/android-css-transition-reconciliation to main August 12, 2026 10:58
@MatiPl01
MatiPl01 force-pushed the @matipl01/android-css-platform-transition-backend branch from d87aa6d to 010000d Compare August 12, 2026 10:58
@MatiPl01
MatiPl01 requested a review from tjzel August 12, 2026 11:21
Owns the per-property state CSS reversing needs: it detects a reversal against
the in-flight transition's start value, reverse-shortens the duration through
the easing curve, and hands the resolved timeline to the Kotlin animator.

Elapsed time crosses instead of an absolute start. Reverse-shortening backdates
the start and transition-delay pushes it forward, and computing it here keeps
Kotlin off a second clock that would drift from the loop's timestamp.

Easings cross as the same normalized point arrays the loop uses, so nothing
reimplements the easing spec on the other side of the boundary.
Hands the animator the resolved start timestamp instead of an elapsed offset, so
it can subtract against the clock once it is actually on the UI thread. Apple
already takes the same value as CALayer.beginTime.
Nothing needs setTransitionAlpha any more, so the manager no longer requires
API 29 and can be constructed unconditionally. That makes the field non-null and
removes the null handling that went with it.
A variadic generic lambda forwards to the shared object in three lines, so the
bindShared template it replaced can go. Ownership is unchanged: the captured
shared_ptr still keeps the object alive for as long as the callbacks do.

Also drops comments that named the file they mirror or restated a field list.
@MatiPl01
MatiPl01 force-pushed the @matipl01/android-css-platform-transition-backend branch from 010000d to 8fe070b Compare August 12, 2026 11:31
@MatiPl01
MatiPl01 requested a review from pawicao August 12, 2026 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants