Site crash due to FPS transition triggering a massive calc tree that ends up overflowing the stack.
Categories
(Core :: CSS Transitions and Animations, defect, P3)
Tracking
()
People
(Reporter: jakea, Unassigned)
References
Details
Attachments
(1 file)
|
27.93 KB,
text/plain
|
Details |
https://deploy-preview-3--prop-for-that.netlify.app/
Open the page above. Scroll around a bit. The tab will crash.
I think it's something to do with calc() ending up nested internally. The stack has a lot of
0x0000000314fc92d4 XUL`style::values::generics::calc::GenericCalcNode$LT$L$GT$::resolve_internal::haab154f8676dae4c(self=0x0000000105facb40, leaf_to_output_fn=0x000000016bc50b07) at calc.rs:960:39
Comment 1•5 months ago
|
||
Comment 2•5 months ago
|
||
It does seem like that page is creating an extremely nested calc(), yeah...
| Reporter | ||
Comment 3•5 months ago
|
||
They worked around it by reducing the frequency they were updating the fps value.
Comment 4•5 months ago
|
||
There's some width animation that's getting a bit insane:
from=calc((0.0795176 * ((0.0902915 * ((0.121569 * ((0.152823 * ((0.128757 * ((0.0733192 * ((0.111883 * ((0.133369 * ((0.122332 * ((0.100483 * ((0.0430473 * ((0.00335719 * ((0.128209 * ((0.0433193 * ((0.103013 * ((0.0164842 * ((0.00502697 * ((0.0475304 * ((0.059183 * ((0.0598108 * ((0.0387707 * ((0.0453012 * ((0.0832714 * ((0.172771 * ((0.130287 * ((0.0364755 * ((0.136753 * ((0.0921445 * ((0.170324 * ((0.134633 * ((0.155437 * ((0.119692 * ((0.0752179 * ((0.0959218 * ((0.0359836 * ((0.0805729 * ((0.045436 * ((0.0406303 * ((0.0606498 * ((0.045042 * ((0.0492906 * ((0.103586 * ((0.139387 * ((0.0856149 * ((0.116746 * ((0.112462 * ((0.109867 * ((0.108781 * ((0.0969144 * ((0.038514 * ((0.0918807 * ((0.126869 * ((0.190388 * ((0.058371 * ((0.116263 * ((0.0879295 * ((0.11788 * ((0.0694412 * ((0.0607552 * ((0.0503555 * ((0.1776 * ((0.143994 * ((0.185108 * ((0.181923 * ((0.191308 * ((0.202227 * ((0.209257 * ((0.139485 * ((0.165727 * ((0.213394 * ((0.185781 * ((0.148089 * ((0.198988 * ((0.196431 * ((0.205296 * ((0.20766 * ((0.21496 * ((0.139265 * ((0.0516589 * ((0.137687 * ((0.0887818 * ((0.15592 * ((0.109234 * ((0.234431 * ((0.14184 * ((0.239654 * ((0.150105 * ((0.0088013 * ((0.23649 * ((0.147354 * ((0.117776 * ((0.0203673 * ((0.108508 * ((0.00446863 * ((0.0123148 * ((0.0904475 * ((0.162685 * ((0.0506651 * ((0.0412618 * ((0.0544048 * ((0.0327511 * ((0.0168047 * ((0.0837258 * ((0.127319 * ((0.0112008 * ((0.00149296 * ((0.0663546 * ((0.0000211417 * ((0.051976 * ((0.109174 * ((0.115816 * ((0.00817758 * ((0.0129647 * ((0.0876664 * ((0.0000109346 * ((0.163012 * ((0.114146 * ((0.00624707 * ((0.0550788 * clamp(0%, 15.8333%, 100%)) + (0.944921 * clamp(0%, 15%, 100%)))) + (0.993753 * clamp(0%, 14.1667%, 100%)))) + (0.885854 * clamp(0%, 15%, 100%)))) + (0.836988 * clamp(0%, 14.1667%, 100%)))) + (0.999989 * clamp(0%, 15%, 100%)))) + (0.912334 * clamp(0%, 15.8333%, 100%)))) + (0.987035 * clamp(0%, 15%, 100%)))) + (0.991822 * clamp(0%, 15.8333%, 100%)))) + (0.884184 * clamp(0%, 15%, 100%)))) + (0.890826 * clamp(0%, 15.8333%, 100%)))) + (0.948024 * clamp(0%, 15%, 100%)))) + (0.999979 * clamp(0%, 15.8333%, 100%)))) + (0.933645 * clamp(0%, 16.6667%, 100%)))) + (0.998507 * clamp(0%, 15.8333%, 100%)))) + (0.988799 * clamp(0%, 16.6667%, 100%)))) + (0.872681 *clamp(0%, 17.5%, 100%)))) + (0.916274 * clamp(0%, 16.6667%, 100%)))) + (0.983195 * clamp(0%, 17.5%, 100%)))) + (0.967249 * clamp(0%, 16.6667%, 100%)))) + (0.945595 * clamp(0%, 15.8333%, 100%)))) + (0.958738 * clamp(0%, 15%, 100%)))) + (0.949335 * clamp(0%, 14.1667%, 100%)))) + (0.837315 * clamp(0%, 15%, 100%)))) + (0.909553 * clamp(0%, 15.8333%, 100%)))) + (0.987685 * clamp(0%, 15%, 100%)))) + (0.995531 * clamp(0%, 15.8333%, 100%)))) + (0.891492 * clamp(0%, 15%, 100%)))) + (0.979633 * clamp(0%, 14.1667%, 100%)))) + (0.882224 * clamp(0%, 18.3333%, 100%)))) + (0.852646 * clamp(0%, 17.5%, 100%)))) + (0.76351 * clamp(0%, 16.6667%, 100%)))) + (0.991199 * clamp(0%, 17.5%, 100%)))) + (0.849895 * clamp(0%, 16.6667%, 100%)))) + (0.760346 * clamp(0%, 15.8333%, 100%)))) + (0.85816 * clamp(0%, 16.6667%, 100%)))) + (0.765569 * clamp(0%, 20%, 100%)))) + (0.890766 * clamp(0%, 20.8333%, 100%)))) + (0.84408 * clamp(0%, 20%, 100%)))) + (0.911218 * clamp(0%, 19.1667%, 100%)))) + (0.862313 * clamp(0%, 21.6667%, 100%)))) + (0.948341 * clamp(0%, 20.8333%, 100%)))) + (0.860735 * clamp(0%, 20%, 100%)))) + (0.78504 * clamp(0%, 23.3333%, 100%)))) + (0.79234 * clamp(0%, 22.5%, 100%)))) + (0.794704 * clamp(0%, 25%, 100%)))) + (0.803569 * clamp(0%, 24.1667%, 100%)))) + (0.801012 * clamp(0%, 23.3333%, 100%)))) + (0.851911 * clamp(0%, 22.5%, 100%)))) + (0.814219 * clamp(0%, 25%, 100%)))) + (0.786606 * clamp(0%, 27.5%, 100%)))) + (0.834273 * clamp(0%, 26.6667%, 100%)))) + (0.860515 * clamp(0%, 29.1667%, 100%)))) + (0.790743 * clamp(0%, 27.5%, 100%)))) + (0.797773 * clamp(0%, 25.8333%, 100%)))) + (0.808692 * clamp(0%, 25%, 100%)))) + (0.818077 * clamp(0%, 24.1667%, 100%)))) + (0.814892 * clamp(0%, 23.3333%, 100%)))) + (0.856006 * clamp(0%, 22.5%, 100%)))) + (0.822401 * clamp(0%, 25%, 100%)))) + (0.949644 * clamp(0%, 24.1667%, 100%)))) + (0.939245 * clamp(0%, 22.5%, 100%)))) + (0.930559 * clamp(0%, 21.6667%, 100%)))) + (0.88212 * clamp(0%, 20%, 100%)))) + (0.912071 * clamp(0%, 23.3333%, 100%)))) + (0.883737 * clamp(0%, 21.6667%, 100%)))) + (0.941629 * clamp(0%, 24.1667%, 100%)))) + (0.809612 * clamp(0%, 22.5%, 100%)))) + (0.873131 * clamp(0%, 21.6667%, 100%)))) + (0.908119 * clamp(0%, 24.1667%, 100%)))) + (0.961486 * clamp(0%, 23.3333%, 100%)))) + (0.903086 * clamp(0%, 21.6667%, 100%)))) + (0.891219 * clamp(0%, 20.8333%, 100%)))) + (0.890133 * clamp(0%, 20%, 100%)))) + (0.887538 * clamp(0%, 19.1667%, 100%)))) + (0.883254 * clamp(0%, 18.3333%, 100%)))) + (0.914385 * clamp(0%, 17.5%, 100%)))) + (0.860613 * clamp(0%, 20.8333%, 100%)))) + (0.896414 * clamp(0%, 20%, 100%)))) + (0.950709 * clamp(0%, 19.1667%, 100%)))) + (0.954958 * clamp(0%, 18.3333%, 100%)))) + (0.93935 * clamp(0%, 17.5%, 100%)))) + (0.95937 * clamp(0%, 16.6667%, 100%)))) + (0.954564 * clamp(0%, 15.8333%, 100%)))) + (0.919427 * clamp(0%, 15%, 100%)))) + (0.964016 * clamp(0%, 18.3333%, 100%)))) + (0.904078 * clamp(0%, 20.8333%, 100%)))) + (0.924782 * clamp(0%, 20%, 100%)))) + (0.880308 * clamp(0%, 19.1667%, 100%)))) + (0.844563 * clamp(0%, 22.5%, 100%)))) + (0.865367 * clamp(0%, 21.6667%, 100%)))) + (0.829676 * clamp(0%, 20.8333%, 100%)))) + (0.907856 * clamp(0%, 20%, 100%)))) + (0.863247 * clamp(0%, 19.1667%, 100%)))) + (0.963525 * clamp(0%, 18.3333%, 100%)))) + (0.869713 * clamp(0%, 17.5%, 100%)))) + (0.827229 * clamp(0%, 20.8333%, 100%)))) + (0.916729 * clamp(0%, 20%, 100%)))) + (0.954699 * clamp(0%, 22.5%, 100%)))) + (0.961229 * clamp(0%, 21.6667%, 100%)))) + (0.940189 * clamp(0%, 20%, 100%)))) + (0.940817 * clamp(0%, 19.1667%, 100%)))) + (0.95247 * clamp(0%, 18.3333%, 100%)))) + (0.994973 * clamp(0%, 17.5%, 100%)))) + (0.983516 * clamp(0%, 16.6667%, 100%)))) + (0.896987 * clamp(0%, 17.5%, 100%)))) + (0.956681 * clamp(0%, 16.6667%, 100%)))) + (0.871792 * clamp(0%, 17.5%, 100%)))) + (0.996643 * clamp(0%, 16.6667%, 100%)))) + (0.956953 * clamp(0%, 17.5%, 100%)))) + (0.899517 * clamp(0%, 18.3333%, 100%)))) + (0.877668 * clamp(0%, 17.5%, 100%)))) + (0.866631 * clamp(0%, 16.6667%, 100%)))) + (0.888117 * clamp(0%, 20%, 100%)))) + (0.926681 * clamp(0%, 22.5%, 100%)))) + (0.871243 * clamp(0%, 21.6667%, 100%)))) + (0.847177 * clamp(0%, 20.8333%, 100%)))) + (0.878431 * clamp(0%, 20%, 100%)))) + (0.909709 * clamp(0%, 19.1667%, 100%)))) + (0.920482 * clamp(0%, 20%, 100%)))
to=clamp(0%, 19.1667%, 100%)
I mean, we could prevent it from crashing but it'll eventually misbehave. Do you know what might be creating that animation?
Comment 5•5 months ago
|
||
From a bit of debugging it seems to be an <i> element.
Comment 6•5 months ago
|
||
Which matches that hchip__bar thing.
Comment 7•5 months ago
|
||
Ok so I this is it I guess: https://github.com/argyleink/prop-for-that/blob/554ebabd8912672a276d97d06424cf495d16d549/demos/src/styles.css#L674-L680
So if you change the value mid-transition, you increase the depth of the calc tree.
It's a bit silly / unfortunate that interpolating between:
clamp(0%, 10, 100%);
And:
clamp(0%, 20, 100%);
Ends up in p * clamp(...) - (1 - p) * clamp(...) rather than clamp(0%, n, 100%);
Comment 8•5 months ago
|
||
This doesn't happen in Chrome because they simplify down the percentage in the middle, but it should happen in WebKit as well, see https://github.com/w3c/csswg-drafts/issues/12131#issuecomment-4600367547 for a reduced test-case.
Updated•5 months ago
|
Comment 9•5 months ago
|
||
That said, the better fix for that page would be to tweak this to be something like:
inline-size: calc(var(--live-fps, 0) / 120 * 100%);
max-inline-size: 100%;
right?
| Reporter | ||
Comment 10•5 months ago
|
||
I'll send this their way.
I haven't seen it crash in Safari fwiw. I scrolled around for a few minutes.
So if you change the value mid-transition, you increase the depth of the calc tree.
Hah. One of the talks at CSSDay was doing lots of fancy stuff with calc, clamp etc etc, and it made me wonder when we (web developers) are going to have to start worrying about the runtime performance of this stuff vs JS equivalents.
As a web developer, it's not obvious to me at all that clamp + calc + interrupting animations would cause this stack to build up. If I was writing my own JS to do this, I'd be able to set break points etc to see where things were going wrong, but we don't offer developers insight into this stuff in CSS.
Just brain-dumping right now, but it feels like we either need to ensure this stuff doesn't happen in CSS, or provide tooling that helps developers fix it when it does happen.
Comment 11•5 months ago
|
||
Yeah an extra factor here is that our style threads have a smaller stacks than e.g. the main thread.
Comment 12•1 month ago
|
||
(In reply to Jake Archibald [:jakea] from comment #0)
Created attachment 9597230 [details]
Stack tracehttps://deploy-preview-3--prop-for-that.netlify.app/
Open the page above. Scroll around a bit. The tab will crash.
I think it's something to do with calc() ending up nested internally. The stack has a lot of
0x0000000314fc92d4 XUL`style::values::generics::calc::GenericCalcNode$LT$L$GT$::resolve_internal::haab154f8676dae4c(self=0x0000000105facb40, leaf_to_output_fn=0x000000016bc50b07) at calc.rs:960:39
Observations from my end (macOS 27):
Firefox does not even start to render the animation following the mouse pointer in the background, and crashing can indeed happen rather fast moving the cursor around on that.
It does work fine in Chrome, no crash, 385 MB RAM use for me, very smooth.
Description
•