zsviczian / obsidian-excalidraw-plugin

A plugin to edit and view Excalidraw drawings in Obsidian
4.15k stars 229 forks source link

BUG: PDF Export of Markdown of Hybrid Note takes so long #1932

Open KrazyManJ opened 2 months ago

KrazyManJ commented 2 months ago

Your environment

SYSTEM INFO:
    Obsidian version: v1.6.7
    Installer version: v1.6.5
    Operating system: Windows 11 Home 10.0.22631
    Login status: logged in
    Catalyst license: none
    Insider build toggle: off
    Live preview: off
    Base theme: light
    Community theme: none
    Snippets enabled: 21
    Restricted mode: off
    Plugins installed: 66
    Plugins enabled: 60
        1: QR Code Generator v1.2.1
        2: Discord Rich Presence v1.5.1
        3: Charts View v1.2.7
        4: Table Extended v1.6.1
        5: Paste URL into selection v1.7.0
        6: Language Translator v1.0.4
        7: Settings Search v1.3.10
        8: Convert url to preview (iframe) v0.5.0
        9: Hotkey Helper v0.3.18
        10: Embed Code File v1.2.0
        11: Obsidian Functionplot v1.2.1
        12: Git v2.25.0
        13: Iconize v2.14.3
        14: Smart Random Note v0.2.1
        15: Meld Encrypt v2.3.7
        16: Mind Map v1.1.0
        17: Bulk Rename v0.5.2
        18: Kanban v2.0.51
        19: Dirtreeist v0.0.2
        20: Code Block Labels v1.0.0
        21: Custom Frames v2.4.7
        22: MySnippets v1.2.3
        23: Surfing v0.9.12
        24: Pluck v1.0.1
        25: Execute Code v1.12.0
        26: Desmos v0.6.8
        27: Tracker v1.14.0
        28: Diagrams.net v1.0.4
        29: TikZJax v0.5.2
        30: Excalidraw v2.3.0
        31: Templater v2.4.1
        32: Novel word count v3.10.2
        33: Link Favicons v1.8.4
        34: Note Refactor v1.8.2
        35: BRAT v1.0.1
        36: Latex Suite v1.9.4
        37: Advanced Tables v0.21.0
        38: Banners v1.3.3
        39: Commander v0.5.1
        40: 3D Graph v1.0.5
        41: Latex OCR v0.7.3
        42: Better Export PDF v1.9.1
        43: Export Image plugin v2.3.10
        44: YTranscript v0.9.2
        45: Workspaces Plus v0.3.3
        46: Dataview v0.5.67
        47: Periodic Notes v0.0.17
        48: Reminder v1.1.15
        49: Ribbon Divider v1.1.1
        50: Calendar v1.5.10
        51: Google Calendar v1.10.14
        52: Natural Language Dates v0.6.2
        53: Tag Wrangler v0.6.1
        54: Advanced Canvas v3.1.0
        55: Optimize Canvas Connections v1.0.0
        56: Keyshots v2.3.0
        57: Book Search v0.7.4
        58: Projects v1.17.4
        59: Highlightr v1.2.2
        60: Editor Syntax Highlight v0.1.3

RECOMMENDATIONS:
    Custom theme and snippets: for cosmetic issues, please first try updating your theme and disabling your snippets. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community theme and snippets.
    Community plugins: for bugs, please first try updating all your plugins to latest. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community plugins.

Describe the bug When I have hybrid note (both Excalidraw and markdown in one file, where i embed areas and frames of drawing into markdown), it takes a long time to export.

To Reproduce

  1. Create excalidraw file (drawing)
  2. Place two or more shapes of any kind (the more you place, the more time it will take in result to export)
  3. Copy embed link either of area or group (any kind of "part embed") of all elements
  4. Go to markdown side of current file
  5. Insert all these links into markdown with embeding whole image (embed file)
  6. Try to export to PDF
  7. Now it freezes and after a LONG time, it will finally export

Expected behavior To export faster (in seconds, not in tens or hundreds of seconds).

Screenshots This is screenshot of note that I was trying to export, and it took 20 seconds to export it.

Additional context No additional info. I have to say that your plugin is awesome and I love your work behind it, I appreciate it alot! <3

KrazyManJ commented 2 months ago

Note: I've tried it with empty vault, and the same result happened. As well as trying to embed 3 areas to separate note, the same export time result.

zsviczian commented 2 months ago

I am able to reproduce.

KrazyManJ commented 2 months ago

Thank you @zsviczian for your response.

One note to mention, some kind of memory leak happens afterwards, Obsidian went skyrocket from 1GB of RAM usage to 5GB when exporting note with 6 different area sections inside. Sometimes export will just close and whole Obsidian freezes.

zsviczian commented 2 months ago

this issue opened a can of worms. There are many things wrong with the preview rendering, Export to PDF is just one of the many issues. Unfortunately, this is probably the most flaky of all my code in the plugin. There are many special cases to look out for, and Obsidian does not natively support the type of rendering Excalidraw does ![[drawing]]. Obsidian's approach is built around code blocks, but code blocks come with lots of limitations... long story short I added some additional patching to the existing code, which drastically improved performance (at least in my setup) and reduced memory usage. Please test. I released 2.4.0-beta-4 just now.

Watch this if you are not familiar with BRAT and beta testing plugins: https://youtu.be/2poSS-Z91lY

KrazyManJ commented 2 months ago

@zsviczian, I apologize, but i have bad news. I don't see any change in time of export. I've tried several attempts of multiple notes and it ends up with obsidian freezing. I've tried both empty and my personal vault (that I've sent debug info of).

If you would like copies of notes, I can send them through discord to test them yourself, but I don't know how to help more.

zsviczian commented 2 months ago

Please confirm you are testing 2.4.0-beta-4

image
KrazyManJ commented 2 months ago

Here is a confirmation @zsviczian:

image

zsviczian commented 2 months ago

Please try to reproduce the error in a clean vault with only 2.4.0-beta-5 (I made a few further tweaks this morning). In my test environment, there is a very clear and strong performance improvement. So if the same is not true in your environment then we need to understand why the environment is different.

I don't expect that the file you are exporting should be a source of the issue, but if you can share, that can help me verify if the same problem happens on my end.

On a side note. I see you have Editor Syntax Highlight" installed. Based on this issue. I just saw a message by Licat (Obsidian funder) recommending not to use this plugin due to the solutions it includes. I recommend disabling it and then restarting Obsidian. It won't solve the export pdf issue, but at least there is one less potential problem source.

The other "suspicious" plugin is Better PDF Export. I am not familiar with the plugin, but since it is about PDF export and your issue is also with that... just trying to identify the differences.

Obsidian plugins (like Excalidraw) are hobby projects. I see you have 60 plugins enabled. I recommend clearing out those that you don't really use. Each plugin adds custom code that is most often not tested to work with other plugins and can have all sorts of adverse effects. For example, I use 18 plugins, and regularly trim back to list to closer to 10.

BTW - why are you not using live preview? It feels strange to me, as it is one of the best features of the Obsidian editor.

KrazyManJ commented 2 months ago

Hello @zsviczian, I've tried to update installer version and created brand new vault for this testing. Only thing that it contains are 5 files, one new created via current version of excalidraw, and 4 previous, and I am still facing the same issue. Here is debug info from this vault:

SYSTEM INFO:
    Obsidian version: v1.6.7
    Installer version: v1.6.7
    Operating system: Windows 11 Home 10.0.22631
    Login status: logged in
    Catalyst license: none
    Insider build toggle: off
    Live preview: on
    Base theme: adapt to system
    Community theme: none
    Snippets enabled: 0
    Restricted mode: off
    Plugins installed: 2
    Plugins enabled: 2
        1: BRAT v1.0.1
        2: Excalidraw v2.4.0-beta-5

RECOMMENDATIONS:
    Community plugins: for bugs, please first try updating all your plugins to latest. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community plugins.

So that means that the amount of plugin does not affect export time for me. At least I think. But still I will try to export all files via "Export to PDF command", with stopwatch to see how fast it actually is. I will send you all files to discord (i do not want to share them in public). Here are all files in experiment for export times (from lightest to most heaviest):

Note: While exporting notes, the UI somehow glitches, here is Screenshot:

image

BTW - why are you not using live preview? It feels strange to me, as it is one of the best features of the Obsidian editor.

I am used to it. Live preview somehow jumps in scroll and that slowed me down in work, now I am used to just press Ctrl + E to switch between Editing mode and Reading mode.

zsviczian commented 2 months ago

Thanks! The files were not attached.

KrazyManJ commented 2 months ago

Thanks! The files were not attached.

I've sent you them on Discord, because I do not want to share them in public. I've attached them there.