Slate: Pasting very huge document freezes the editor, taking more than 10 minutes to finally paste

Created on 11 Apr 2018  Â·  15Comments  Â·  Source: ianstormtaylor/slate

Do you want to request a _feature_ or report a _bug_?

Bug

What's the current behavior?

Pasting a very huge document like the one contained in this file https://www.dropbox.com/s/wpefhhwrivvajvc/huge.text?dl=0 on slatejs.org demo app freezes the app. I didn't see the need to make a jsfiddle example as it's happening on slate demo

What's the expected behavior?

It appears within seconds like it does on facebook.com, draft.js, http://prosemirror.net/, https://quilljs.com/

âš‘ perf

Most helpful comment

this is no longer an issue in newer versions

All 15 comments

Was this using the paste html example?

I tried it on richtext and huge document examples(clearing existing contents first).

Note, I pasted the content of the linked file https://www.dropbox.com/s/wpefhhwrivvajvc/huge.text?dl=0, not the dropbox page

Those examples don't have paste handlers implemented, so maybe check what happens with the Paste HTML example because that's specifically implemented to showcase the paste handling and how that works.

It might have the same performance problems, but it also might not.

Just tried pasting on Paste HTML example; same result

The paste handler in the example is for html deserialisation, the content I'm pasting is plain text

I do not find a easy way to solve the problem. It seems we have to async the serializer to solve the problem.

Woah yeah that document destroys my editor. It's been several minutes now since the cursor even blinked. I eventually had to restart, as I have no idea how much longer that might have gone on for. I waited at least 4 minutes. I'm doing more processing than the examples, but oof!

I have a hypothesis. The slate creates a list of characters when creating texts. If we change the structure of text, use leaf rather than characters as the base of text. It would solve the problem.

However, I would begin on performance issue when and only when my finishing https://github.com/ianstormtaylor/slate/pull/1765

The bottle neck is node.mapDescendants, not serializer. See: https://github.com/ianstormtaylor/slate/pull/1783

@benjycui Do you mean the paste problem is fixed after that PR?

@zhujinxuan yes. @chitezh you can try this PR with your test data.

Thanks, will do

Great improvement!

However, it did freeze the editor for an average of 38s which is a significant improvement from the 2m11s on slate.org.
Also, it still did show the unresponsive page warning just before it pasted around 37s

image

@chitezh you need NODE_ENV=production to use production version when you test it locally.

@benjycui I wasn't able to run the example in prod mode, I did try prefixing server and watch scripts with cross-env NODE_ENV=production but it didn't load on the browser.

I would appreciate some help here

this is no longer an issue in newer versions

Was this page helpful?
0 / 5 - 0 ratings