Vinzent03 / obsidian-git

Integrate Git version control with automatic backup and other advanced features in Obsidian.md
MIT License
6.82k stars 292 forks source link

[BUG] Backup on Android leads to buffer error #307

Closed 0xShkk closed 2 years ago

0xShkk commented 2 years ago

Hi,

I have a repo which contains a few Pictures. Its about 40 MB in size in total.

The strange thing is that sometimes it works to do a backup so the push completes and everything is completely in snyc.

And then out of nowhere when trying to do a backup it says initializing push and directly after that buffer error.

It's like yesterday evening it is working then the next morning it says buffer error and then few hours later it's working again. Only adding few lines of text between the backup attempts.

Could I debug this somehow or is my repo already too big?

Screenshot_20220909-210547_Obsidian.jpg

Bug is on Android and Plugin version is 2.1.0

Vinzent03 commented 2 years ago

I haven't done much research, but I guess it depends on the available ram on your device. E.g. how many other apps you have opened. 40mb isn't that big. I thought the limit would be higher.

0xShkk commented 2 years ago

Thats a good point. Will try to clean the cache everytime before doing a backup and see how it goes

Vinzent03 commented 2 years ago

Since there isn't really anything, I can do to fix this. I'm closing this now.

sakha002 commented 2 years ago

@Vinzent03 Hi, I am getting same buffer error when attempting to push, and my repo is tiny , the commit said 10 files changed, and device memory is big. I also closed all other apps. Any suggestions on what to do? I hope I can avoid cloning again

0xShkk commented 2 years ago

@Vinzent03 Hi, I am getting same buffer error when attempting to push, and my repo is tiny , the commit said 10 files changed, and device memory is big. I also closed all other apps. Any suggestions on what to do? I hope I can avoid cloning again

Just wait and try again. Its working again after a while but its definately buggy. Sad that this is not investigated any further..

0xShkk commented 2 years ago

Also, clearing cache after getting the error didnt help.

c0deZ3R0 commented 2 years ago

I have the same problem with a small repo. Can't get mobile to sync without buffer error. Have cleared the cache with no luck.

0xShkk commented 2 years ago

@Vinzent03 maybe some advises on one could debug this?

It seems like there are a few people experiencing the issue

0xShkk commented 2 years ago

Or should I open the bug elsewhere?

Any help would be greatly appreciated

Vinzent03 commented 2 years ago

As said before I'm really sorry it's not working on your device, but I think there is nothing I can do. The underlying lib is not very memory saving. I know that's bad for a mobile. plugin, but that's the only way I found to make it work for at least some users.

0xShkk commented 2 years ago

Ok no worries than. It works most of the time though

Thanks for your work and sharing

0xShkk commented 2 years ago

Leaving this here in case someone got the same troubles and looks for a solution.

When you exclude the Obsidian app from memory management in Android settings, the plugin works just fine. I can do this in device management settings but this setting may dependt on the device.

Takaishisama commented 2 years ago

0xShkk

Could you please explain further? Can't seem to find how

blqke commented 2 years ago

@Takaishisama

Succeeded to exclude the app from memory management, it is now working as expected. It depends of your android device, here how you can find the settings screen:

New Project

penfold00 commented 1 year ago

I'm experiencing the same problem with a small vault and small files. I am using a Samsung Galaxy S10, Android 12.

The sync worked 1 or 2 times, now there's a buffer error every time and it's not pushing/pulling. Clearing the app cache didn't help. I checked the memory usage of the app, Android says max usage has been 333 MB, which seems normal. Average usage of 107 MB seems a bit high, but still fine.

I am very confused by the proposed solution by @0xShkk and @blqke. @blqke you are changing the battery usage in your screenshot, which should not have anything to do with memory management?! @0xShkk is that what you meant? I cannot find a setting to change memory usage behaviour of an app.

Also, might the sync of the app settings between PC and Android be a problem? Should these be excluded using .gitignore?

Thanks for your help!

0xShkk commented 1 year ago

@penfold00

I meant exactly this. It may be that this setting can't be found on all devices but just guessing here. For me it still works fine

HarvsG commented 1 year ago

As said before I'm really sorry it's not working on your device, but I think there is nothing I can do. The underlying lib is not very memory saving. I know that's bad for a mobile. plugin, but that's the only way I found to make it work for at least some users.

isomorphic git supports reducing the clone and fetch depth: https://isomorphic-git.org/docs/en/clone You may find this makes things less memory intensive as there is no need to clone the entire git history - particularly if users have accidentally have larger files in their git history

This comment suggests a method of keeping all the clients having a small and efficient git history, however I am not sure if these features are all implemented in these git libraries: https://stackoverflow.com/a/37105443/3562522

Tagging in case closed issue is muted @Vinzent03

Vinzent03 commented 1 year ago

@HarvsG Great idea. Available in v2.17.0

bszewc3203 commented 1 year ago

So it seems this error doesn't have a fix yet which kinda sucks since I have the same problem. Cloning a vault crashes the app. Tried this battery option even though it is strange like the other person said and it didn't work. Also tried turning off every other app that was running.

btmurrell commented 1 year ago

I am having this problem 100% of the time. My repo is only 1.5MB. I am on Android. I have tried the memory and the battery suggestions above with no success.

@Vinzent03, could you share what other configurations or conditions might trigger the "buffer error"? Is there any obsidian-git logging I could capture?

I have searched isomorphic-git for "buffer error" and it does not appear on the web or in the obsidian-git repo.

Thank you!

btmurrell commented 1 year ago

FYI @Vinzent03, and for any others that may land here... For my case, it was a "user shot self in foot", "user solved self" PEBKAC case... I was curious about what other factors might contribute to this error. I can tell you one...

Because of other errors I had experienced, I had removed and re-cloned my repo more than once. In one reconfiguration, I moved my repo to a subfolder of its original location. So, originally my repo was in something like folder-a/notes and I moved it into folder-a/newhome/notes. To do this, I removed my folder-a/notes directory, then re-cloned into folder-a/newhome/notes. MY problem was that I left behind the folder-a/.obsidian directory.... and so, I ended up with two .obsidian folders in a hierarchy... so, as we know, the obsidian-git configs are under the .obsidian/plugins directory... and I assume there is an "up the chain" precedence in obsidian-git and with two conflicting configs, that was the cause of my "buffer error". After removing my parent directory .obsidian folder, my issue was resolved.

MalachiMcIntosh commented 1 year ago

First off thanks to the maintainers for this fantastic plugin. I just wanted to comment for anyone who comes across this issue to say I've found a workaround that is currently working for me (Samsung Galaxy S21, Android 13).

In Settings -> Battery and Device Care -> Memory I increased the RAM Plus (which I assume is swap) to 8GB (seems overkill) and added Obsidian to the "Excluded apps" list. I haven't had any buffer error issues since. Still watching #572 intently though!

Screenshot_20231030_102125_Settings Screenshot_20231030_102137_Device care SmartSelect_20231030_102605_Device care

EDIT: OK, after a few more days I've started getting buffer errors again. So maybe disregard this.

vJourneyman commented 8 months ago

Wondering if people could report the versions of Android, phone, and RAM with their problem. I'm able to do an initial sync from remote repo, but not a backup after making a small change. buffer error

Pixel 5, 8GB RAM, Android 14 with Nov 5, 2023 security patch;

Obsidian maxed out at 3.9 GB of RAM usage.

How to Check RAM on Android 14?

Mick1o commented 6 months ago

I'm having the same problem. I haven't even managed to backup once, not even with trying every suggested method here.

Surprising this hasn't been fixed yet as it seems to be a pretty major issue.

Exanite commented 4 months ago

Also getting this issue. Pixel 4a with 6 GB ram. Obsidian shows as using only 280 MB of ram. I've also set it to unrestricted.

I've had this happen twice. I don't remember what caused the first one, but the second seems to be caused by attempting to pull when the remote contains changes that modify a file that is already locally modified. I tried to discard the change and pull again, but the buffer errors continue to occur.

Deleting the vault and re-cloning the repo has fixed it in both cases for me. Restarting Obsidian doesn't seem to do anything (I haven't tried force killing the app though).