Skip to content

chore: Trim comments on the platform transition path - #10222

Closed
MatiPl01 wants to merge 2 commits into
@matipl01/android-css-shared-mount-retryfrom
@matipl01/android-css-trim-transition-comments
Closed

MatiPl01 wants to merge 2 commits into
@matipl01/android-css-shared-mount-retryfrom
@matipl01/android-css-trim-transition-comments

Conversation

@MatiPl01

@MatiPl01 MatiPl01 commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Drops comments that restate the code and shortens those carrying a second sentence the first already implied.

The Kotlin binary search in CSSEasing is renamed from lastIndexAtOrBefore to firstSmallerOrEqual, matching its C++ counterpart in CSS/utils/algorithms.cpp, so both turn up in one grep. That is what the comment pointing across languages was there for. They cannot share a file - ObjectAnimator calls TimeInterpolator.getInterpolation from Java every frame, so the curve has to be evaluated Java-side rather than over JNI.

Kept the notes that would otherwise be re-derived: the easing type mirroring PlatformEasing::Type, resolveView throwing rather than returning null, and overrideDurationScale being @hide.

@MatiPl01 MatiPl01 self-assigned this Aug 11, 2026
@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • Documentation
    • Clarified CSS easing behavior and handling of duplicate stops without changing interpolation results.
    • Added guidance on animation playback acceptance, retrying pending starts, interrupted transitions, and resolving absolute timelines.
    • Updated duration-scaling guidance to explain how animation durations are adjusted during playback.

Walkthrough

The PR updates CSS easing, transition playback, and duration-scaling documentation. It also renames a private easing lookup helper. Runtime behavior and public declarations remain unchanged.

Changes

CSS animation updates

Layer / File(s) Summary
CSS easing helper update
packages/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/css/CSSEasing.kt
The duplicate-x lookup helper is renamed to firstSmallerOrEqual. Both interpolators use the new name.
Transition and duration documentation
packages/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/css/CSSPlatformTransitionsManager.kt, packages/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/css/DurationScale.kt
Comments clarify native playback acceptance, pending-start retries, interruption handling, elapsed-time resolution, and duration scaling.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary change: trimming comments on the platform transition path.
Description check ✅ Passed The description accurately explains the comment cleanup, helper rename, retained notes, and Java-side easing evaluation.
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.
✨ 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-trim-transition-comments

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 force-pushed the @matipl01/android-css-trim-transition-comments branch from dd83fb4 to 98b66be Compare August 11, 2026 16:14

@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/java/com/swmansion/reanimated/css/CSSEasing.kt`:
- Line 26: Rename the Kotlin helper firstSmallerOrEqual and its corresponding
C++ helper to lastIndexAtOrBefore, updating all declarations and call sites
while preserving the existing returned-index behavior.
🪄 Autofix

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: ee65557b-4a73-4e92-a702-bbefc65df96a

📥 Commits

Reviewing files that changed from the base of the PR and between dd83fb4 and 98b66be.

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

* x values resolves to its last entry rather than an arbitrary one.
*/
private fun lastIndexAtOrBefore(
private fun firstSmallerOrEqual(

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.

📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

fd -i '^algorithms\.cpp$' packages/react-native-reanimated -x \
  rg -n -C 12 '\b(firstSmallerOrEqual|lastIndexAtOrBefore)\b' {}

Repository: software-mansion/react-native-reanimated

Length of output: 534


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- Kotlin helper and call sites ---'
rg -n -C 14 '\b(firstSmallerOrEqual|lastIndexAtOrBefore)\b' \
  packages/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/css/CSSEasing.kt

printf '%s\n' '--- C++ declaration and related references ---'
rg -n -C 8 '\bfirstSmallerOrEqual\b|\blastIndexAtOrBefore\b' \
  packages/react-native-reanimated/common/cpp \
  packages/react-native-reanimated/android \
  packages/react-native-reanimated/ios 2>/dev/null || true

printf '%s\n' '--- Documentation describing the helper ---'
rg -n -i -C 5 'smaller|upper.?bound|binary search|easing' \
  packages/react-native-reanimated/common/cpp \
  packages/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/css \
  2>/dev/null | head -240

Repository: software-mansion/react-native-reanimated

Length of output: 21098


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- all matching declarations and uses ---'
rg -n -C 6 '\bfirstSmallerOrEqual\b|\blastIndexAtOrBefore\b' packages/react-native-reanimated || true

printf '%s\n' '--- algorithm files ---'
fd -i 'algorithms\.(h|cpp)$' packages/react-native-reanimated -x sh -c '
  echo "### $1"
  cat -n "$1"
' sh {}

printf '%s\n' '--- point-array construction and interpolation inputs ---'
rg -n -C 8 'pointsX|easingPointsX|LinearStopsInterpolator|StepsInterpolator|linear\(' \
  packages/react-native-reanimated/common \
  packages/react-native-reanimated/android/src/main/java \
  2>/dev/null | head -300

Repository: software-mansion/react-native-reanimated

Length of output: 23814


🏁 Script executed:

python3 - <<'PY'
from bisect import bisect_right

def kotlin_equivalent(x, points):
    low, high = 0, len(points)
    while low < high:
        mid = (low + high) >> 1
        if points[mid] <= x:
            low = mid + 1
        else:
            high = mid
    return 0 if low == 0 else low - 1

cases = [
    ([-1.0, 0.0, 0.5, 1.0], -2.0),
    ([-1.0, 0.0, 0.5, 1.0], -1.0),
    ([-1.0, 0.0, 0.5, 1.0], 0.5),
    ([-1.0, 0.0, 0.5, 1.0], 2.0),
    ([0.0, 0.5, 0.5, 1.0], 0.5),
]

for points, x in cases:
    actual = kotlin_equivalent(x, points)
    expected_upper_bound = bisect_right(points, x) - 1
    expected_with_fallback = max(0, expected_upper_bound)
    print({
        "points": points,
        "x": x,
        "returned": actual,
        "last_index_at_or_before": expected_upper_bound,
        "implementation_with_below-first-fallback": expected_with_fallback,
    })
    assert actual == expected_with_fallback
PY

Repository: software-mansion/react-native-reanimated

Length of output: 860


Rename the helper to match its returned index.

For x >= pointsX[0], firstSmallerOrEqual returns the last index at or before x, including the last duplicate. Rename the Kotlin and C++ helpers to lastIndexAtOrBefore.

🤖 Prompt for 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.

In
`@packages/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/css/CSSEasing.kt`
at line 26, Rename the Kotlin helper firstSmallerOrEqual and its corresponding
C++ helper to lastIndexAtOrBefore, updating all declarations and call sites
while preserving the existing returned-index behavior.

Every start waiting for its View to mount posted its own Choreographer
callback each frame. Waiting starts now share a single callback that walks
them and reschedules only while any remain.

Keying them by transition also removes the start tokens: a newer start for
a key replaces the pending entry, so a superseded request cannot begin.
Drops comments that restate the code and shortens those carrying a second
sentence the first already implied. The Kotlin binary search is renamed to
firstSmallerOrEqual so it and its C++ counterpart turn up in the same grep,
which the comment pointing across languages was doing instead.

Kept the notes that would otherwise be re-derived: the easing type mirroring
PlatformEasing::Type, resolveView throwing rather than returning null, and
overrideDurationScale being @hide.
@MatiPl01
MatiPl01 force-pushed the @matipl01/android-css-shared-mount-retry branch from e3de810 to 73aee14 Compare August 11, 2026 16:40
@MatiPl01
MatiPl01 force-pushed the @matipl01/android-css-trim-transition-comments branch from 98b66be to cd745da Compare August 11, 2026 16:40
@MatiPl01
MatiPl01 force-pushed the @matipl01/android-css-shared-mount-retry branch from 73aee14 to 05c9697 Compare August 11, 2026 16:43
@MatiPl01

Copy link
Copy Markdown
Contributor Author

Folded into the PRs that introduce these comments (#10090 and #10214), so this carries no changes of its own.

@MatiPl01 MatiPl01 closed this Aug 11, 2026
@MatiPl01
MatiPl01 deleted the @matipl01/android-css-trim-transition-comments branch August 11, 2026 16:43
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