-
-
Notifications
You must be signed in to change notification settings - Fork 830
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removing background-color from willChange
- Loading branch information
1 parent
4d1ec5d
commit 1cdf396
Showing
5 changed files
with
325 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
315 changes: 315 additions & 0 deletions
315
dev/html/public/benchmarks/pregenerated-background-color.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,315 @@ | ||
<html> | ||
<head> | ||
<title>Pre-generated keyframes performance</title> | ||
<!-- | ||
This file demonstrates that the performance of pre-generated keyframes is poor in Chrome | ||
under surprising circumstances. | ||
Specifically, pre-generated keyframes are fine in isolation. But when combined with a | ||
requestAnimationFrame animation, AND another WAAPI animation, performance becomes | ||
(literally) 100x worse. | ||
To use: | ||
1. Open this file in Chrome | ||
2. Open performance tab and throttle 6x | ||
3. On an M1 Pro notice style recalculations of ~170ms | ||
4. Comment `animation.ready` block, disabling requestAnimationFrame animation | ||
5. Profile and notice style recalculations of ~1.5ms | ||
6. Undo changes | ||
7. Comment out `opacity` WAAPI animation, moving `const animation = ` to background-color animation. | ||
8. Profile and notice style recalculations of ~2.5ms | ||
9. Undo changes | ||
10. Replace `backgroundColor: pregeneratedKeyframes` with `backgroundColor: ["#f00", "#00f"]` | ||
11. Profile and notice style recalculations of ~2.5ms | ||
--> | ||
<style> | ||
body { | ||
display: flex; | ||
flex-wrap: wrap; | ||
gap: 10px; | ||
height: 100vh; | ||
overflow: hidden; | ||
} | ||
|
||
.box { | ||
width: 50px; | ||
height: 50px; | ||
background-color: #f00; | ||
opacity: 0; | ||
will-change: auto !important; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<div class="box"></div> | ||
<script type="module" src="/src/imports/framer-motion-dom.js"></script> | ||
<script type="module"> | ||
const boxes = document.querySelectorAll(".box") | ||
let startTime = 0 | ||
const duration = 10000 | ||
const rotateRate = 360 / duration | ||
|
||
function rotate(timestamp) { | ||
const elapsed = timestamp - startTime | ||
boxes.forEach((box, index) => { | ||
box.style.transform = `rotate(${elapsed * rotateRate}deg)` | ||
}) | ||
|
||
requestAnimationFrame(rotate) | ||
} | ||
|
||
function animateRotation() { | ||
startTime = performance.now() | ||
requestAnimationFrame(rotate) | ||
} | ||
// animateRotation() | ||
|
||
Motion.animate( | ||
boxes, | ||
{ opacity: [0, 1], backgroundColor: ["#f00", "#00f"] }, | ||
{ duration: duration / 1000, repeat: Infinity } | ||
) | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters