CodeMirror (v3 from github source) freezes (and sometimes crashes IE) on very long lines.
I use codemirror to format and highlight code. Sometimes, all this code is on one line.
When that happens, CodeMirror freezes for up to 10 seconds (on my i7/ssd/16gb ram gig) and sometimes crashes IE.
I debugged it into 'measureLineInner' (line 864). where it tries to loop trough every character of that line (in my case a +2500 char line).
Can this logic be optimized?
edit: IE 10 btw.
edit2: IE9 too
for now, I 'fixed' it by adding lineWrapping = true to the options. But this is not really what I want.
I can reproduce this -- but only in IE. It appears that calling getBoundingClientRect (or accessing offsetTop/offsetLeft) causes a recomputation of the layout (or some other ridiculously expensive operation) every single time it is called. This amounts to about 1.6 milliseconds per character, which does really add up on long lines. Turning on text wrapping does indeed miraculously speed it up, but only by a factor four or so, so the problem is still noticeable.
This doesn't seem to happen for all nodes. If I use a node in a simple document, IE seems to properly cache the result and the whole thing speeds up by a factor 1000. So now the question is what it is about the CodeMirror DOM nodes that breaks caching.
Help IE cache layout information in measureLineInner
Please try with the attached patch. The situation still isn't great -- typing will be noticeably laggy on long lines -- but a lot better than the original situation where it would simply lock up.
This is the best I've been able to squeeze out of IEs crummy rendering engine for now. Ideas for further techniques to improve this are welcome.
Verified, that works (a bit better :-))
Disable line measuring subdivision hack (#990) on IE7
It completely screws up bounding rects when this is enabled.