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 lags badly when note contains many triple backtick blocks #7867
Comments
@nickrbogdanov can you comment the version of Joplin that you are using? |
I just reproduced the problem on Linux using the test case above. That version is: It's from the Ubuntu snap, which looks to be a few months old: https://snapcraft.io/joplin-desktop I also see it on macOS:
If I navigate to Joplin -> Check for updates..., it tells me I'm on the latest release. |
I have 5 code blocks of 2367 lines of each but editor is working file, I agree that scrolling becomes a bit slow but it is understandable. I also tried it with 50 code blocks containing ~130 lines each. here is the jopling version details that am using
|
Could you please try pasting my test case into a new note: https://gist.githubusercontent.com/nickrbogdanov/2da682ea0620dfbd137df8927d5834b7/raw/76f913b04fe0b31a26c27a90958a8bc064627e83/gistfile1.txt |
Okay, just tried and found editing text becomes lazy, but it is also understandable. And on the other hand, It would be a rare case where a note will contain 1000 code blocks. That's because it will also be harder to navigate across such a large note. |
Two things:
|
Thanks @nickrbogdanov, that's good to know it's related to syntax autodetection, it might mean we can fix it by caching something |
Well about 4 years ago I've implemented an optimisation to fix that exact problem, but somehow it disappeared over the years after multiple refactorings. I've enabled it again and it seems to work as expected (went from taking 2000ms to render on my machine to 20ms) |
Hi, any chance this could be merged into the next 2.10.x release? Looks like it is in the dev branch but not the release-2.10 branch. |
No sorry, I would prefer if it goes through a prerelease in case there's any bug we didn't expect |
I have a note that's about 1500 lines long, which has 50+ "```" preformatted blocks containing code, log snippets, and other miscellaneous data. I noticed that as this note grew, editing performance got worse and worse. For instance, just typing a few characters on a fresh line, then highlighting them and deleting them, took 8+ seconds. This is a problem on macOS and on Linux.
I opened up Help -> Toggle development tools, started Profiling, and reproduced the problem. It pointed to compileLanguage() in highlight.js as the culprit. Apparently, letting highlight.js autodetect the syntax highlighting scheme requires compiling or evaluating a massive number of regular expressions.
A simple repro case is to paste 1000 instances of a simple preformatted text block into a note, and then try adding/deleting text from the note:
As a workaround: when I disable syntax highlighting on each block, the performance issue goes away:
This may be similar to #1649
The text was updated successfully, but these errors were encountered: