Skip to content

Use bezier-easing 3.2 closed-form solver in Easing.bezier - #58941

Open
gre wants to merge 1 commit into
react:mainfrom
gre:bezier-easing-3
Open

gre wants to merge 1 commit into
react:mainfrom
gre:bezier-easing-3

Conversation

@gre

@gre gre commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Summary:

Hi, this is @gre, I'm the author of bezier-easing, which is also embedded in this project (packages/react-native/Libraries/Animated/bezier.js). The library was recently improved with better performance and more reliability, and I wanted to backport the benefits here.

This brings its 3.2 solver (closed-form, no sample table):

  • Fixes steep curves. Easing.bezier(1, 0, 0, 1)(0.4996) returned 0.348 instead of 0.431, and the value went backwards around the middle.
  • Exact. Error goes from up to ~1e-3 (~8e-5 on Easing.ease) to ~1e-14.
  • Faster on Hermes. A call is 3-5x faster, and creating an easing is 10x faster.
  • Smaller. 682 → 424 bytes min+gz.
  • x outside [0, 1] now saturates to 0 / 1. The old search returned arbitrary values there (Easing.bezier(0.25, 0.1, 0.25, 1)(-0.5) gave 0.39). This is visible with interpolate + extrapolate: 'extend'. Linear curves are unchanged.
download

Changelog:

[GENERAL] [FIXED] - Easing.bezier: fix wrong values on steep curves such as (1, 0, 0, 1); input outside [0, 1] now saturates

Test Plan:

  • Added precision, monotonicity and out-of-range tests to bezier-itest.js. yarn fantom packages/react-native/Libraries/Animated/ passes, and yarn flow check, eslint and prettier are clean.
  • Compared against bezier-easing 3.2 on ~7.6M values (random curves, presets, edge cases): bit-identical.

Replace the sample table + Newton-Raphson + bisection search with the
closed-form solver of bezier-easing 3.2: exact (~1e-14 instead of up to
~1e-3), no backward jump on steep curves such as (1, 0, 0, 1), faster.

Inputs outside [0, 1] now saturate to 0 / 1 instead of going through
the old search, which returned arbitrary values there.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 8, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Oct 8, 2026

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

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant