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

[Feature Request] Run on background process. / [Bug] UI freeze when run. #69

Open
lkhphuc opened this issue Apr 21, 2021 · 44 comments
Open

[Feature Request] Run on background process. / [Bug] UI freeze when run. #69

lkhphuc opened this issue Apr 21, 2021 · 44 comments

Comments

@lkhphuc
Copy link

@lkhphuc lkhphuc commented Apr 21, 2021

I set git backup to run automatically every hour.
Everytime it runs, Obsidian becomes laggy and unresponsive until it finish, which can takes up to 30s-60s. If I happen to be using Obsidian at this exact time 2-3 times in a morning, it can be very frustrating.
I wonder if this process can be run in the background?

Maybe related if #68 is fixed.

@MrVPlusOne
Copy link

@MrVPlusOne MrVPlusOne commented Apr 28, 2021

I'm having the same issue here! One thing that feels strange to me is that if I manually push the changes from within the command line using git, it takes almost no time for the push to finish, whereas if I run the push command of the plugin from inside Obsidian, it freezes the UI and can take more than 30 seconds. What extra work does the plugin do that makes it so much slower than git?

@23tux
Copy link

@23tux 23tux commented May 16, 2021

Same issue here! I've configured obsidian-git to push changes every 5 minutes, so the lagging / freezing becomes REALLY annoying.

@broven
Copy link

@broven broven commented May 25, 2021

Same issue

@dsteinbock
Copy link

@dsteinbock dsteinbock commented Jun 3, 2021

Can we rename this issue "Abnormally high CPU usage" or something similar.

Same issue, but some more details. When Obsidian Git is running, the Obsidian process spikes to 90-100% CPU usage for ~30 seconds. Obsidian Git plugin settings also spikes the CPU. For example, I'm experiencing the following:

  1. Open Obsidian Settings
  2. Click on plugin options for plugins other than Obsidian Git. UI is fast.
  3. Click on plugin options for Obsidian Git. UI freezes for 5 seconds before settings appear.

Same thing happens when I toggle off Obsidian Git under Community Plugins and toggle it on. UI freezes for 5 seconds before the toggle turns on.

What OS are y'all running? I didn't notice this until after I upgraded from MacOS Catalina to Big Sur last week. Not sure if that's a coincidence.

@MrVPlusOne
Copy link

@MrVPlusOne MrVPlusOne commented Jun 4, 2021

Actually, I think this issue was greatly improved after I upgraded my Obsidian and the plugin to the newest version. Maybe you can try to upgrade your Obsidian under the "Options -> About" tab.

The plugin still frees my UI for ~5 seconds, but it's much faster than before (~30 sec).

@akselw
Copy link

@akselw akselw commented Jun 4, 2021

I have the same issue, and I experience it on both my Mac running Catalina and my Mac running Big Sur. I just noticed that Ben Hong had the same issue on his live stream a couple of days ago. You can see it, and he points it out, at the 32:30 mark here: https://www.twitch.tv/videos/1044660956?t=0h32m30s

@lkhphuc lkhphuc changed the title Run on background process. [Feature Request] Run on background process. / [Bug] UI freeze when run. Jun 5, 2021
@lkhphuc
Copy link
Author

@lkhphuc lkhphuc commented Jun 5, 2021

I updated the issue's name to reflect two side of this issue.

@gabros20
Copy link

@gabros20 gabros20 commented Jun 11, 2021

I have the same issue on Big Sur. Freezes the UI until the commit runs for 10-15 seconds. Recently I've updated Mac OS High Sierra to Big Sure and thats when I noticed the issue straight after.

@dwSun
Copy link

@dwSun dwSun commented Jul 1, 2021

Same issue,
Big Sur 11.4
Obsidian v0.12.5
Obsidian Git 1.9.2

I have 1625 files, most are pdfs, all those files take 1.7GB on my disk.

UI freezes for 10~15 seconds when starting up or pushing to github.

image

@MrModest
Copy link

@MrModest MrModest commented Jul 21, 2021

same issue. and it's only on mac. on Windows 10 works fine, but on Mac freezing even I open setting page for plugin

Freeze when I run from command panele "Commit all changes" and when I open plugin options for this plugin. When I open plugin options for other plugins it works fine

@prakar
Copy link

@prakar prakar commented Jul 23, 2021

NOTE: This would be a great plugin if only it worked for me. Kudos to the developer..I shall await this issue to be fixed. Somehow.

Same issue. When the plugin is enabled, CPU maxes out and Obsidian can't be used. Every click takes a long time to process.

On OSX 10.11.8 El Capitan

Screen Shot 2021-07-23 at 6 09 27 PM
Screen Shot 2021-07-23 at 6 08 24 PM

@ronilaukkarinen
Copy link
Contributor

@ronilaukkarinen ronilaukkarinen commented Aug 3, 2021

Yeah this happens for me as well on macOS (Big Sur). On Windows 10 I have no issues.

@Vinzent03
Copy link
Collaborator

@Vinzent03 Vinzent03 commented Aug 22, 2021

I am only on Linux and Windows and I think you are all macOS users right? It's hard to reproduce for me. I think the problem must be somewhere else. I don't know if running it in a different process is the right way and would even fix it.

@MrModest
Copy link

@MrModest MrModest commented Aug 22, 2021

@Vinzent03 can I help you get some logs for diagnose problem?

@MrModest
Copy link

@MrModest MrModest commented Aug 22, 2021

think the problem must be somewhere else.

but it reproduce only for this plugin.

@MrModest
Copy link

@MrModest MrModest commented Aug 22, 2021

Screen.Recording.2021-08-22.at.18.00.15.mov

@MrModest
Copy link

@MrModest MrModest commented Aug 22, 2021

What common have launch settings page and commit? May be it relate with git library? On mac git require Xcode
May be some problem relate with that.

@Vinzent03
Copy link
Collaborator

@Vinzent03 Vinzent03 commented Aug 24, 2021

I think the root of the issue is either the communication of simple-git(external library to communicate with local git installation) with git or a wrong/bad git installation. I am not sure what further details you could provide me.

@MrModest
Copy link

@MrModest MrModest commented Aug 24, 2021

@Vinzent03 may be you can add some verbose logs for localize the problem, and I will run this and give this logs for you.
For understanding, freeze happens inside lib method or your code. May it some concrete freeze method and you can find alternative.

Your plugin is very comfortable. It would be great continue use it on Mac.

If we can find concrete method of lib, we can create an issue to lib's devs)

@Vinzent03
Copy link
Collaborator

@Vinzent03 Vinzent03 commented Aug 25, 2021

@MrModest Here is a new main.js in the zip. Place it in <vault>.obsidian/plugins/obsidian-git. It adds some logs for pulling and opening the settings pane. Maybe you can tell me the time difference between each log. (Logs can be seen by opening the console: CTRL + SHIFT + I)
main.zip

@MrModest
Copy link

@MrModest MrModest commented Aug 27, 2021

@Vinzent03

<pause> means UI freeze about 1 second

When open plugin’s setting window:

Start getting branch info
simpleGit.ts:111 Get git status for branch info
<pause>
simpleGit.ts:115 Get branch info

When run command “Pull from remote”:

Start pulling
<pause>
main.ts:345 git obsidian message: Everything is up-to-date
main.ts:187 Get git status after pull
main.ts:194 Finish pull

When run command: “Create backup"

<pause>
git obsidian message: Committed 1 files
<pause>
simpleGit.ts:111 Get git status for branch info
<pause>
simpleGit.ts:115 Get branch info
<pause>
main.ts:345 git obsidian message: Pushed 1 files to remote

@Vinzent03
Copy link
Collaborator

@Vinzent03 Vinzent03 commented Aug 30, 2021

Sorry for late response. Seems like every communication with simpe-git/local git installation freezes Obsidian. I don't think I will have the time to put that in another process (if it works at all). Pull requests are welcome 😅

@olearycrew
Copy link

@olearycrew olearycrew commented Sep 8, 2021

I would think the only way around this is to spawn another process - I wonder if that's even possible with the Obsidian plugin infrastructure.

@MrModest
Copy link

@MrModest MrModest commented Sep 9, 2021

Some funny moment.
In Macbook Pro with M1 it still freezing, but now it about a second or a bit smaller instead 2 or more seconds in Intel version :D

@dsteinbock
Copy link

@dsteinbock dsteinbock commented Sep 12, 2021

Not sure it's been said already in this thread: the plugin did not have this behavior in the past, on MacOS. So either a change to Obsidian or a change to the plugin introduced this issue. Has that breaking change been tracked down?

@warrenalphonso
Copy link

@warrenalphonso warrenalphonso commented Sep 12, 2021

@dsteinbock Do you remember roughly how long ago it worked fine? Maybe try a past release around then and see if it persists? https://github.com/denolehov/obsidian-git/tags

@KierenB
Copy link

@KierenB KierenB commented Sep 16, 2021

I've also been having this issue (Intel Mac, plugin version 1.11), for me the pause is 6-7sec so really uncomfortable in terms of blocking note-taking at important times. For the time being I've gone back to the background task of uploading to GitHub as described here: https://medium.com/analytics-vidhya/how-i-put-my-mind-under-version-control-24caea37b8a5

kudos to @Vinzent03 for an excellent plugin, hopefully someone with more skill than me can help him with a solution 😅

@davecan
Copy link

@davecan davecan commented Sep 26, 2021

Confirming same issue here. Freeze is about 40-50 seconds so I've had to set the sync to 180 minutes just to make it tolerable. Preferably it would sync much sooner than that.

macOS Big Sur 11.6, Obsidian v0.12.15, git version 2.32.

This has been occurring for "a while" though I can't put my finger on specifically when it started becoming a problem. It's been at least a couple months I would think. I upgraded to Big Sur in May and to the current OS version last week, so those don't seem to be directly related. Obsidian is set to auto-update.

Interesting to note that I currently have 3 instances of Obsidian open, each pointing to a separate vault, and they have been open for multiple days. I also have it set to pull before push and to show the status bar updates.

I closed all of them, forced a restart of Obsidian, and tried changing a couple of settings.

  • Turned off pull before push, lag is reduced only a bit. And even though the status bar says the operation is complete and the UI responds, the UI is still extremely slow in opening the settings once a push occurs.

  • Then turned off the status bar updates and it is still lagging.

After the second change, measuring the time from initiation of the commit to the time when the note screen is responsive again is 32 seconds. But when I immediately open the settings screen right after the popup message says the git operation is complete the UI still lags until nearly 45 seconds (total) before the settings UI is usable.

Interestingly, the status bar says it is now 4 minutes since the last git update, and when I just reopened the settings screen it once again lagged for about 10 seconds before even displaying the screen. The Obsidian Helper (Renderer) process spiked the CPU as described by others.

I did have the git plugin configured to run every 1 minute for the tests I described above so it appears there is some interaction happening here that is causing effects that persist beyond the execution of the plugin itself.

When I switched the plugin back to 180 minute intervals and then terminated the entire Obsidian process and restarted it with a single vault, the expected smooth fluid operations returned, no noticeable lag in usage.

@dsteinbock
Copy link

@dsteinbock dsteinbock commented Sep 26, 2021

@dsteinbock Do you remember roughly how long ago it worked fine? Maybe try a past release around then and see if it persists?

Well the issue was first reported by @lkhphuc on April 21. I remember dealing with the lag for weeks — thinking it was an Obsidian bug that would get fixed — until I traced it to this plugin.

So we should try testing old versions of Obsidian w/ old versions of obsidian-git to backtrace.

e.g.
Obsidian release from March 21: https://github.com/obsidianmd/obsidian-releases/releases/tag/v0.11.9
obsidian-git from March 17: https://github.com/denolehov/obsidian-git/releases/tag/1.6.1

Try to find a past version combo that doesn't exhibit this bug. Then work forward in time from there.

other Obsidian releases:
https://github.com/obsidianmd/obsidian-releases/releases?after=v0.11.11

other obsidian-git releases:
https://github.com/denolehov/obsidian-git/releases?after=1.9.0

@miluoshi
Copy link

@miluoshi miluoshi commented Sep 29, 2021

This happens to me as well.

I've tried debugging this issue with Chrome DevTools.

While the backup task is running there are multiple ChildProcess.spawn commands being run by simple-git library, each spawn taking ~3s to finish and each blocking UI thread.

image

Googling directed me to issue in electron repo, that seems to be related to this issue.

Other possibly related issues:

From the above discussions it is apparent that the issue occurs in newer versions of MacOS Big Sur.

Recap of the bug with a timeline: electron/electron#26143 (comment)

My system:

  • OS: MacOS Big Sur 11.6
  • Obsidian: v0.12.15 (Electron v12.0.18)
  • Obsidian Git: v1.13.0

@23tux
Copy link

@23tux 23tux commented Dec 6, 2021

Is there any news on this? I've increased the committing interval to 1h, but it would be nice to have a more fine grained history about my edits

@kmf
Copy link

@kmf kmf commented Jan 11, 2022

Not sure if it's related, I have/had the same issue,
I have Homebrew installed, and was using the updated git that shipped with it

git 2.34.1

I did a simple

brew unlink git
Unlinking /usr/local/Cellar/git/2.34.1... 213 symlinks removed.

When I then ran

git --version
git version 2.32.0 (Apple Git-132)

Related Link: https://www.jeffgeerling.com/comment/17150#comment-17150

My system:

  • OS: MacOS Monterey 12.2
  • Obsidian: v0.13.19
  • Obsidian Git: v1.20.0

@aoxuely
Copy link

@aoxuely aoxuely commented Jan 23, 2022

I have the same issue,but I founded that while obsidian doing backup works,the cpu also cost much,and the ui freezes long time
image

OS: macOS (Big Sur) 11.6

@RumiAllbert
Copy link

@RumiAllbert RumiAllbert commented Feb 2, 2022

My solution to this was to simply write a contab to run git every x number of minutes. I love the plugin but will have to wait until there is a fix.

@miluoshi
Copy link

@miluoshi miluoshi commented Feb 2, 2022

Today I was prototyping an idea that could partially solve this freezing issue and it seems it might work.

I was thinking it would be great if the plugin did auto backups only when Obsidian window is in background (not focused).
It would be much less annoying if auto backup were the freezes happening only when I am not currently using Obsidian.

It can be implemented using blur and focus events on window. For tabbing between fullscreen apps also visibilitychange event works.
Auto backups would run only X minutes after blur and on focus the timer would be cancelled. What do you think?

Pseudo code:

const backgroundBackupTimeout = 1000 * 60 * X; // X minutes
let timerId;

window.addEventListener('blur', () => {
  timerId = setTimeout(() => {
    // do backup
  }, backgroundBackupTimeout);
});

window.addEventListener('focus', () => {
  if (timerId) {
    clearTimeout(timerId);
    timerId = undefined;
  }
});

@davecan
Copy link

@davecan davecan commented Feb 2, 2022

Speaking only for myself I think this could be a great thing to try. I typically leave obsidian open most of the time and it is idle in the background most of that time so that would be a good UX experience for me.

I'm assuming the option to display a notification when the plugin starts would still work, so if a user unblurs the app while it is executing they would see the notice explaining why it is temporarily sluggish?

@wesmoncrief
Copy link

@wesmoncrief wesmoncrief commented Feb 24, 2022

I would also really appreciate the background solution.

In particular, I often open Obsidian in the middle of a meeting to quickly jot something down, and having it hang for the first ~5+ seconds is pretty annoying.

@Vinzent03 would you be open to a PR that does something along the lines of what @miluoshi suggested?

@miluoshi
Copy link

@miluoshi miluoshi commented Feb 24, 2022

I've created a PR with suggested feature above #188

@tht
Copy link

@tht tht commented Feb 24, 2022

@miluoshi: Thanks a lot… I've just installed it manually in my Obsidian and will report back if there are any issues.

@miluoshi
Copy link

@miluoshi miluoshi commented Feb 24, 2022

@miluoshi: Thanks a lot… I've just installed it manually in my Obsidian and will report back if there are any issues.

Thank you! It definitely needs some testing, because I might have missed some edge cases.

@tht
Copy link

@tht tht commented Feb 26, 2022

For me it is not working at all. It completely stopped committing and pushing (haven't checked pulling). Window was inactive for hours today but it did not push the local changes.
image

@miluoshi
Copy link

@miluoshi miluoshi commented Mar 3, 2022

For me it is not working at all. It completely stopped committing and pushing (haven't checked pulling). Window was inactive for hours today but it did not push the local changes.

@tht thanks for testing. I'll get back to it this weekend.

@miluoshi
Copy link

@miluoshi miluoshi commented Mar 3, 2022

Notice that fix for the original bug with freezing in libuv was merged yesterday and we're waiting for Electron to merge this fix and release updated version: electron/electron#26143 (comment)

@samuelskeirik
Copy link

@samuelskeirik samuelskeirik commented Mar 18, 2022

After Electron merges this fix, will we have to wait on Obsidian to also update? Or will that fix in Electron propagate down to Obsidian?

Sorry, I am not a programmer by trade. I've just been learning bits and pieces here and there because of Obsidian.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet