Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Very slow with large text #42

Closed
ropel opened this issue Apr 9, 2019 · 14 comments · Fixed by #46
Closed

Very slow with large text #42

ropel opened this issue Apr 9, 2019 · 14 comments · Fixed by #46
Assignees
Labels
Milestone

Comments

@ropel
Copy link

ropel commented Apr 9, 2019

I've tried embedding ClassicEditor in a clean vue project: everything is OK, but when I paste a long flat text (not formatted, just 800 lines long text) the editor became veeery slow (several seconds just to type a character and see it on screen). The same text pasted in your online (not vue) examples works without problems. After deleting all the text, editing is again responsive.
Removing "v-model" tag (thinking about a slowdown keeping the model in sync) didn't help
Tried with latest Chrome on Windows and Linux
My page is as simple as that:

<template>
    <ckeditor :editor="editor" v-model="editorData" :config="editorConfig"></ckeditor>
</template>
<script>
import ClassicEditor from '@ckeditor/ckeditor5-build-classic';
export default {
  name: "editortest",
  components: {},
  data: function() {
    return {
      editor: ClassicEditor,
      editorData: "<p>Rich-text editor content.</p>",
      editorConfig: {
        // The configuration of the rich-text editor.
      }
    };
  },
  methods: {}
};
</script>

<style>
</style>
@ropel ropel changed the title Very slow with big text Very slow with large text Apr 9, 2019
@Mgsy
Copy link
Member

Mgsy commented Apr 10, 2019

I can confirm it. I've just loaded 800 paragraphs as initial editor content and the editor became incredibly slow. It doesn't happen in CKEditor 5 without Vue integration.

@oleq, could you take a look at this one?

@oleq
Copy link
Member

oleq commented Apr 11, 2019

I confirm the issue. The culprit is this listener

editor.model.document.on( 'change:data', evt => {
const data = editor.getData();
// The compatibility with the v-model and general Vue.js concept of input–like components.
this.$emit( 'input', data, evt, editor );
} );
. When there's a lot of data, it takes a lot of time to emit the event. It's getData that makes it slow. We should probably debounce it.

image

@oleq oleq added this to the iteration 24 milestone Apr 11, 2019
@oleq oleq added the type:bug label Apr 11, 2019
@Reinmar
Copy link
Member

Reinmar commented Apr 11, 2019

Dunno how it works in Vue, so sorry for a potentially stupid question – can the content be retrieved only on demand? Or does Vue implement a sort of two-way-binding so it can't?

BTW, I'd consider something like:

this.$emit( 'input', () => editor.getData(), evt, editor ); 

So, instead of passing data directly in the input event, we'd allow someone to retrieve it if needed. Although, if the consumer would actually read it on every input that would change nothing.

Sorry again if I'm missing the point :D For two-way data binding debouncing seems reasonable.

@oleq
Copy link
Member

oleq commented Apr 17, 2019

@Reinmar I'm afraid it is impossible. 2-way data binding depends on actual data and there's no way to do things on demand. However, in the PR I managed to reduce the number of setData() and getData() calls with some caching, which significantly improved the performance.

In the second step, I'm gonna investigate a possibility of debouncing. Stay tuned.

@oleq
Copy link
Member

oleq commented Apr 18, 2019

I updated the PR with a debounced #input event. Any feedback appreciated.

@pomek pomek closed this as completed in #46 Apr 19, 2019
pomek added a commit that referenced this issue Apr 19, 2019
Fix: Improved performance when editing large content. Debounced the component `#input` event. Closes #42.
@AndrewMast
Copy link

It would be nice to know if the editor is currently being "debounced" so a form submission can be delayed. Maybe setting a variable "typing" to true? Or at least setting a "maxWait"...

@Reinmar
Copy link
Member

Reinmar commented May 20, 2019

Something like – isBusy? :D If it solves some issues, then it sounds fine to me.

@Reinmar
Copy link
Member

Reinmar commented May 20, 2019

BTW, perhaps we could use the PendingActions plugin? It's mentioned in https://ckeditor.com/docs/ckeditor5/latest/builds/guides/integration/saving-data.html#autosave-feature and could help here too.

@awmartin
Copy link

I just encountered this issue today in Vue.js. I get a half- to full-second delay while typing, making for a frustrating staccato, stop-and-go experience. Is there a mitigation for this, perhaps not using CKEditor as a Vue component and just loading it as a pure native build?

@Reinmar
Copy link
Member

Reinmar commented May 7, 2020

@awmartin could you open a new ticket (and cc me there)? I suppose that there must be an option to disable the two-way data binding or a smarter debounce mechanism (e.g. similar to the one used by autosave).

Also, a related ticket in CKEditor 5 itself: ckeditor/ckeditor5#5812.

@szohaib
Copy link

szohaib commented Jan 18, 2021

Can anyone share some update on this please?

@danefondo
Copy link

danefondo commented Feb 3, 2021

What about @ready="onReady" --> onReady(editor) { const data = editor.getData() } and skip the v-model? Possibly tying it to various events through editor.editing.view.document.on("event", (evt, data) => {})

@awmartin
Copy link

awmartin commented Feb 4, 2021

I forgot to open another ticket. :-(

For context, I use a doc with about 6000 words and a lot of paragraphs and list items to test. The delay is typically 600-700ms when it appears. I think the performance of getData is largely correlated to the number of top-level elements.

To bypass the v-model pattern and remove the hesitation, I had to remove the change:data event here and remove the modelValue watcher. The performance returned, and I just handled saving documents manually. You don't get any Vue.js data binding though.

The other approach I tried was just increasing the debounce interval to 3000ms. It seemed to be okay except for a couple of hiccups, which I couldn't quite track down.

@rolexta
Copy link

rolexta commented Apr 27, 2022

still very slow on document editor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants