question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Large line widgets slow down the editor due to forced reflows

See original GitHub issue

Here’s a sandbox showing the issue: https://codepen.io/anon/pen/zQGJMM

If I create a line widget with a large number of DOM nodes, then the CodeMirror instance quickly becomes laggy due to forced reflows. This seems to be because of how CodeMirror measures the line height in functions like updateHeightsInViewport, where it calculates display.lineDiv.offsetTop (the line widget is inside the lineDiv).

In the sandbox I cranked it up to 100k nodes inside the LineWidget to make the problem really noticeable (each edit takes almost 1 second on my computer) but the problem is still noticeable for smaller numbers of DOM nodes.

Is there anything I can do about this? My main use-case is to have a max-height on the LineWidget, so intuitively the height should always be fixed at the maximum when there are large numbers of nodes, so it seems like this should be possible to make fast. Any help would be greatly appreciated.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
SteveSonoacommented, Jul 10, 2019

I recognize that this issue is marked as closed by the author, but I am also experiencing the same issues with the same symptoms (severe slowdown due to the offsetTop calculation). I’m using CodeMirror to display an API result, and 2 identified use cases return around 90,000 lines. With that calculation only taking a millisecond or two per line, at 90,000 lines, it slows the page to an apparent halt.

Screen Shot 2019-07-09 at 1 05 24 PM Screen Shot 2019-07-09 at 1 05 43 PM

I will certainly begin testing with the CSS contain you mentioned earlier, but will this component be updated to address the issue natively? Thanks for your time.

0reactions
thomasjmcommented, May 8, 2019

Got it, thanks – I guess it’s time for virtual DOM tricks. Closing this now…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Large line widgets slow down the editor due to forced reflows
If I create a line widget with a large number of DOM nodes, then the CodeMirror instance quickly becomes laggy due to forced...
Read more >
What is a Forced Reflow and How to Solve it? - Yonatan Kra
Force reflow (or Layout Reflow) is a major performance bottleneck. It happens when a measurement of the DOM happens after a DOM mutation....
Read more >
Minimizing browser reflow | PageSpeed Insights
Here are some easy guidelines to help you minimize reflow in your web pages: Reduce unnecessary DOM depth. Changes at one level in...
Read more >
gNu - River Thames Conditions - Environment Agency - GOV.UK
Philishave tracer shaver, Criminoso menor de 21 anos, Nutley high school nj athletics, 15152 friar st, Project ciampa, Bromford lane incident, Comlurb 1746, ......
Read more >
Branding for Mobile Speed – Everyone hates a slow website!
We've encountered them on client sites and know they slow everything down. ... WordPress uses ImageMagick, an open-source command-line graphics editor, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found