5 ms·
TL;DR: It seems to be a problem in Chromium, the relevant CSS (one second change) results in a 60hz animation cycle. Workaround: "editor.cursorBlinking": "s
by okket 10y ago
TL;DR: It seems to be a problem in Chromium, the relevant CSS (one second change) results in a 60hz animation cycle.
Workaround:
"editor.cursorBlinking": "solid"
- johnhattan 10y agoYou think this is gonna be fixed in Chromium, fixed in VSCode, or working-as-designed?
- okket 10y agoIssues/bugs are filed, see https://github.com/Microsoft/vscode/issues/22900#issuecomment-288529120 https://github.com/Microsoft/vscode/issues/22900#issuecommen...
- revelation 10y agoOkay, but checking at 60 hz if an animation needs to be updated is not relevant work. In no universe should that cause 13% processor load. Sure maybe you can get smarter and realize that all animations run at 2 hz and then also only check at 2 hz, but it seems the root problem here is an entirely different one.
- ygra 10y agoInteresting, considering that CSS animations were supposed to be much better than JS animations in that regard. I guess a simple setInterval would actually perform better here.
- ralfn 10y agoCSS animations and raw JS animations perform equally well. JS had a bad reputation for animation only because the common libraries back then (jquery, mootools) had absolute horrible incompetent implementations. This also has nothing to do with the blinking interval. A setInterval would simply not do the same. The CSS animation is fading its opacity at 60 fps not toggling it. Doing the same with a setInterval(.., 1000/60) will use the same amount of CPU. As any introductory tutorial about css animations explains: They interpolate between the percentages you are not providing! So thats a DOM update every 12ms. The reason its smooth is because opacity (like transform) does not trigger a relayout. Finally, whatever is triggering relayouts is not the opacity change, but some other obviously badly written code that is continously triggered on requestAnimationFrame and is touching the DOM even though, zero dom writes should be taking place on idle. (And zero dom reads always! Since reading from the DOM triggers synchronisation between the rendering thread and the js thread)
- mastax 10y ago> The CSS animation is fading its opacity at 60 fps not toggling it. Most of the cursor styles have some sort of animation, but the "blink" style is just an on-off blink with no fade. Chrome updates every animation at 60hz, even step animations like these. This is an acknowledged issue in the Chrome bug tracker as linked in the issue.
- artursapek 10y agoI recently discovered the same issue in a webapp I develop... a simple CSS animation for a "loading" spinner was pegging the CPU. Using steps(n) with a low number basically resolves the issue. https://css-tricks.com/snippets/css/keyframe-animation-syntax/#article-header-id-6 https://css-tricks.com/snippets/css/keyframe-animation-synta... Kind of ridiculous that it's so easy to make this mistake.
- gigatexal 10y agoWith great power (flexibility of JavaScript) comes great responsibility.