holochain / holochain

The current, performant & industrial strength version of Holochain on Rust.
https://holochain.org
Other
1.14k stars 140 forks source link

[MOBILE] Mobile Support - Global Tracking Issue #3243

Open guillemcordoba opened 5 months ago

guillemcordoba commented 5 months ago

After a full iteration of development + deployment + testing cycle with the rostanga mobile app, I've explored a lot of the territory for running holochain on mobile. Right now I'm actually having to maintain a fork of holochain that stores all data in firebase because of the tx5 PendingJoin bug that is a known issue in 0.3.0. Also this makes me less nervous about holochain processes running into these kinds of issues while running for full days.

Anyway, in my view this is a comprehensive list of the issues that holochain core + its dependencies need to fix before we can say that "holochain supports mobile":

UX issues

Networking

Push Notifications

To achieve push notifications in mobile OSes, we basically need to go through Firebase Cloud Messaging (FCM) and Apple Notification Service (APN). Here I'm assuming tauri as the mobile runtime that holochain is running in.

Android specific issues

iOS specific issues

Precompiled wasms

This is the area that I have explored the least. So I'm not sure this is ready to go as it is in the code. I do now that @Connoropolous played a big role in the implementation of prepackaged wasms in iOS, so I'll let him comment if he sees fit to do so. But at least we need a:

Interpreted wasms

AFAIK, iOS has as a rule that you can't execute or JIT compile anything that wasn't prepackaged as part of your iOS app at compile time.

Note: be careful, as apple actually lets you do things when developing with xcode that then you can't do when publishing an app to the appstore. In my development, holochain worked fine by JIT compiling the wasms, but that stopped working only when I build the "production" app build and downloaded it to the appstore.

wasmer supports a bunch of JIT compile engines, one of them is JavascriptCore which uses the underlying OS based JIT, but in which apple have dropped support for webassembly and will not be bringing it back. I've done some research and wasmer had a vote around implementing more backends, one of which is wasmi, which is a wasm interpreter. They could also implement something like a bridge to WKWebView which does seem to have native WebAssembly support in iOS, but I haven't seem any mention of that in any of their repositories or docs.

With all of this, we are left with no path to implement a runtime like we, neighborhoods or the launcher in iOS. These are runtimes that don't prepackage all installable apps in them, but rather they download them from the internet and install them dynamically in the conductor. I certainly want to enable these kinds of use cases, but it seems like without a big effort they are not possible with the current state of things.

The solutions that I can see are:

All of these seem like a big lift, but this seems crucially important. @thedavidmeister am I missing something in this territory?

I'd be really interested in talking about more options in this territory.


I'll try to keep this issue up to date with all the fixes and developments so that we have an overall view of the state of affairs.

Connoropolous commented 5 months ago

hiyas... this line explains a bit about how the precompiled thing worked, but I have no idea anymore about how wasmer has moved. https://github.com/holochain/holochain/blob/194bc259a4d683d83e4953bb24bf5e6e8b7294fe/CHANGELOG.md?plain=1#L2116

There was the additional step that during the Dna read phase you needed to translate the dylib "paths" and read in the bytes. That's in a private repo.

guillemcordoba commented 5 months ago

@Connoropolous thanks! did you need to package your dylib deserialized wasms into iOS frameworks for it to work?

Connoropolous commented 5 months ago

I needed to have those dylib files sitting in the Xcode project folder and make sure they were included on the bundle of things that got codesigned during the app build process. I also needed to develop by testing and running on a hardware device, no simulator.

guillemcordoba commented 5 months ago

That's really helpful @Connoropolous , thanks!

abe-njama commented 5 months ago

@guillemcordoba what's this Tx5 PendingJoin known issue? Could you be referring to the performance issue on Android 33?

guillemcordoba commented 5 months ago

Oh sorry, it's not really tx5 as I got yesterday, it's the issue that @maackle is referring to here, that makes 0.3.x not viable right now, because when you enable the app is app is not enabled and stays in paused mode with PendingJoin as its reason.

maackle commented 5 months ago

FYI https://github.com/holochain/holochain/pull/3221 just merged, removing the network join error

thedavidmeister commented 5 months ago

@guillemcordoba is adding wasmi as an engine really that big of a lift?

i'd expect wasmer to basically work as-is because we'd still be using its interface, with wasmi only implemented "under the hood" of wasmer, right?

guillemcordoba commented 5 months ago

@thedavidmeister I don't think it should be that much of a lift no, and for holochain I think that would be the ideal, since then from holochain's point of view it's still wasmer.

Problem is I haven't seen any movement whatsoever in any wasmer repos/discord/discussions/pullrequests/articles that indicate to me that adding wasmi as an engine is in their backlog. So we'd have to request for that I imagine, and put pressure on it so that it is implemented... And meanwhile we have a bunch of time constraints on our side of needing to build products that work now on iOS (at least this is the situation that I'm in right now).

thedavidmeister commented 5 months ago

@guillemcordoba hmm, i have no idea what is involved in making an engine or who to talk to about it, do you?

guillemcordoba commented 5 months ago

Nope... No idea, the wasmer repo and discord is the first thing I would try.

jost-s commented 5 months ago

In my experience the wasmer discord server is not attended much. Github issues and discussions have worked for me to get answers from wasmer devs.

abe-njama commented 5 months ago

@guillemcordoba a couple of the PRs that you tagged in the UX issues section have been merged to develop. Relax our notion of "joining the network" - Merged and awaiting a release to 0.3.0-beta-dev.35 There's however a related timeout reduction that's pending merging and release as well that will help improve the app experience

refactor: move wasmer module cache to conductor - Merged and awaiting a release to 0.3.0-beta-dev.35

The Networking issues will mostly be addressed by the new endpoint logic in tx5. This work is still in progress pending further integration to Holochain.

abe-njama commented 5 months ago

@zippy @guillemcordoba @thedavidmeister

I've filed an issue in the wasmer repo requesting support or a support model be proposed by the wasmer team so we can confidently work on any one of the Interpreted wasm solutions being suggested by @guillemcordoba in this main issue. This is a follow-up to an email that I'd sent to the wasmer maintainers but I hadn't received a response to. Please feel free to pile on to the issue so we can get some traction.

abe-njama commented 4 months ago

Hey @guillemcordoba. Are you able to update the test application to 'holochain 0.3.0-beta-dev.37' and run the tests again? The fixes to some of the UX and Networking issues that had been raised have been shipped and we'd like to understand what impact these have had and to take stock of any new issues and to keep focus on outstanding ones.

github-actions[bot] commented 3 months ago

This item has been open for 30 days with no activity.