mayurankv / Obsidian-Code-Styler

A plugin for Obsidian.md for styling codeblocks and inline code
Other
282 stars 9 forks source link

Bug: performance issues #91

Open olearydj opened 1 year ago

olearydj commented 1 year ago

While Code Styler is enabled my Obsidian performance is significantly affected. Keyboard response, file opening, etc. are all noticeably delayed. When I disable OCS, these symptoms go away.

Describe the bug

See above.

Steps to reproduce

See above.

n/a

Expected behaviour

Don't hinder app responsiveness.

Current behaviour

Distracting enough that I have to disable an otherwise awesome plugin. ☹️

Environment

16" 2019 MacBook Pro with 2.3g 8-core intel and AMD radeon pro 5500m (8gb); 32gb ram I've never reported a performance bug before, so I'm not one of those guys.

Additional context

No console errors. I'm happy to provide any other logs / data you need to consider / address this issue. Thanks for a great, beautiful plugin.

Dan

mayurankv commented 1 year ago

Sorry, is version 1.4.3 an insider version?

Have you used any version of the plugin before 1.0.7? Were the issues still present? Could you try making a new vault and seeing if the performance persists? If it does, I'd still be interested in solving why its affecting performance for you but It'd be nice to know the whole thing isn't buggy haha.

Lastly, if the problem does persist, could you try close all notes apart from one reading mode note and see if the symptoms are still there, and also then separately try just one editing mode note and see if the symptoms remain.

Did you try and disable all other plugins than this plugin? (I know that's tedious so no worries if not).

olearydj commented 1 year ago

It seems ok in a sandbox with just OCS installed.

I previously reported a couple of bugs that you fixed in earlier versions. I've experienced "laggy" performance from the first use, but wasn't certain it was due to OCS. I've enabled and disabled it several times since, each time sensing the issue enough to disable it again. It is not a dramatic slowdown, but enough to be distracting. v1.4.3 is an insider version.

I recorded a test in my main vault. First I closed all notes, restarted Obsidian, and then started recording the video. https://share.cleanshot.com/3FPHdpQW

Maybe a result of interaction with other plugins, etc. Can I dump any performance related data for you? I can do more testing with some plugins deactivated, etc. later but don't have the time right now.

Thanks for the quick support as always.

mayurankv commented 1 year ago

Huh, I'm afraid I'm going to have to take some time working out what the issue could be. I'll first try to replicate it if possible. Will likely ask a few questions over the next few days.

mayurankv commented 1 year ago

Honestly, that is really surprising, I've not noticed any effects similar to that video. Do the symptoms also occur in reading mode?

olearydj commented 1 year ago

Sorry for the troubling news. It is hard to tell if the effects persist in reading mode, because it is most noticeable when I type, etc.

But when checking to confirm that I noticed that my code blocks aren't actually getting the OCS styling in reading mode. This must be a new problem as I would have noticed it before. I've attached a new video that shows that. Also, when I deactivate OCS, the live preview mode gets corrupted. See video.

https://share.cleanshot.com/V1Yx9wm5

mayurankv commented 1 year ago

Thanks again for the detailed report. I had actually noticed when doing extensive testing that sometimes half the page would load before I scrolled and then the rest would suddenly appear so I agree there must be some significant internal issue regarding that. For the reading mode, are you definitely not getting error outputs in your command log?

olearydj commented 1 year ago

I just repeated the entire process in the prior video with the dev tools opened. No errors or warnings were popped.

olearydj commented 1 year ago

I also noticed the text / styles popping in while scrolling in Reading mode with OCS active.

mayurankv commented 1 year ago

Would it be possible to list the active plugins you're using?

I must say I'm at a bit of a loss on where to start with this. I'll try and identify why things may not completely render instantly with reading mode for some clues. Also editing mode may just be running a bit too intensively causing the performance issues. But reading mode not applying at all with no errors at all is weird.

mayurankv commented 1 year ago

Could you send me the content of the note that breaks as well?

olearydj commented 1 year ago

Happy to provide whatever you need.

python-virtual-environments.md

SYSTEM INFO:
    Obsidian version: v1.4.3
    Installer version: v1.3.5
    Operating system: Darwin Kernel Version 22.5.0: Thu Jun  8 22:22:22 PDT 2023; root:xnu-8796.121.3~7/RELEASE_X86_64 22.5.0
    Login status: logged in
    Catalyst license: vip
    Insider build toggle: on
    Live preview: on
    Legacy editor: off
    Base theme: dark
    Community theme: Minimal v7.2.0
    Snippets enabled: 5
    Restricted mode: off
    Plugins installed: 49
    Plugins enabled: 41
        1: Dataview v0.5.56
        2: File Tree Alternative Plugin v2.3.5
        3: Admonition v10.0.1
        4: Auto Link Title v1.4.1
        5: Advanced Tables v0.19.1
        6: Better Word Count v0.10.0
        7: Advanced Slides v1.20.0
        8: Divide & Conquer v1.0.0
        9: floating toc v2.3.0
        10: File Creation and Last Modified Timestamps in Status Bar v1.2.0
        11: Another Quick Switcher v8.14.0
        12: Zotero Integration v3.0.7
        13: Pandoc Reference List v2.0.19
        14: Hide Sidebars on Window Resize v1.1.0
        15: Plugin Update Tracker v1.5.2
        16: Share as Gist v1.2.1
        17: Text Format v2.2.7
        18: Wikipedia v1.0.3
        19: Hider v1.3.1
        20: Hotkey Helper v0.3.18
        21: Kanban v1.5.3
        22: Linter v1.19.1
        23: Longform v2.0.3
        24: Minimal Theme Settings v7.2.1
        25: Note Refactor v1.7.1
        26: Pandoc Plugin v0.4.1
        27: Pane Relief v0.5.1
        28: Quick Explorer v0.2.8
        29: Readwise Official v2.0.1
        30: Recent Files v1.3.7
        31: Regex Find/Replace v1.2.0
        32: Settings Search v1.3.8
        33: Sortable v0.3.1
        34: Style Settings v1.0.6
        35: Supercharged Links v0.10.0
        36: Tag Wrangler v0.5.11
        37: Templater v1.16.0
        38: Text Generator v0.3.20
        39: Force note view mode v1.2.0
        40: Obsidian Git v2.20.7
        41: Default New Tab Page v0.11.0

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.
olearydj commented 1 year ago

It's a lot of plugins. I can do some divide and conquer testing this weekend if you like. It might not completely isolate the problem but could save a lot of time.

mayurankv commented 1 year ago

That would be very helpful if you get the time! I'm trying to get the next release done and then I'll try and focus on this. Thank you for all the info!

mayurankv commented 1 year ago

I doubt this has been resolved with the latest release?

olearydj commented 1 year ago

I haven't had a chance to check it yet. Will do so this weekend and provide some divide and conquer findings if not. Sorry for going quiet - I'm trying to finish my PhD this semester while teaching a full load and had to travel last weekend.

mayurankv commented 1 year ago

Oh no rush at all! Best of luck with the PhD and teaching!

mayurankv commented 1 year ago

FYI some rather large changes have been made to how the live preview part of the plugin works with the last two versions. Though I'm not actually sure whether it improves or detracts from performance (as I've never had an issue with it either way). Would be interested to hear how you feel when you get the chance!

olearydj commented 1 year ago

Hey, I'm really sorry I haven't been able to get back to this. It is still on my list and I plan to this weekend. Meanwhile I've noticed the latest version fails to install when upgrading in the plugin panel.

mayurankv commented 1 year ago

Hi, honestly no worries at all! I actually just released a new version and tested that I could update from a previous version. Not sure if the last release had issues. Could you check if this one works?

olearydj commented 1 year ago

Hey! Yes, I was able to get the next version installed without issues. with the 1.4.5 version rolled out to everyone, I'm hopeful we can get to the bottom of this - I'll get you an update this weekend

On Fri, Aug 25, 2023 at 6:04 PM Mayuran Visakan @.***> wrote:

FYI some rather large changes have been made to how the live preview part of the plugin works with the last two versions. Though I'm not actually sure whether it improves or detracts from performance (as I've never had an issue with it either way). Would be interested to hear how you feel when you get the chance!

— Reply to this email directly, view it on GitHub https://github.com/mayurankv/Obsidian-Code-Styler/issues/91#issuecomment-1694019133, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKF2CW2XCXF3COQGK55DUXDXXEVRVANCNFSM6AAAAAA3UKU5WA . You are receiving this because you authored the thread.Message ID: @.***>

noidilin commented 1 year ago

Hi, I'm experiencing a similar performance issue. Most of the operations in Obsidian feel laggy after OCS is enabled.

I've tried disabling the plugins I am using one by one and found out that disabling the "Excalidraw" plugin will fix the performance issue in my case. It's worth mentioning that before installing OCS, I hadn't noticed any kind of performance issue while using the "Excalidraw" plugin.

Here is the system info when encountering the issue:

Plugin Version: 1.0.11

{
  "process": {
    "obsidian-version": "1.4.16",
    "obsidian-installer": "1.4.13",
    "platform": "desktop",
    "os": "windows11",
    "theme": "minimal"
  },
  "app": {
    "internalPlugins": {
      "config": {
        "file-explorer": true,
        "global-search": true,
        "switcher": true,
        "graph": true,
        "backlink": true,
        "outgoing-link": true,
        "tag-pane": true,
        "page-preview": true,
        "daily-notes": false,
        "templates": false,
        "note-composer": false,
        "command-palette": true,
        "slash-command": false,
        "editor-status": false,
        "starred": true,
        "markdown-importer": false,
        "zk-prefixer": false,
        "random-note": false,
        "outline": true,
        "word-count": false,
        "slides": false,
        "audio-recorder": false,
        "workspaces": true,
        "file-recovery": true,
        "publish": false,
        "sync": false,
        "canvas": true,
        "bookmarks": true,
        "properties": true
      }
    },
    "plugins": {
      "enabledPlugins": [
        "smart-random-note",
        "note-refactor-obsidian",
        "hotkeysplus-obsidian",
        "better-word-count",
        "periodic-notes",
        "table-editor-obsidian",
        "cm-typewriter-scroll-obsidian",
        "tag-wrangler",
        "dataview",
        "obsidian-outliner",
        "obsidian-style-settings",
        "templater-obsidian",
        "obsidian-git",
        "calendar",
        "obsidian-admonition",
        "obsidian-minimal-settings",
        "obsidian-hider",
        "obsidian-footnotes",
        "open-vscode",
        "obsidian-linter",
        "metadata-menu",
        "tag-navigator",
        "obsidian-contextual-typography",
        "obsidian-memos",
        "obsidian-advanced-slides",
        "obsidian-regex-pipeline",
        "excalibrain",
        "various-complements",
        "darlal-switcher-plus",
        "cm-chs-patch",
        "omnisearch",
        "obsidian-hover-editor",
        "obsidian-filename-heading-sync",
        "pane-relief",
        "nldates-obsidian",
        "url-into-selection",
        "workspaces-plus",
        "obsidian-icon-folder",
        "obsidian-paste-png-to-jpeg",
        "obsidian-snippet-downloader",
        "obsidian-quiet-outline",
        "obsidian-textgenerator-plugin",
        "obsidian42-brat",
        "yank-highlight",
        "obsidian-plugin-prettier",
        "code-emitter",
        "graph-analysis",
        "ninja-cursor",
        "easy-typing-obsidian",
        "code-styler",
        "obsidian-excalidraw-plugin"
      ]
  }
}
mayurankv commented 12 months ago

Hi! Thanks for letting me know. That's really annoying. Just to double check, if you update to the new release the issue still persists right? One more question, does the issue still persist in a new vault with just Excalidraw and OCS installed?

mayurankv commented 12 months ago

@olearydj Just to check, are you still having any performance issues at all? No worries if you haven't got any further info.

noidilin commented 12 months ago

I just tested in a vault with a clean setup, and both the “Excalidraw” and OCS plugins are updated. Unfortunately, I found out that actually Obsidian became pretty laggy after I enabled the “Excalidraw” plugin. Since I haven’t used a brand new vault for a long time, I didn’t notice the performance impact before.

Moreover, by enabling more plugins that function in edit mode, the performance drop is continuously increasing. Therefore, the experience that I am having might be the compound result of multiple plugins, but most of it is contributed by “Excalidraw” and then secondly by the OCS plugin.

mayurankv commented 12 months ago

I'm always interested in performance issues so I will try and have a look as to how any issues might be arising.

Does enabling OCS after exalidraw affect performance any more than any other plugin after excalidraw? i.e. the execute code plugin or dataview or any others?

noidilin commented 12 months ago

It is quite hard to explain the laggy behavior, so I recorded a video with the newly created vault and other plugin enabled. There is a keycast indicator showing what key I have pressed or I am currently holding.

https://github.com/mayurankv/Obsidian-Code-Styler/assets/40153468/b0af951f-b8d2-4c1a-a3f1-52f4024b951b

During this video, I have done these operation:

  1. Use arrow key to move in source mode with OCS and excalidraw disabled.
  2. Enable Excalidraw. You can see the cursor behavior not syncing with keypress (especially when I holding arrow key).
  3. Disable Excalidraw and reload obsidian.
  4. Enable OCS and the cursor behavior still not syncing with keypress.
  5. Enable Excalidraw with OCS enabled. The issue become more noticable.

In my personal experience, most significant performance impact comes from the OCS and Excalidraw plug-ins.

roman-balzer commented 9 months ago

I did some testing on this, so I had an empty file where I had a macro type like 20 characters (almost no delay between). No plugins except OCS, toggling on/off Theme and CSS

Results: Using OCS will introduce severe typing lag especially with multiple CSS-Snippets like MCL or some of my custom ones. However, this happens when I have a "more complex" file open. Empty file with no sidebar - no lag Empty file with complex file in sidebar - severe lag (800ms) Complex file with no sidebar - severe lag (800ms)

When I say "complex", I'm talking about some headers, some task lists and some links. Not more than that. And at no point in those tests I had somewhere a code snippet in view or file.

mayurankv commented 9 months ago

Hi, thanks so much for this, it'd be great to tackle this. Would it be possible for you to provide some of the snippets and files for which the lag was noticeable?

roman-balzer commented 9 months ago

I'm still trying to narrow it even more down, since the CSS also does introduce a good amount of lag. But like I mentioned even with no CSS and no Theme, the rendering goes from ~70ms to ~115ms in my tests.

As for CSS, MCL's CSS had a really noticeable effect on the rendering performance alongside OCS. As for the file, I'd rather not share my private ToDo list, but like I said, it's really just a File with Headers, TasksList, some links internal and external, maybe 80-100 lines.

mayurankv commented 9 months ago

No worries, I'll try and create a similar file and see if I can reproduce this. Thanks for mentioning the CSS and any further information you do fine would definitely be helpful in fixing this. This will probably be my first priority to fix if I can reproduce it (hopefully over the next few days). By any change are the css files that get cumbersome ones that define colours? Also one more question, how are you measuring the rendering time? That would be really helpful for me to test as well!

roman-balzer commented 9 months ago

I measured the time with dev tools. image I mostly only looked at Recalculate Style as that did notable jump from 50ms to 800ms. But I do have to add, since I tested it with a macro without delay between keypresses, that made the performance issue more obvious and thus those 800ms. When mashing 123123123123 fast, those numbers where not that high, but still very notable elevated.

About the problematic CSS, I haven't narrowed it down, also not really a pro on CSS performance. But I'll just add that info, some of more notable slowdowns occurred with CSS files using :has() and :is(). But that's just a wild guess.

mayurankv commented 9 months ago

Thanks for the added detail. Would it be possible to share the macro as I'd obviously like to fix this issue as completely as possible (though an imperceptible lag would still be much better than the current state).

roman-balzer commented 9 months ago

Macro is just in my keyboard software writing, 123 123 123 this is a test. Can't export that.

mayurankv commented 9 months ago

Got it cheers, thanks for all th info, will try to reproduce.