Make Obsidian Sync work in background (on Mobile)

I’m not familiar with the details, but I think it has to do with what Apple allows apps to do in the background. AFAIK, since Obsidian uses Capacitor to build the mobile app, it would need to use web frameworks/services in the background in order to sync things in the background, and Apple currently disallows those frameworks from running in the background (and offers no way for the user to say “it’s cool I accept the risk/battery drain/whatever”).

It would be cool if Apple was less paternalistic about iOS. Alas.

5 Likes

Crap— of course. I knew Obsidian wasn’t native, but that implication didn’t occur to me. Thanks for the detail. I did a little digging just now, and it looks like there’s a plugin that might provide a way around that. It lets Capacitor apps run OS-native background tasks. Do you know if anyone at Obsidian has tried that?

I hope I’m not coming off as a backseat driver. :joy: Obsidian has been a game-changer for me, and this has been the only major hitch. If we know the Capacitor plugin won’t work, I need to see if I can find another creative solution. I have some ideas, but I don’t want to try something that the experts already know won’t work.

2 Likes

The team’s aware of Background Runner but it doesn’t solve all of the issues, regrettably. Open to other ideas as there’s always a chance we haven’t thought of it!

5 Likes

Thanks! That’s great to know. I’ll have to do some digging to see if my other idea has any merit. Cheers!

1 Like

I think this isn’t really viable but just dropping it here in case it could be relevant:

My hacky solution of playing a 10 hour silent audio file still works (as long as I don’t play other audio (spotify, youtube…) in between.
Note: only if the note that contains the audio file is in live preview, not reading view.
If the audio file in Obsidian would continue playing after the other audio source stops, that would be great - but technically not possible I guess.

I’m not sure which kinds of background processes prevent an app from being killed, but audio is one, and I guess location (e.g. Google Maps navigation) is another. I wonder if a plug-in that does constant location tracking as in a google maps navigation would keep Obsidian backgrounded. That could be a community plugin for those of us that want Obs backgrounded all the time.

4 Likes

I want to support the obsidian team because I love the product, and sync works GREAT for syncing my vault between computers, but it is very jarring to open up the mobile app, wait a few seconds for everything to load, and then wait again for files to update to their latest version from the cloud sync. Especially jarring with the daily note that gets opened by default.

It’s unfortunate that I can get a better user experience on Android using a third party syncing tool like Dropbox which does sync in the background.

4 Likes

There’s been a lot of discussion here about iOS. I’m on Android, and I’d be very interested on whether there’s the same limitations there. As I understand it there’s some existing capacity to function in the background on Android (I’m assuming so, as Syncthing does it at the cost of a constant notification telling me that it’s running in the background). Is it at all possible to implement this for Android users? I love Obsidian and want to support it, but it’s disappointing to see that the third party Syncthing solution is actually far more usable in this area.

Please let me know if there’s a better spot to be asking this, or whether this should be fielded as a separate feature request. Thank you!

+1 for iOS. I don’t know if it is better to reply here or create a new topic dedicated to iOS, it is my first post, so please be patient with me ;). I use Obsidian daily on Mac OS but not very often on mobile because

  1. Each time I want to send a piece of text or edit I need to wait for iCloud to synch (“Waiting for iCloud to synchronize Obsidian configuration files…”)
  2. it takes 1 to 5 minutes (sometimes more)
  3. On mobile the idea is to send a quick note to work on it later in desktop mode

So here is my question/suggestion :
On iOS you can decide to activate background updates for any application (if the feature is implemented) but I did not see the choice in iOS for Obsidian (Settings > General > Background App Refresh).
Could you add this feature for iOS: activate background Refresh ?

3 Likes

Thank you for the information. But what is the situation for Android? I am using Android, but I am not sure if there is background synchronization.

I don’t know anything about Android except that you should be able to keep apps open in the background:

https://www.androidpolice.com/prevent-apps-from-sleeping-in-the-background-on-android/

1 Like

Thank you for your response. However, being able to run an application in the background is different from the application having the ability to synchronize in the background. For example, I was using Joplin until recently, and Joplin did not have a background synchronization feature. It required keeping the phone screen on for synchronization, and there were even recommendations for specific apps for this purpose. I’m wondering if Obsidian has a similar situation.

I’m not a iOS developer but running in background means also receiving data. For instance, I have some apps syncing with feedly, for my rss sources, that sync in background, and fetch web content at same time, but the frequency depends from iOS and I know that there are some limitation but I don’t know which they are (in terms of computation time/data transferred in background).

I assume the average user would be ok if everythign needs to sync upon opening Obsidian. The waiting time until Obsidian opens is the annoying thing.
Over time it conditions you to use another app for quickly jotting something down, because 15s to a minute wait time is something most people are unwilling to invest for quickly jotting down a thought.

1 Like

In my understanding, on mobile you cannot put application in background “as a whole”, as you do, for instance in Windows or macOS, since they will be suspended and they cannot be updated if you don’t declare and define a background task.

This task will be the part that could run in background, fetching data from internet and executing computation.

Since the task doesn’t run all the time but it is triggered with a frequency that depends from a lot of factors (like battery level, WiFi availability, previous executions, etc…) it could happen that you could open obsidian and the data inside has still to be aligned, since you did an update on another device in the time between two updates.

Anyway, declaring a background task for sync could be helpful to reduce the update time on opening since the refresh should involve only the very last data, instead of the whole package even if it could not remove the need of a sync “on start”.

I let skilled iOS devs to correct me. As I said, I’m not a developer but I just read some parts of the technical documentation so my understanding could be wrong.

1 Like

+1 for iOS

1 Like

Yes please, also for iOS.

1 Like

I’m going to call baloney on blaming iOS/iPadOS for the protracted syncimg issues, background syncing issues, startup issues, etc. I have way too many other apps that do not have this issue.

There are fundamental assumptions being made by the Obsidian developers that are probably only partially correct, and they can’t see it likely because of their own unconscious bias and maybe some lack of experience, idk.

I am a software engineer with mobile and large enterprise system design, architecture, blah blah blah experience. I’ve had to solve this problem over and over again, most of the time because a software developer doesn’t know how to do incremental syncing on disconnected devices when metadata and indexes are involved.

The first thing to solve: load the UI in its last known state and assume statelessness, meaning be skeptical of the the local files state. Allow the user to use the app while you sync in the background. Since Obsidian was built on Node.js and Electron. Electron has a small flaw on iOS and iPadOS… where to store volatile metadata files like the indexes, file lists, etc. Because the developers have chosen to store them on the .obsidian directory instead of the default location iOS and iPadOS expects, the developers are subject to iOS/iPadOS offloading the core files of the app. It appears, with Obsidian Sync they are trying to handle this more elegantly, but they are still putting synchronization as a foreground process even while Node.js and Electron allows this to be a background process called asynchronous communication using async, promise, and callbacks. There is also a collection of design patterns in software engineering for distributed systems that should be used but seems like they aren’t. This is a pretty common skills development problem in software development because front-end/UI developers using don’t have the same skills as a back-end developer developers, and people that claim to be a full-stack developer (front-end and back-end) usually are a master of neither. Nor can they be. This stuff is just too complex to really master both. So while this post could be read as an indictment against the software developers at Obsidian, I think it is more likely an indictment against the management’s understanding of the different skill sets (and different people) needed to build a robust distributed application ecosystem.

Or I could just be wrong and something else is going on.

The fact that there are so many other commercial distributed apps built with Electron and Node.js that sync just fine points towards design decisions and lack of skills by the development staff at Obsidian. (Cough. Notion. Cough.)

The old saying is, “Engineers are great at not planning for the success of their products. We struggle scaling beyond our initial design.”

I really think that is the case here.

Hopefully someone at Obsidian reads this and digs into what I’ve said. This app has so much potential but still fells like something just hacked together for their own, initial use case. Often refactoring an app means fundamentally changing the BUSINESS model, what you charge for and what you don’t. I paid for Obsidian Sync and I don’t use it because it stinks and there is no assurance of data privacy or security. That forced me to switch to iCloud sync. And that REALLY doesn’t work. Why? Because I have over 30k notes that are hyperlinked in a knowledge web. Obsidian isn’t designed for that, wasn’t designed for that, and doesn’t seem to be using design patterns that would handle concurrency, supervisor, semaphores, deadlocks, observer/observable state, stateless distributed data accessors, and other challenges that comes with multiple application instances on different platforms being used simultaneously.

2 Likes

This simply isn’t true. Apple has a background process handler. How do you think you get shipping updates for Amazon purchases? Weather alerts?

Just because you don’t know how to do something doesn’t mean it doesn’t exist.

Here are the docs from Apple for how to do it.

1 Like

Push Notifications?

@Azmonial just said that. They’re distinguishing between a backgrounded app and a background task. Re-read.

1 Like

I have 3 devices which I use to access my ObsidianMD vault. I often access these files via iOS shortcuts to quickly add content to my notes. I need a way to trigger the ObsidianMD to silently sync these changes in the background.

Additionally I am not confident in the ObsidianMD merge tool (at least in it’s default configuration) as I have witnessed my data be removed in front on my eyes. Device 1 and Device 2 both made different changes to the same file without syncing. When they resynced, Device 1 was overwritten with Device 2’s changes.

Questions:

If I open the app and return to the homescreen, is that sufficient enough to trigger the syncing to continue while the app is not in the front most view?