I have a project where there are lots of editors on the page and updating higher than 0.27.x makes it just impossible to use some features of the project at all, because everything becomes slowed down too much.
I am not sure, but probably it could be the case of the new normalization or the old shema versus renderNode/renderMark functions, because that are the differences in my code for these versions.
I did face similar issue. The performance regression is pretty noticeable for me as well.
One of the issue I identified is described in https://github.com/ianstormtaylor/slate/issues/1318#issuecomment-341956697
First, the <Editor /> will always trigger onChange() when component load because Value's Schema does not match <Editor />'s Schema.
Second, the onChange() is triggered by a timer, which if you end up having large number of editors, it just cause a huge hang on start up. I think using timer to send component related events is really bad idea because by the time the timer is invoked, the component might no longer be in that state.
I do hope we can work around this issue, Slate used to be really performant for such use case, I hope it doesn't lose that capability.
I going copy my comment from https://github.com/ianstormtaylor/slate/issues/1318#issuecomment-341956697 to here as the ticket is already closed.
I'm facing a new issue though, as we are using
setTimeout()for the new behaviour, on browser like Safari that does not aggressively process those timeout in a timely manner, you can see that timeout build up as well. So if I duplicate the number of editors by 10x in the jsfiddle running inside Safari, the console will slowly print out the debug statement one after another.I understand I am using Slate very differently from the normal path, but this is a regression for me, before the change, older version was very capable on rendering hundreds of
<Editor />components.Analysing the situation, I identify the following issues:
- flushing of changes only happen in
componentDidMount()andcomponentDidUpdate(), although you have specifically documented the rationale for having change queue, it doesn't seems like a bad idea to trigger theonChange()event immediately during these component life cycle.setTimeout()might not be immediate.- Value's schema must be exact reference to Editor's schema (identity), even if their value is the same, if not,
onChange()event is fired.- There's no way we can pass in a schema from the outside (update Value's schema) so as to suppress the
onChange()situation.I'm still digging the code to see if I can workaround the issue. I haven't gotten up to speed with the latest changes, will keep you updated!
References
@lxcid, your issue is closed, so have you managed to fix it? I have tried the newest version of package today in the morning before writing mine and it was still present.
I append the shrinked and cut code sample of my wysiwyg component to show what i have: https://pastebin.com/sAkSfKu8
It was still usable for me. @HydraOrc, will u be able to create a jsfiddle to showcase your issue?
https://jsfiddle.net/2zokvrvt/192/
U might have to change the state to value in the JSFiddle though.
@lxcid,
With the newest version: https://jsfiddle.net/HydraOrc/4hutkdxb/
With the old good-working version: https://jsfiddle.net/HydraOrc/6v1nhztr/
I see that this case is not so slow to showcase my issue, but in the real project the code with the newest version causes the significant performance decrease
Nice @HydraOrc, I do want to be able to help improve this aspect of the codebase. I'll do some investigation on top of what I suspecting at the moment when I have some time this week! I'll keep this thread updated.
+1. I have a similar use case with multiple editors that would prevent me from updating past 0.27.x. Let me know if I can help.
We have a huge word document, about 700 pages, we transfer to slate document, but we can't open this document whit slate 0.31.3
A lot of the logic has changed since 0.27, so I'm going to close this. Feel free to open new issues with specific performance bottlenecks!
Most helpful comment
I did face similar issue. The performance regression is pretty noticeable for me as well.
One of the issue I identified is described in https://github.com/ianstormtaylor/slate/issues/1318#issuecomment-341956697
First, the
<Editor />will always triggeronChange()when component load becauseValue'sSchemadoes not match<Editor />'sSchema.Second, the
onChange()is triggered by a timer, which if you end up having large number of editors, it just cause a huge hang on start up. I think using timer to send component related events is really bad idea because by the time the timer is invoked, the component might no longer be in that state.I do hope we can work around this issue, Slate used to be really performant for such use case, I hope it doesn't lose that capability.