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

Obsidian mobile support #57

Closed
Vinzent03 opened this issue Mar 22, 2021 · 131 comments
Closed

Obsidian mobile support #57

Vinzent03 opened this issue Mar 22, 2021 · 131 comments

Comments

@Vinzent03
Copy link
Collaborator

Because you cannot install git on Android/iOS the plugin has to include git in itself.
Maybe the npm package isomorphic-git is the solution.

@xeor

This comment has been minimized.

@kalitara
Copy link

kalitara commented Apr 4, 2021

I'm using termux on Android.
https://www.techrepublic.com/article/how-to-install-git-on-android/

Maybe there is a gateway to send shell commands to termux?

I don't have access to Obsidian mobile so I currently use Markor when I want to do some writing on the phone.

@renehernandez

This comment has been minimized.

@denolehov

This comment has been minimized.

@renehernandez

This comment has been minimized.

@denolehov

This comment has been minimized.

@Vinzent03 Vinzent03 pinned this issue Apr 11, 2021
@Vinzent03
Copy link
Collaborator Author

Vinzent03 commented Apr 11, 2021

Status update

I decided to use isomorphic-git, which is a "rewritten" git in javascript. Sadly it brings some problems:

The CORS problem is a real problem, because pulling/pushing does not work. It would need a proxy server, which is not very secure. The Obsidian devs have a method to fix CORS, but that's currently not exposed and does not support all features that are needed to push/pull. They have to improve and expose it.

Sadly they have more urgent things to do, so it's not high priority on their list.

@renehernandez

This comment has been minimized.

@Vinzent03
Copy link
Collaborator Author

Vinzent03 commented Apr 13, 2021

I am really not happy with this situation, but even the Obsidian dev @lishid said that there is most likely no way for the plugin to fix this without a Server. (Discord message)

I guess I will work on the mobile version (since there is a lot to do), but I won't be able to publish/finish it while this API is not available. I have no clue, when this will be.

Maybe I will publish a version where the user has to insert a proxy server url. So the user can decide over his data.

@Vinzent03
Copy link
Collaborator Author

Vinzent03 commented Apr 15, 2021

In addition, I don't own a Catalyst license, so I cannot test it on mobile.
I got sponsored, so I can now test myself on mobile.

@Vinzent03
Copy link
Collaborator Author

Vinzent03 commented Apr 20, 2021

I did some huge progress on the pr #66 . Sadly there is a big problem with the file system. I have to customize and proxy the Obsidian adapter. At the moment, the method stat() is still missing on it but thanks to the Obsidian devs, because they are exposing it in the next insider mobile release.
I can't promise it will work, but I hope so. 😉

@ryanpcmcquen

This comment has been minimized.

@quintrino

This comment has been minimized.

@ryanpcmcquen

This comment has been minimized.

@quintrino

This comment has been minimized.

@bppdddqqqq
Copy link

I think a much much much more wiser option would've been to use WASM and just transpile official implementation of libgit. I am not quite sure on the extent this kind of dogfuckery would've taken to do it, but probably much lesser evil than using an implementation of git, that's meant to be ran in web browsers with localStorages n shit

@prashant2402
Copy link

prashant2402 commented Jun 26, 2021

@Vinzent03 thanks first of all for giving us this amazing plugin, it worked flawlessly in Windows 10.
Before coming across this plugin I've had similar idea of using git as backend vault and created shell scripts to sync git and scheduled cron jobs.
I use 3 different devices (work windows 10, personal linux (arch linux) and Android). my approach worked great until I struggled with merge conflicts when I had changes in same lines etc. then found your plugin.
I use termux on android, setting up git and cron in termux is no different. surprised that you didn't make use of it to offer Android support. Cant comment on Ios as I don't have knowledge

@douglasg14b

This comment has been minimized.

@Vinzent03
Copy link
Collaborator Author

Status Update

Hey I am still alive. I did nothing regarding this issue the last months, because of some frustration. 😅😅 My implementation is mostly done. But I have huge doubt that I will ever be able to publish the update. It was a horrible journey with isomorphic-git and the restrictions on mobile (such as CORS). Now that everything works. There is still a huge problem:

Performance

  • In a repo with 2 commits with 1000 50 lines long txt files and a 10mb pdf it takes 110 seconds to display the changed files modal.
  • In my repo for school notes with many pdfs the app crashes when cloning, because of out of memory.

I doubt that my implementation is the problem. I think isomorphic-git doesn't work well with the limited resources on mobile.
It may work in small repos, but I don't want to publish a plugin which crashes Obsidian.

I am happy about any help. Maybe it's my fault after all.

@Duske
Copy link

Duske commented Jul 15, 2021

First, thank you for the update and your work on this! 🚀
If performance is the issue right now, would it be possible to switch to https://www.nodegit.org/ or the WASM approach? Regarding the first option, I am not sure how the app for mobile is actually built and if it is possible to require node libraries, not just browser ones.

@Vinzent03
Copy link
Collaborator Author

That's the problem. You can't use node libraries on mobile.

@vanadium23
Copy link

@Vinzent03 where can we read about limitation for mobile libraries in obsidian?

@Vinzent03
Copy link
Collaborator Author

As long as you don't use any 1) NodeJS modules via require or import, 2) Electron modules via require('electron'), or 3) Vault.adapter, or 4) CodeMirror 5 API, your plugin should work

https://discord.com/channels/686053708261228577/707816848615407697/823558775943331850
That's an answer from Licat(Developer of Obsidian) — 22.03.2021.
But I think point 3 with Vault.adapter is wrong, because that's possible.

@lishid
Copy link

lishid commented Jul 15, 2021

But I think point 3 with Vault.adapter is wrong, because that's possible.

I meant using FileSystemAdapter, and associated internals like basePath, etc.


I have a workaround for the CORS issue coming soon in the API. I guess this doesn't really help with the memory or speed issues though.

@wyatt
Copy link

wyatt commented Jul 15, 2021

Just a quick workaround for anyone who needs Git syncing with Obsidian (iOS only) (note this is not ideal, but can work as a good stop-gap imo):

  • Download and setup a vault in the Obsidian mobile app. Don't sync it with iCloud
  • Download Working Copy (There are alternatives for Android, but I haven't tried them)
  • Add your GitHub account in the setup pages
  • Click the + icon and select "Setup synced directory"
  • Commit all recent changes (i.e. the .obsidian folder and some other misc files)
  • Add your git repository as a remote, make sure you choose to sync via SSH
  • Click the fingerprint icon and under the name of your remote select Pull.

This process can be automated at intervals with Apple Shortcuts.

Hope this can help someone :)

Thanks to @Vinzent03 for all the work being put into this, and hopefully we'll have a more cohesive experience in the future

@vanadium23
Copy link

For Android you can use termux, and follow this guide:
https://renerocks.ai/blog/obsidian-encrypted-github-android/

@steven-kraft
Copy link

It should probably be mentioned that Working Copy costs $19.99 to use. The only alternative I could find was Polygit for $2/mo or $10/year.

@eleanorkonik
Copy link

For what it's worth, this is apparently a free iOS method: https://forum.obsidian.md/t/mobile-sync-with-git-on-ios-for-free-using-ish/

@wedgen
Copy link

wedgen commented May 27, 2022

An Android workaround I haven't seen mentioned is MGit.

I've only started using it but it seems to work well enough.

I had issues with mgit, i ended up buying pocketgit, that works pretty well. Easier to manage your commits. But I did have some success with mgit. Its just another step I would like to avoid.

@pulinagrawal
Copy link

pulinagrawal commented Jun 11, 2022

It seems the problem is pretty much solved for iOS users.

https://forum.obsidian.md/t/mobile-setting-up-ios-git-based-syncing-with-mobile-app-using-working-copy/16499

IOS + "working copy" is working for me, at least for 2 minutes

Here is my solution for Android users. I have been using this very successfully for multiple months now. Everything stays in sync and my life is good!!

https://pulinagrawal.github.io/Obsidian-Sync-Alternative

@CypherpunkSamurai
Copy link

CypherpunkSamurai commented Jun 11, 2022

I also use Dropbox and One drive sync plugin now. It's great, and I no longer require git based solution.

That being said, I'm also looking forward to forking MGit in my free time and working something out with intents. possibly I can extend MGit to run commit and push from external intents. The obsidian part I'm not sure.

@Vinzent03
Copy link
Collaborator Author

Vinzent03 commented Aug 13, 2022

I think I have something interesting to share with you. I finally got time and motivation 😄 to work on a mobile version. It's still in beta, but you can try it out by following this README. Please tell me if you encounter any issues.

@mathisgauthey
Copy link

Hi there, I created a guide on how to use Termux on Android the simple way with a widget and an automatic sync setup. It is available on Reddit, hope it'll help.

@HybridRbt
Copy link

I think I have something interesting to share with you. I finally got time and motivation 😄 to work on a mobile version. It's still in beta, but you can try it out by following this README. Please tell me if you encounter any issues.

Exciting news! Currently testing this plugin, but cannot move beyond the setup stage. When I was asked if I have an .obsidian folder in my remote repo, I've chosen yes and chose to delete all my local configs, and then the clone was aborted immediately. Does this mean that I have to delete all my local config folders BEFORE cloning? Don't how to do that though, since every time Obsidian launches it will always create a new config folder, isn't it?

@Vinzent03
Copy link
Collaborator Author

@HybridRbt Thanks for the feedback. Should be fixed in 1.1.9

@dsr432

This comment was marked as resolved.

@Vinzent03

This comment was marked as resolved.

@dsr432

This comment was marked as resolved.

@Vinzent03

This comment was marked as resolved.

@dsr432

This comment was marked as resolved.

@Vinzent03

This comment was marked as resolved.

@dsr432

This comment was marked as resolved.

@Vinzent03

This comment was marked as resolved.

@dsr432

This comment was marked as resolved.

@Vinzent03

This comment was marked as resolved.

@HybridRbt
Copy link

@HybridRbt Thanks for the feedback. Should be fixed in 1.1.9

I have updated and tested it again, and indeed it now starts to clone successfully. But I don't know if it's due to my outdated hardware (iPhone X) or something else, it can never finish the clone: a few minutes after the clone starts, Obsidian will crash.

I have plugged it in and turned off automatic screen lock so the app is always on.

@Vinzent03
Copy link
Collaborator Author

@HybridRbt I'm really sorry, but your repo is too big then. It crashes, because of an out of memory error, and there's nothing I can do to fix this. May I ask how big it is as listed here

@HybridRbt
Copy link

@Vinzent03 yes, I think you are right. I checked the size of my repo and it's nearly 500MB. Is there a way to make it sync slower and use less memory? I think this only happens for the initial clone, am I right? if this is the case, I can leave it syncing for, say, an hour or so

@Vinzent03
Copy link
Collaborator Author

@HybridRbt I don't know yet why running status for listing changed files takes so long. I don't know how big the impact of bigger files is, or only the amount of files matters. You could clone it on a different device and move the directory to your mobile device.

@ddelange
Copy link

My current workaround: edit in Obsidian for Android, then open GitJournal to sync the workspace manually

@Columpio
Copy link

Columpio commented Sep 3, 2022

@Vinzent03
Can merging with conflicts be fixed now?
They have already fixed it in isomorphic git:
isomorphic-git/isomorphic-git#841

@Columpio
Copy link

Columpio commented Sep 3, 2022

What should one do in case of merge conflicts?

@HybridRbt
Copy link

HybridRbt commented Sep 4, 2022

@HybridRbt I don't know yet why running status for listing changed files takes so long. I don't know how big the impact of bigger files is, or only the amount of files matters. You could clone it on a different device and move the directory to your mobile device.

Thanks! So I've done another round of tests using your suggested method. Strangely, I cannot just copy the folder from my mac to my iPhone, it always stuck at around 28 MB. So I have turned on the core sync plugin, and used it to perform an initial sync. But even after this, the backup process still failed. It always stuck in "initializing fetch" or "getting status".

@Vinzent03
Copy link
Collaborator Author

@Columpio Merge conflicts should be supported. What happens for your when you get a merge conflict?
@HybridRbt I guess you have too many files then.

I'm locking the issue now. Please create a new issue or discussion for bugs or feature requests.

Repository owner locked as too heated and limited conversation to collaborators Sep 5, 2022
GollyTicker pushed a commit to GollyTicker/obsidian-git that referenced this issue Sep 6, 2022
@Vinzent03 Vinzent03 unpinned this issue Nov 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests