activate-power-mode
activate-power-mode copied to clipboard
get{BoundingClientRect,ComputedStyle} each keypress not ideal for performance
As I understand it, HTMLElement#getBoundingClientRect
(hereby gbcr) and getComputedStyle
(hereby gcs) is run each time particles need to be generated. This is problematic since on my machine at least, it is quite easy to produce lag when typing quite a lot on default settings.
According to what forces layout, gbcr will always cause a layout, and gcs will do the same if it is in a shadow root (IIRC Atom uses Shadow DOM for the editor component).
Calling gbcr and gcs each keypress should be avoided where possible. With using gcs for getting the text colour, I think settling for white/grey (to look like dust or cement crumbling) would be adequate.
With gbcr, unfortunately the alternatives that are calculating positions through offsetWidth
, ..., and parentNode.scrollTop
, ... all trigger layout as well, however according to this benchmark it is still faster.
Could alternative solutions like these be considered?
yup, got the same problem. (I don't have a bad computer though (Intel Core i5-4570 (3.2 GHz) - Gainward GTX 970 - 8GO) Would it be possible to fix this? (EDIT: Actually, I don't know if that's exactly my problem, but at least It's a performance issue: when screen shaking is enabled, even on 1, it's very laggy)
with the latest release the issue persists?
Persists
Hi, a little update on this
-
getBoundingClientRect
is not used on each keystroke, I think is not used anymore. Instead usingoffset*
only when changing text editor. And for particles positionscroll*
functions. -
getComputedStyle
can't be removed because is needed to get text color. If want a bit of performance, use fixed or random color on the package settings.