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

BUG: Performance issues when enabled #1456

Open
SeLiEnisyst opened this issue Nov 22, 2023 · 45 comments
Open

BUG: Performance issues when enabled #1456

SeLiEnisyst opened this issue Nov 22, 2023 · 45 comments
Labels
bug Something isn't working

Comments

@SeLiEnisyst
Copy link

SeLiEnisyst commented Nov 22, 2023

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....

@SeLiEnisyst SeLiEnisyst changed the title BUG: BUG: Performance issues when enabled Nov 22, 2023
@zsviczian zsviczian added the bug Something isn't working label Nov 23, 2023
@zsviczian
Copy link
Owner

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?

@zsviczian
Copy link
Owner

@TfTHacker is working on an update to SNW - which will be performance-oriented. Hopefully, that will resolve the issue.

@SeLiEnisyst
Copy link
Author

SeLiEnisyst commented Nov 24, 2023

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

@KingRecycle
Copy link

KingRecycle commented Nov 24, 2023

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.

@zsviczian
Copy link
Owner

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?

@KingRecycle
Copy link

@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.

d5pxva.mp4

@zsviczian
Copy link
Owner

@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?

image

@KingRecycle
Copy link

KingRecycle commented Nov 24, 2023

@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.

i525r7.mp4

@zsviczian
Copy link
Owner

@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.

@KingRecycle
Copy link

@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!

@zsviczian
Copy link
Owner

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.

@KingRecycle
Copy link

@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!

@zsviczian
Copy link
Owner

@KingRecycle can you test 2.0.4 to see if the performance has improved?

@KingRecycle
Copy link

KingRecycle commented Nov 26, 2023

@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.

@zsviczian
Copy link
Owner

I guess this is what "removing Excalidraw" support means: AnubisNekhet/AnuPpuccin@30b4da5

@KingRecycle
Copy link

@SeLiEnisyst Do you use the Anuppuccin theme? Turning it off fixed my performance issues.

@SeLiEnisyst
Copy link
Author

@KingRecycle No, I use the Minimal Theme. Disabling the Minimal Theme, didn't solve the problem

@piotrnajda3000
Copy link

piotrnajda3000 commented Nov 28, 2023

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:

image

Default theme + Excalidraw as the only plugin:

image

Minimal theme + no plugins:

image

Default theme + no plugins:

image

@zsviczian
Copy link
Owner

I have found 2 main sources of slowdown, but still investigating.

  1. 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.

  2. 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.

@zsviczian
Copy link
Owner

@piotrnajda3000, could you run the same test with this version?

main.zip

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")

@piotrnajda3000
Copy link

piotrnajda3000 commented Nov 29, 2023

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.

@zsviczian
Copy link
Owner

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 :(

@Archie-2021
Copy link

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

@Comprehensive-Jason
Copy link

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.

@zsviczian
Copy link
Owner

@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.

@Archie-2021
Copy link

@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

@Steven-AA
Copy link

Steven-AA commented Dec 18, 2023

Similar performance problem for me. Maybe this issue will be helpful.

@guidovicino
Copy link

guidovicino commented Dec 18, 2023

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)

@Archie-2021
Copy link

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.

@KingRecycle
Copy link

@Archie-2021 yeah I also still have the slow down on default theme but it's just worse on a custom theme.

@zsviczian
Copy link
Owner

Someone please help me with a repeatable/measurable test sequence to reproduce this. I created a new vault, I installed minimal theme and the minimal theme config plugin, plus Excalidraw. I set CPU throttle to 6x slowdown so as to counter my desktops performance. I am unable to spot any performance issues.

Do you experience slowness when a drawing is open, or just when Excalidraw is loaded to memory? Do you experience slowness in a markdown document, or in Excalidraw? Please help me with step by-step when I need to do so I can see a difference when running performance profiler in developer console.

Thank you!

@zsviczian
Copy link
Owner

I did 3 tests all roughly 10 seconds long.
1st with both Excalidraw and minimal theme disabled: render time 821ms; idle time:5309ms
Link to screen recording
image

2nd with only Excalidraw enabled: render time 1089ms; Idle time: 5823ms
link to screen recording
image

3rd with both Excalidraw and Minimal Theme + Theme Settings enabled render time: 1297ms, idle time 5341ms
link to screen recording
image

There does seem to be a gradual increase in render time (twice +20%), though the test is hardly definitive. Interestingly, in the second case, while render time increased, idle time increased as well. Maybe I was not pushing the keyboard vehemently enough?

@Archie-2021
Copy link

I did 3 tests all roughly 10 seconds long. 1st with both Excalidraw and minimal theme disabled: render time 821ms; idle time:5309ms Link to screen recording image

2nd with only Excalidraw enabled: render time 1089ms; Idle time: 5823ms link to screen recording image

3rd with both Excalidraw and Minimal Theme + Theme Settings enabled render time: 1297ms, idle time 5341ms link to screen recording image

There does seem to be a gradual increase in render time (twice +20%), though the test is hardly definitive. Interestingly, in the second case, while render time increased, idle time increased as well. Maybe I was not pushing the keyboard vehemently enough?

At least in my case it is visable when I try to scroll the page or move the cursor (I use vim mode and moving the cursor is so so rough when this slow down happens) and this is how i finally could figure out the issue at last, because I didn't have any other metric to measure it.

@zsviczian
Copy link
Owner

does it happen without VIM mode as well?

@Comprehensive-Jason
Copy link

Comprehensive-Jason commented Dec 18, 2023

Someone please help me with a repeatable/measurable test sequence to reproduce this. I created a new vault, I installed minimal theme and the minimal theme config plugin, plus Excalidraw. I set CPU throttle to 6x slowdown so as to counter my desktops performance. I am unable to spot any performance issues.

Do you experience slowness when a drawing is open, or just when Excalidraw is loaded to memory? Do you experience slowness in a markdown document, or in Excalidraw? Please help me with step by-step when I need to do so I can see a difference when running performance profiler in developer console.

Thank you!

I find the easiest way to test the slowdown is to type in an empty Markdown note. Without Excalidraw, the typing is smooth and normal. With Excalidraw, there is an inconsistent delay and lag between my keypress and the letters showing up on screen.

I record the performance while typing in a note, then look at the time spent on Recalculate Style.

Here's a video: https://drive.google.com/file/d/18Bwf68ZNQ2HbSEGCiq2d5smQ310whx80/view?usp=sharing
First is with Excalidraw, then without.

For some reason though, sometimes the performance feels fine with Excalidraw when I first open Obsidian. Only after I use it for a bit does the lag start appearing.

@Archie-2021
Copy link

Someone please help me with a repeatable/measurable test sequence to reproduce this. I created a new vault, I installed minimal theme and the minimal theme config plugin, plus Excalidraw. I set CPU throttle to 6x slowdown so as to counter my desktops performance. I am unable to spot any performance issues.

Do you experience slowness when a drawing is open, or just when Excalidraw is loaded to memory? Do you experience slowness in a markdown document, or in Excalidraw? Please help me with step by-step when I need to do so I can see a difference when running performance profiler in developer console.

Thank you!

I find the easiest way to test the slowdown is to type in an empty Markdown note. Without Excalidraw, the typing is smooth and normal. With Excalidraw, there is an inconsistent delay and lag between my keypress and the letters showing up on screen.

I record the performance while typing in a note, then look at the time spent on Recalculate Style.

Here's a video: https://drive.google.com/file/d/18Bwf68ZNQ2HbSEGCiq2d5smQ310whx80/view?usp=sharing

Exactly, it is not just moving the cursor, it is a huge delay to any keyboard input when I am typing too, which may have nothing to do with vim mode

@zsviczian
Copy link
Owner

zsviczian commented Dec 19, 2023

So I think this is a CSS issue. If I delete the Excalidraw CSS styles from document performance improves.

This led me to see that excalidraw littered with lots of <style> tags. I rolled back all the way to April 2021, it seems the plugin has always been like this. I've now cleaned it up, however performance did not improve - I think. I'd appreciate if you could try this new styles.css and main.js and let me know your experiences.

main.zip

unzip and copy contents to .obsidian/plugins/obsidian-excalidraw-plugin. Restart Obsidian and let me know if you experience improvement.

I looked at :has mentioned in the linked issue above, but that does not account for any of the performance issues. I also fed my CSS to ChatGPT to ask if there is anything funny in there - result is, there is nothing.

@Steven-AA
Copy link

Steven-AA commented Dec 19, 2023

Way better.

Previous:
image

New one:
image

With Excalidraw off:
image

BTW, I am typing during the record.

@KingRecycle
Copy link

KingRecycle commented Dec 21, 2023

Has anyone tried uninstall/reinstall Obsidian completely? I got a new SSD and I reinstalled Windows which I had to reinstall Obsidian and now the performance issues I had are gone with Excalidraw enabled with default/minimal theme. Anuppuccin theme still kills the performance though.

Have you tried this @Steven-AA ?

@Steven-AA
Copy link

Has anyone tried uninstall/reinstall Obsidian completely? I got a new SSD and I reinstalled Windows which I had to reinstall Obsidian and now the performance issues I had are gone with Excalidraw enabled with default/minimal theme. Anuppuccin theme still kills the performance though.

Have you tried this @Steven-AA ?

No I did not. Seems that you have a different performance bottleneck. The temp new file above already works perfect for me.

@zsviczian
Copy link
Owner

@Steven-AA hope you have upgraded to 2.0.13 and not using the temp file still. All the performance enhancements are included in the new version - plus some fixes (such as using the temp file the stencil library is not visible, because I purged the excalidraw.css too aggressively.)

@NukedOne
Copy link

NukedOne commented Dec 25, 2023

I started to find Obsidian slowing down for some reason. Then I followed the performance debug process, and after confirming that it runs flawlessly in Restricted mode, I started the bisection process, and it turned out that when I enable Excalidraw, I notice the ~1s latency when switching notes, for example. Then I went to Excalidraw issues page and found this issue. It turns out I also have Minimal theme installed. I tried disabling Minimal theme and using the Default theme, while keeping Excalidraw enabled, and the slowdown would go away. I can live with the Default theme for now, but just beware, there is something in these two plugins that makes them not get along well.

Obsidian v1.4.16
Excalidraw 2.0.13

@roman-balzer
Copy link

Just played around with extensions and also noticed that excalidraw had an high impact on typing performance (using minimal), but also want to note that having sidebars open with notes in it severely decreases performance additionally

@zsviczian
Copy link
Owner

zsviczian commented Feb 21, 2024 via email

@zsviczian
Copy link
Owner

zsviczian commented Feb 21, 2024

@roman-balzer, (or anyone else who has energy for this....)

As I do not use the Minimal theme, you could help with some testing to try to see what the problem might be using the method of elimination. I want to understand if the issue is because of some conflict between the Minimal theme css and the Excalidraw css or because of something in the plugin code. I have an assumption this is CSS related, this is what I'd like to confirm or prove wrong.

For this testing

  1. turn off the Excalidraw plugin.
  2. create, then enable a css snippet
    image
  3. see if the performance issue is still there

CSS Snippets to play with (You'll need to download and unzip these css files):

  1. Test with the normal/full excalidraw snippet. Copy this file as a css snippet, then enable it:
    styles-with-fonts.zip

Do you experience similar performance issues when this css snippet is enabled as when Excalidraw is enabled?

  1. If yes, then try this second css (this one is much smaller (does not have the embedded fonts)
    styles-without-fonts.zip

Do you experience similar performance issues when this css snippet is enabled as when Excalidraw is enabled?

  1. if yes, then lets start to eliminate the parts of the css. Half the css, cutting at valid locations (typically after } character, so the css file stays functional. Try the top half, then try the bottom half.

Do you experience similar performance issues when this css snippet is enabled as when Excalidraw is enabled?

  1. half the half that produced the performance issue and continue as in step 3.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

10 participants