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

Slow rendering of KaTeX on W10 #2357

Closed
ArjenB96 opened this issue Jan 24, 2020 · 20 comments
Closed

Slow rendering of KaTeX on W10 #2357

ArjenB96 opened this issue Jan 24, 2020 · 20 comments
Labels
bug It's a bug high High priority issues renderer About the note renderer

Comments

@ArjenB96
Copy link

ArjenB96 commented Jan 24, 2020

When working on my note (linked below) I notice a signifcant increase in render time when I increase the amount of KaTeX, even though I do not find it to be that much. Even after typing single letters and pausing slightly, the editor freezes for ~0.5-1 seconds to render the entire file and this disturbs my work flow.

I do not experience the issue as much on my laptop running macOS Mojave. Hiding the rendered version using the Layout button does not help the issue.

Environment

Joplin version: 1.0.178 (prod, win32)
Platform: Windows
OS specifics: 10, standard editor settings with 'Nord' them enabled.

Steps To Reproduce

slow_render.zip

  1. Open linked file in Joplin
  2. Make any (small) changes.
  3. Experience significant render time.

Describe what you expected to happen:
Much less render time, allowing for a more smooth work flow.

@ArjenB96 ArjenB96 added the bug It's a bug label Jan 24, 2020
@laurent22 laurent22 added renderer About the note renderer high High priority issues labels Jan 24, 2020
@ArjenB96
Copy link
Author

ArjenB96 commented Jan 24, 2020

Log does not show anything interesting.
Furthermore, It seems that restarting the application seems to bring the render time back to acceptable levels. Not sure why?
I'll try to monitor resource usage when working on my notes.

@ArjenB96
Copy link
Author

ArjenB96 commented Jan 24, 2020

On start-up, Joplin uses about 175-200 MB of RAM. After working for 45-60 minutes on a single note file, it rises to 500 MB. It is at this point that the renderer becomes a bit choppy.
Even though my RAM usage is at 30% and I have 16GB of RAM available, the renderer still lags at that point.

@laurent22
Copy link
Owner

Katex code blocks are cached, so maybe the cache is malfunctioning and adding data without deleting old one.

@ArjenB96
Copy link
Author

There are quite some instances where I use inline code blocks. Especially in the part I wrote the last hour a significant amount of inline code blocks were written, but not a lot of text.

@ulucs
Copy link

ulucs commented Jan 24, 2020

I have been having the same issue and resorted to reinstalling the previous version as a workaround.

@laurent22
Copy link
Owner

I'm not seeing any slow down actually. Can someone post one example Markdown that definitely shows the problem?

@lbo34
Copy link

lbo34 commented Jan 25, 2020

Hi. I am also on 1.0.178 (the app update pops for 1.0.179 but does not download it), but on OS X.
I am experiencing the same problem. The math equations are re-written every time I type something (even if it is not an equation). This happens on several documents, but I believe I did not experience this behaviour before... I am dropping an example...
Notes de Cours Machine Learning II_ Deep Learning.md.zip

@ArjenB96
Copy link
Author

ArjenB96 commented Jan 25, 2020

I can confirm Ibo34's issue.
Currently trying this on OSX 10.14.5 with version 1.0.178 and I have the same issue.
Here is a screen capture of the issue.
Holding the 'a' button is normal speed when rendering isn't triggered.
Tapping 'a' is me trying to trigger rendering.
When it renders, I continue to hold 'a' so the delay can be seen.

It happens even when I only update the file with mostly text, as opposed to heavy KaTeX usage.
Not to point fingers or anything, but maybe it is KaTeX caching stuff every time it renders, but not deleting the cache? Maybe the problem depends on the amount of renders being done in a session, so the files that we upload won't initially have the problem.

@lbo34
Copy link

lbo34 commented Jan 25, 2020

I also notice some latex commands stopped working... Like \mathbb{} and some others. Used o work very well.

@lbo34
Copy link

lbo34 commented Jan 25, 2020

--updated: manage to reinstall with Homebrew. Now on 1.0.179... but the KaTeX flickering problem and changes to some functions (for instance \mathbb \reals) is also in 1.0.179.

This is bad... I tried to downgrade to 1.0.177 and I am not sure what went wrong but I cannot open the app anymore. It says it is opened but the main windows does not appear. I can access the menu but nothing happens. Only "about Joplin" seems to work and opens a window on the bottom left of the screen... I tried to reinstall 1.0.177, 1.0.178... Nothing seems to work.

@laurent22
Copy link
Owner

@lbo34

for instance \mathbb \reals

As this is a different issue, could you open a new issue with a complete markdown example, and what rendering you expect?

@lbo34
Copy link

lbo34 commented Jan 26, 2020

Sure... it is just these two things seems to have appeared at the same time. I'll open a new issue.

@ulucs
Copy link

ulucs commented Jan 27, 2020

Did you have any success reproducing the issue?

I also found a new workaround: disabling and then reenabling KaTeX seems to work for a while

@laurent22
Copy link
Owner

@ulucs, this workaround is to fix what issue?

@ArjenB96
Copy link
Author

ArjenB96 commented Jan 27, 2020

@laurent22 The lag.
If I switch continuously between two medium-sized notes with KaTeX in both of them, I notice the lag showing up after a while. I have not timed it, but it might be somewhere in the range of 10-20 minutes.

@ulucs
Copy link

ulucs commented Jan 27, 2020

Yeah, it is about the lag. I also noticed the issue is also present in version 1.0.177

@laurent22
Copy link
Owner

@ArjenB96, if you could post an example of note that shows this memory leak it might help. The more sample notes we have the better.

@ArjenB96
Copy link
Author

lag_files.zip

I hope I did it right, I tried to export two notes in .jex file.
The result after 10 minutes of switching notes (while writing the summary file listed) is very significant. The resulting lag carries on when trying to edit any note.

@lbo34
Copy link

lbo34 commented Jan 28, 2020

true @ulucs. it seems to help a bit.

@laurent22
Copy link
Owner

laurent22 commented Feb 8, 2020

I couldn't quite replicate any slow down or memory leak on my side (it stays at 90MB on Windows and loads fast), however I've optimised how the Katex assets and other plugin assets (CSS and fonts) are loaded and I think it should make it faster and consume less RAM.

Another thing that was changed in a recent release is that rendering is now asynchronous but I hope it's not the issue as that will be much harder to fix.

This change will be in the next release.

@lock lock bot locked and limited conversation to collaborators Feb 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug It's a bug high High priority issues renderer About the note renderer
Projects
None yet
Development

No branches or pull requests

4 participants