Open Blquinn opened 2 years ago
I suspect this is one of the causes
I have the same problem. My app is for writing large docs. If i paste a text with 40000 characters or more, the editor starts to degrade for doing any operations (insert, or delete, or paste more text). Is there any way to fix it
The performance of the editor begins to degrade when the document size gets reasonably large, especially when performing edits.
I ran some profiles with 500 paragraphs of text loaded. (from https://loremipsum.io/generator/?n=500&t=p)
It seems like the main issue is that the entire widget is re-drawn and re-laid-out on every edit. Meaning, every line of text is re-drawn on every frame, regardless of if it changed, or not. I think this should be avoidable. I also profiled https://github.com/superlistapp/super_editor and there was no jank when editing large documents, perhaps insight can be gained from there.
A couple of smaller issues:
Rasterization is slow on every frame, this seems to be due to the cursor blinking, but it only happens on larger documents, so I assume it's redrawing the whole document when the cursor blinks, or something like that.
Also, in RawEditorStateTextInputClientMixin calling "Document.toPlainText()" and diffing that against the editor text seems to be very slow for large documents.