obsidian-excalidraw-plugin
obsidian-excalidraw-plugin copied to clipboard
BUG: Performance issues when enabled
Hi, I'm experiencing performance issues, when I have this plugin enabled: When typing some letters or sentences on my keyboard, the editor shows them much later (~ 1 second) than without enabling this plugin...
See my current debug info: SYSTEM INFO: Obsidian version: v1.5.0 Installer version: v1.4.13 Operating system: Windows 10 Pro 10.0.22621 Login status: logged in Catalyst license: insider Insider build toggle: on Live preview: on Base theme: dark Community theme: Minimal v7.4.2 Snippets enabled: 2 Restricted mode: off Plugins installed: 61 Plugins enabled: 6 1: Calendar v1.5.10 2: Copy as HTML v1.1.3 3: Dataview v0.5.64 4: Diagrams v1.5.0 5: Excalidraw v2.0.2 6: File Tree Alternative Plugin v2.3.6
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.
... unfortunately I experience the same behavior when disabling File Tree Explorer...
so: this configuration works fine: 1: Calendar v1.5.10 2: Copy as HTML v1.1.3 3: Dataview v0.5.64 4: Diagrams v1.5.0 5: Excalidraw v2.0.2
this configuration works also fine: 1: Calendar v1.5.10 2: Copy as HTML v1.1.3 3: Dataview v0.5.64 4: Diagrams v1.5.0 5: File Tree Alternative Plugin v2.3.6
but this configuration has performance issues: 1: Calendar v1.5.10 2: Copy as HTML v1.1.3 3: Dataview v0.5.64 4: Diagrams v1.5.0 5: Excalidraw v2.0.2 6: File Tree Alternative Plugin v2.3.6
Do you have an idea, how to proceed?
same issues with this configuration, that has the same performance issues:
Plugins enabled: 10
1: Calendar v1.5.10
2: Copy as HTML v1.1.3
3: Dataview v0.5.64
4: Diagrams v1.5.0
5: Hotkeys++ v0.2.7
6: Hotkeys for templates v1.4.3
7: Minimal Theme Settings v7.3.0
8: Natural Language Dates v0.6.1
9: Obsidian42 - Strange New Worlds (SNW) v1.2.3
10: Excalidraw v2.0.2
without plugin 9) there are no issues and without plugin 10) there are no issues. If both are enabled, there are issues....
does this happen on an empty page or a page that has already some text? If yes, can you share an example page? Does this happen when you have only a single tab open, or when you have multiple tabs open? What are on those tabs?
@TfTHacker is working on an update to SNW - which will be performance-oriented. Hopefully, that will resolve the issue.
does this happen on an empty page or a page that has already some text?
yes, it also happens on an empty page
Does this happen when you have only a single tab open, or when you have multiple tabs open?
yes, it also happens with only a single tap open
Not sure if my issue is super related but I also have this issue but it is all of Obsidian that slows down, Doing anything has a slight delay to it. Disabling all plugins but Excalidraw still causes the slow down.
looking for the needle in the haystack. (unfortunately) I do not experience performance issues... thus cannot replicate problems. True, Excalidraw installs a number of event handlers, but based on code profiling I don't see these consuming an obsessive amount of resources.
@KingRecycle, What device are you on?
Can you confirm, that you have disabled all other plugins, then restarted obsidian (to ensure plugins are properly offloaded - some plugins fail to clean up fully), and you experience a slowdown?
Is this slowdown right after Obsidian starts, or even 5 minutes later (maybe Obsidian indexing is running in the background that is eating resources)
Are you frequently changing theme or css styles?
Do you experience a slowdown on an empty document? or a document full of drawings?
@zsviczian I am on PC and yes I've tried restarting Obsidian after disabling, I get the same issue. It's kind of like going from 60fps to 30fps in a sense. It's not a harsh delay but it's a noticeable difference. It's really noticeable when expanding the directory tree and panning the canvas. I recorded a video at 60fps to give you an idea of what I am experiencing.
If you slow it down to x0.25 you can see the "hitching".
Video: Starts off showing with all plugins disabled and then after a few seconds I enable just excalidraw and show that, then I turn it back off and show it without it again.
https://github.com/zsviczian/obsidian-excalidraw-plugin/assets/2867068/5f6e1338-d71f-4700-af99-430fe1dcafad
@KingRecycle, do you by any chance have "Display type for excalidraw.md files in file explorer" enabled? That will have a slight effect on File Explorer when you open or close it, but not at any other time. i.e. it should not affect typing, searching, or anything else - since it monitors the changes in the file explorer tree. Try turning that option off.
What do you mean by panning the canvas? Which canvas?
@zsviczian "Display type for excalidraw.md files in file explorer" option is disabled.
It's like any Obsidian Canvas will drop to like 30fps or something. Here is a video of what happens.
https://github.com/zsviczian/obsidian-excalidraw-plugin/assets/2867068/85440bb0-ab51-4da2-8245-1161a897924e
@KingRecycle I may have found a solution. The strange thing is it has been there for minimum a year now... and nobody ever pointed it out.
I am glad this came up, debugging this helped me identify a number of performance improvement opportunities.
🫰that you'll confirm the performance improvement... Hope to release this WE.
@zsviczian Awesome! The typing issue from the OP I didn't really have or if it is an issue it's so minor I can't really notice it and it wasn't until I was thinking about reorganizing my folder structure that I noticed some hitching in opening folders which got me to test stuff like moving a canvas around. So I couldn't say for sure how long I've had the issue.
Also I forgot to mention that I use the insider build but I did go rollback and check and I still get the slow down when Excalidraw is enabled. I've also changed my monitor to 60hz which makes the slow down less noticeable compared to when I set it to 144hz, so that might contribute to no one bringing up the issue. /shrug
Thanks for your hard work!
this has nothing to do with the insider build, but rather with code I built at the very beginning of the plugin 2+ years ago... code which was not very efficient.
@zsviczian Alright. I'm just trying to cover my bases and give you as much information as possible. I know how troublesome debugging can be. :) Thanks!
@KingRecycle can you test 2.0.4 to see if the performance has improved?
@zsviczian It didn't so I did some more testing.
It seems to be something with AnuPpuccin Theme that reduces the performance of Obsidian and when Excalidraw is enabled for some reason makes it much worse, but with the theme turned off and all my plugins turned on the performance is fine.
Their latest update says "Removed Excalidraw support", not sure if that is related. It was updated 5 days ago which is the same as this issue was created. Not sure if OP also uses the theme though.
I guess this is what "removing Excalidraw" support means: https://github.com/AnubisNekhet/AnuPpuccin/commit/30b4da57c96c2ee06338490fa107d43b18406150
@SeLiEnisyst Do you use the Anuppuccin theme? Turning it off fixed my performance issues.
@KingRecycle No, I use the Minimal Theme. Disabling the Minimal Theme, didn't solve the problem
First of all, thank you for your incredible work zsviczian.
Test with switching between two empty notes (one had one metadata field with two URLs; both had one H1 heading) at a steady rhythm for ~10 seconds. Hardware acceleration enabled, Ubuntu, latest Obsidian and Excalidraw.
We can see that with the Minimal Theme + Excalidraw combo, we're getting 2 whole more seconds on rendering.
Rendering is ~5 times slower for the Default theme with Excalidraw enabled, then without.
Minimal theme + Excalidraw as the only plugin:
Default theme + Excalidraw as the only plugin:
Minimal theme + no plugins:
Default theme + no plugins:
I have found 2 main sources of slowdown, but still investigating.
-
when measuring the text size (this happens very frequently, when ever text elements are rendered for the first time or changed, Excalidraw places a div at the document.body level. I am now testing a modification nesting the text measure div in a div under body, this way avoiding events impacting the whole document tree. The difference is that Excalidraw.com only has Excalidraw, thus changes to body make no real difference. But in Obsidian document body is very heavy.
-
I have 2 DOM observers that fire too frequently, both monitory changes to body. I need to find a different way to achieve their effects. Working on it.
Both of the above will likely collide with themes, because I assume they regularly update body with class tags or similar which in turn triggers a whole host of actions in Excalidraw.
The good thing is I finally found a way to test all of this by throttling my CPU 6x. My next update will focus solely on improving performance.
@piotrnajda3000, could you run the same test with this version?
Can you also confirm if you also have legacy excalidraw files in your vault, and if yes, try the same in a vault without the legacy files. (Remove those and restart Obsidian)
app.vault.getFiles().filter(f=>f.extension==="excalidraw")
Hello @zsviczian, I've repeated my yesterday tests, this time fully relaunching Obsidian between each bullet point below. It's probable I didn't correctly restart when testing yesterday.
- Default Theme + no Excalidraw = ~400ms
- Default Theme + Excalidraw = ~400ms
- Minimal Theme + no Excalidraw = ~700ms
- Minmal Theme + Current Excalidraw = ~2800ms
- Minmal Theme + new main.js for Excalidraw plugin = ~2800ms (same after removing legacy files and restart)
It seems like the issue is with a combination of Minimal Theme + Excalidraw. The delay is noticeable, too, unfortunately.
So this is partially good news. If I understand the earlier measurements correctly, "old excalidraw" with default theme took ~1700ms, which is now down to 400ms. That is a huge improvement, since "new Excalidraw" plus the Obsidian default theme results in no impact to Obsidain performance. I will investigate what minimal theme might be doing that is causing such a major performance drag... (400 to 700 is also an almost 100% degradation), but, to manage expectations, I can't address the issues caused by other plugins and themes. On top of that, unfortunately, I haven't had the real partnership response from Stephen when I tried to address minimal theme and Excalidraw compatibility with him earlier (#502) - so I don't really have high hopes for cooperation now :(
So this is partially good news. If I understand the earlier measurements correctly, "old excalidraw" with default theme took ~1700ms, which is now down to 400ms. That is a huge improvement, since "new Excalidraw" plus the Obsidian default theme results in no impact to Obsidain performance. I will investigate what minimal theme might be doing that is causing such a major performance drag... (400 to 700 is also an almost 100% degradation), but, to manage expectations, I can't address the issues caused by other plugins and themes. On top of that, unfortunately, I haven't had the real partnership response from Stephen when I tried to address minimal theme and Excalidraw compatibility with him earlier (#502) - so I don't really have high hopes for cooperation now :(
I just found out the reason of the huge performance issue with my vault was Excalidraw, and after reading this post i disabled my minimal theme and re-enabled Excalidraw and it is fixed. The impact is so huge, like CPU don't stop to drop to normal levels for minutes after launch and I can scroll smoothly at all. I hope you guys fix this issue soon as I am a big fan of both this plugin and minimal theme. And I would love to help you guys in case you need any info for debugging.
Thanks
I just discovered this conflict between Minimal and Excalidraw was causing lag on my system as well. I hope you all can get it fixed. I'm willing to provide any info needed for debugging as well.
@Comprehensive-Jason, @Archie-2021: Please also raise this issue with Minimal Theme as well. Because my earlier attempt to collaborate on solving an issue with Minimal Theme didn't result in the collaboration I would have hoped for... I've not put any effort into this issue recently. There are many beautiful and functional themes out there. Please choose another until this is fixed - I am sorry.
I'll take a look at this during the holidays.
@Comprehensive-Jason, @Archie-2021: Please also raise this issue with Minimal Theme as well. Because my earlier attempt to collaborate on solving an issue with Minimal Theme didn't result in the collaboration I would have hoped for... I've not put any effort into this issue recently. There are many beautiful and functional themes out there. Please choose another until this is fixed - I am sorry.
I'll take a look at this during the holidays.
Sure , I will raise the issue with them too. I have been using Minimal theme since when I started to use Obsidian (it is more than 3-4 years i think) . It is just that I am very used to have control over appearance of my vault via Minimal Theme settings + Styles plugin that I dont know another way of how to do it. For now I just disable Excalidraw or Minamal based on the needs but I am depending on both of them.
Thanks
Similar performance problem for me. Maybe this issue will be helpful.
Similar performance issue also for me. Bad with default theme. More bad with minimal theme (Debian 12, v1.4.16. Every plugin disabled except Excalidraw. Using deb package)
Today I noticed on another of my vaults that the issue with Excalidraw exists even when I disable Minimal theme. It only goes away when I disable this plugin.
@Archie-2021 yeah I also still have the slow down on default theme but it's just worse on a custom theme.