Skip to content

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

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

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
@gre

gre commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Hey @bartlomiejbloniarz @javache 👋, could you take a look when you have a moment?
It's a drop-in fix for the Animated bezier solver. This is part of backporting the fix in all implementations that were based on bezier-easing original library ( gre/bezier-easing#85 )
Cheers

@javache

javache commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Thanks for contributing this back to our super-old fork!

@meta-codesync

meta-codesync Bot commented Oct 26, 2026

Copy link
Copy Markdown

@javache has imported this pull request. If you are a Meta employee, you can view this in D127563019.

@meta-codesync meta-codesync Bot closed this in 2ae713e Oct 26, 2026
@meta-codesync meta-codesync Bot added the Merged This PR has been merged. label Oct 26, 2026
@meta-codesync

meta-codesync Bot commented Oct 26, 2026

Copy link
Copy Markdown

@javache merged this pull request in 2ae713e.

@react-native-bot

Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @greweb in 2ae713e

When will my fix make it into a release? | How to file a pick request?

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. Merged This PR has been merged. 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.

3 participants