moacirrf / netbeans-markdown

This plugin adds some additional features to Apache Netbeans Markdown Editor. Preview, Split Window, Suggestion, Export to DOCX, PDF and HTML
https://github.com/moacirrf/netbeans-markdown
GNU General Public License v3.0
16 stars 1 forks source link

Open a markdown file takes to long and blocks IDE #13

Open Chris2011 opened 2 years ago

Chris2011 commented 2 years ago

When I open a markdown file for the first time, which is not that big ~240 lines, first it takes couple of seconds to open it and it blocks the whole IDE. After first opening and open it again, I think it is cached somehow and it opens faster.

So this is just a problem for the first opening which doesn't take to long in other IDEs.

So here are my proposals:

IMHO the first 2 points are a must have, the others are nice to haves.

moacirrf commented 2 years ago

I will work on it. Thank you.

moacirrf commented 2 years ago

Hi i made some performance improvements

Performance Improvements

A link of a nbm for tests if you wants to test

https://github.com/moacirrf/netbeans-markdown/releases/tag/0.0.5_alfa

What you think about?

Thanks

https://user-images.githubusercontent.com/950706/193418138-314a063c-b5d8-4d9c-9ebe-62f03992ba72.mp4

moacirrf commented 2 years ago

Maybe is interesting download all images first an make a local cache, what you think?

Chris2011 commented 2 years ago

Hey, unfortunately your download link is not working, i shows a 404. Just make an relase or alpha release or so or draft to let the others know that it is still in progress or so.

What is exact the performance issue? Rendering the images?

moacirrf commented 2 years ago

Sorry, i made other release, now is public, https://github.com/moacirrf/netbeans-markdown/releases/tag/0.0.5_alfa

What is exact the performance issue? Rendering the images?

  • Svg images needs to be converted to png, now they are converted only one time, and they are reused.
  • Content of MD file is loaded with a SwingWorker
  • Included a progress bar on preview window
Chris2011 commented 2 years ago

Thx, I tested it and here are some infos:

Can you just tell me what flexmark is doing here? What kind of output is it? I can still select the output stuff. Is the output somehow SVG or some other formatted output? I just wanted to know the performance problems here, not the performance enhancements.

Btw, thank you very much for your great work.

moacirrf commented 2 years ago

Sorry to hear that the enhancements don't resolve your issues.

Can you just tell me what flexmark is doing here? What kind of output is it? I can still select the output stuff. Is the output somehow SVG or some other formatted output?

  1. Flexmark parses the MD format and generate html.

  2. I use JEditorPane with a custom HtmlEditorKit to show this html on preview window.

  3. JEditorPane has some problems:

    • it don't show svg images, we must convert svg to png using Apache Batik
    • Has a partial support to Html 3.2 and old css version, so we need use Jsoup to do some changes on this html before send to JEditorPane.
  4. Another possible problem, can be network problems, remote images must be downloaded first, so a slow server or a server with some kind of restriction can avoid or slowdown download images.

Thanks

Chris2011 commented 2 years ago

Sorry to hear that the enhancements don't resolve your issues.

Thx, but I think it is better as before. Not complete optimal but a bit better.

Thank you very much for the insights :). Here is my readme and it is not about having images at all: https://github.com/Chris2011/nixos-docker-image-builder/blob/master/README.md

So in general the performance stuff is not only about images. Maybe we need more research. I guess, that flexmark is fast enough to do the generation (?). So maybe it is the HTMLEditorKit which seems slowish? Just guessing. But I know that there are some old stuff which was never touched again for years. So maybe there is still an alternative for the HtmlEditorKit and/or what about to just display an html file with HTML4j? Maybe this could be an alternative.

Chris2011 commented 2 years ago
  1. Another possible problem, can be network problems, remote images must be downloaded first, so a slow server or a server with some kind of restriction can avoid or slowdown download images.

This is just the point if we have URLs which points to remote images but most of the time, the bigger ones like screenshots are in a local folder. In my case.