obsidian-tasks-calendar-wrapper
obsidian-tasks-calendar-wrapper copied to clipboard
Blocking main thread leading to frozen UI
It seems like calendar-wrapper is blocking the UI thread when updating itself, leading to stuttering when the user is writing things. Correct me if I'm wrong, but I've traced it to the function "workLoopSync @ plugin:tasks-calendar-wrapper" which had a total time of 290.4ms to update which blocked user input in obsidian and froze it.
At the same time, for everytime there is a freeze, there's some leftover info level logging being made to the console, with the following message.
Ahis can be traced to the following code, inside the obsidian task wrapper plugin.
Profilling image for reference.
Hi @Osigmae thanks for your feedback and analysis, not sure how would the stuttering happen cause in my environment it works ok. But there is indeed some sync operations (and awaiting async operations) in the code on your writing, but to my knowledge there should be no IO accesses in this process, the items are taken from cache data maintained by obsidian, which should not block.
I assume the reason the stuttering issue happens because there are too many items in your environment, and everytime your files changed the whole item sorting/filtering and some other CPU operations happen. Maybe it can be resolved if you filter out some of them for now, I will work on a diff algorithm or just merge multiple data change actions in a time range (e.g. 200ms) to one to solve this issue.
@Leonezz thanks for your reply! I looked further into my obsidian folder, and found that both the .git, .obsidian and a single folder with a single software project i forgot were adding a lot of files to my workspace. I think you were right, that the files were adding too much overhead to processing. I removed these folders (plugin data which were generated in the .obsidian folder case), and the blocking behavior is gone. thanks!
I still want to investigate further if whether obsidian is slowed down by files inside a .(dot)folder, which in my mind, it should just ignore when it comes to indexing files for tasks and the like. So I think you were right in that there were a lot of files in my environment, I just didn't think it would affect this it so much when it came to responsiveness in the ui.
When time allows, I will try to strace obsidian and see if it crawls though .folders like .obsidian and .git on the filesystem via syscalls everytime it updates or it's mainly due to having this in memory cache having too many elements and that it doesn't filter or separate this long list into smaller segments which can be processed as chunks so it doesn't steal the main thread for too long during this.