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

editor freezes on rendering words as spans #1979

Open
devcer opened this issue Jan 11, 2023 · 5 comments
Open

editor freezes on rendering words as spans #1979

devcer opened this issue Jan 11, 2023 · 5 comments
Labels
type: bug 🪲 Something isn't working

Comments

@devcer
Copy link
Contributor

devcer commented Jan 11, 2023

Summary

I'm building an editor where each word will be rendered as span with additional attributes attached to each span. However, the editor freezes for bigger content. If I start using EntityReferenceExtension, it starts to freeze even more often.

Steps to reproduce

Expected results

You should be able to edit the content and even draw annotations.

Actual results

The page freezes on load and unable to edit anything.

Possible Solution

Not sure what is blocking the render to freeze. spent enough time debugging it and found some mouse event is blocking the render if I check the performance tab.

Screenshot(s)

Screen.Recording.2023-01-11.at.17.37.36.mov

In this video, I'm trying to click on the editor to make changes but I couldn't

Please add a sponsored label to this issue as we are sponsors.

@devcer devcer added the type: bug 🪲 Something isn't working label Jan 11, 2023
@cashwanikumar
Copy link

To add more content, I have attached a profiler screenshot where the Remmiror portal changes every time I type (ref: rect_profile.png)

react_profile

and in chrome dev performance, there is a keypress event which takes a good amount of time when typing (ref: chrome_perfomace.png)

chrome_perfomace

@cashwanikumar
Copy link

little explanation

edit_freeze.webm

@IdrissMahjoubi
Copy link
Contributor

@cashwanikumar Each mouse click/ key press triggers an update in the editor. This update usually go through all extensions. Try excluding extensions and retesting to detect which one is causing the most performance issues.
Granted EntityReferenceExtension is know to cause some performance issues since it recalculates all references on each update (going through all the document tree), which is not ideal. Which also mean the more content you have the longer calculations take.I might looks into that this week to make performance improvement, but this is unlikely to solve all your issues.

@cashwanikumar
Copy link

@IdrissMahjoubi Fully agree!! and thanks for the quick reply.
I will test by removing EntityReferenceExtension and check again and let you know my finding. Also will debug more and will try to find places where performance hit is happening.

Also, do you think if we wrap using react memo here will cause any issue? this I believe surely can stop the remirrorPortal component to update unnecessarily

@IdrissMahjoubi
Copy link
Contributor

Also, do you think if we wrap using react memo here will cause any issue? this I believe surely can stop the remirrorPortal component to update unnecessarily

@cashwanikumar You can try this, but the main issue is still assigning a Mark to each word. This augments the size of the document exponentially, thus making making calculations heavier (cursor position, typing, drawing to view ...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🪲 Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants