motiondivision / motion

A modern animation library for React and JavaScript
https://motion.dev
MIT License
25.84k stars 849 forks source link

Perf: Improving performance of calculated transform comparison #2735

Closed mattgperry closed 4 months ago

mattgperry commented 4 months ago

This PR replaces the calculated transform comparison from creating a transform string and comparing the string, to comparing the Delta features directly.

This makes the delta comparison 100x faster in Safari and 20x faster in Chrome for an overall 1% per-frame reduction in script time.

There's also a little bit of a drive-by where projection metrics are recorded only if MotionDebug is present on window.