realm / realm-dotnet

Realm is a mobile database: a replacement for SQLite & ORMs
https://realm.io
Apache License 2.0
1.23k stars 159 forks source link

Web Assembly/WebGL Support #2199

Open Mohsens22 opened 3 years ago

Mohsens22 commented 3 years ago

Hi. Does this client library work on Dotnet Web Assembly projects (Such as Uno or Blazor)? If not, will there be a plan to add the support?

nirinchev commented 3 years ago

We don't support Wasm yet, although this is an area of acute interest. The Core Database team is exploring various approaches to get the native bits running in Wasm, but that effort is in its infancy and we're not in a position to make any commitments as to when and if the .NET SDK will be able tor un in Blazor/Uno.

Mohsens22 commented 2 years ago

Any news on this one?

nirinchev commented 2 years ago

Unfortunately, nothing to report here.

Mohsens22 commented 2 years ago

I believe that flutter has a wasm head so if we don't have wasm compilation on realm core, does it mean that we also can't use it for flutter web?

nirinchev commented 2 years ago

That is correct - none of the Realm database SDKs support web. If you're using MongoDB Realm (i.e. Sync), you can use the GraphQL API via http to query data in Atlas, but you can't use the local database.

moritz-mg commented 2 years ago

I'm late to the party, as always: Unity WebGL support is a super important feature for us, really (and a bit of a dealbreaker if not coming in the near future). Unity's WebGL/WASM build quality and power has been pretty underrated for quite some time, and it's mostly held back by proper support of a good "C#-speaking" database for Web and Mobile and Desktop.

Use case: We're designing a Web3 & Mobile game we plan to scale to ~60-70k concurrent users, and are looking for ways to not have to deal with writing and maintaining a bridge from Firebase Web to Unity for WebGL/WASM builds (while we could use the pretty decent mobile SDKs otherwise).

Realm has a vastly superior, very clean development paradigm in-engine that made it a very sweet outlook; to be honest I've never seen a more compelling C# data persistence, exchange and sync solution. Realm also has native desktop support, which is a huge plus.

In-Browser execution is still a must for our use case at this time.

There's perhaps a way to feed the native Cpp code into whatever compiles Cpp to WASM in Unity. Even though Unity Technologies just started their half-baked own backend-as-a-service, I reckon they'd be super keen on a solution as slick as Realm Sync to support their entire product. It wouldn't hurt to ask. Metaverse & stuff is really big on Unity this year.

timahrentlov commented 2 years ago

.NET 7 is not too far of, and WASM is going to be important in that release. Would be nice to experiment with blazor + realm soon :)

moritz-mg commented 2 years ago

NB that for Unity3D, which isn't even on .NET 6 for the foreseeable future, WASM support is a somewhat different issue altogether.

connde commented 1 year ago

Hi, any updates on that? We're evaluating the use of Realm for Blazor on multiple enterprise apps, is this on the roadmap?

nirinchev commented 1 year ago

It's not something we expect to support in the near/mid-term timeframe. We have done some preliminary work to support WASM using the JS SDK, but that's mostly at the POC stage.

kyurkchyan commented 10 months ago

Just another comment on how much I would love to see realm in Web Assembly. We have multiple projects using realm, and the only option to access realm DB from the web app is through querying the MongoDB database either through Graph QL APIs, or through a custom API layer.

nirinchev commented 10 months ago

@kyurkchyan are you looking for database support in WASM or just an API to do one-off queries of MongoDB using C#? We're considering extracting the authentication, functions, and remote mongodb client functionalities from the SDK into a separate package, that will be WASM-compatible, but I'd be curious to hear if that's something that will solve your use case.

kyurkchyan commented 10 months ago

Hey @nirinchev. We are looking for DB support in WASM/Blazor. I asked this question about three years ago in StackOverflow, and you had a reply to it. I have been closely following this topic since then regularly.

In most apps we develop, we would like to have as much as possible feature parity and code sharing between mobile and web. Otherwise, we must completely duplicate the core business logic for synced and non-synced scenarios. When working in a sync realm scenario, we heavily rely on the reactive aspects of the realm, and the app is built with reactive extensions. Thus, if the web app can't do that, we will need to reimplement the web app with a more traditional server/client API-based approach, which translates into a different business logic, and in many cases, a different UX. For instance, in WEB API-based approach you need to start thinking about data pagination, which is not an issue in a synced realm scenario.

Thus, we should have synced DB in WASM in the ideal world scenario. Before reaching that ideal world, having shared remote and auth functionality is still a significant gain, as it will simplify the setup. We could go without an explicit API server and talk to MongoDB directly through the auth/API layer built into the realm SDK.

nirinchev commented 10 months ago

Thanks, this makes sense! We're still slowly working towards database support for WASM, but there are many non-trivial obstacles, so we still have some way to go before it's feasible to use as a fully supported platform.

Extracting a fully managed implementation of a App Services client is more feasible in the short term and we'll take your feedback into consideration when reviewing the backlog of tasks.

sumowesley commented 3 months ago

@kyurkchyan are you looking for database support in WASM or just an API to do one-off queries of MongoDB using C#? We're considering extracting the authentication, functions, and remote mongodb client functionalities from the SDK into a separate package, that will be WASM-compatible, but I'd be curious to hear if that's something that will solve your use case.

I'd be interested to know if this idea has got much further. We're writing mobile app with Realm but because of app store rules, we have to manage subscriptions outside of the Apps. We would like to do this through a small Blazor WASM project. Authentication would be good, as would writing to custom user data.

nirinchev commented 3 months ago

Yes, that's still something we're interested in and are slowly moving in that direction, but don't have a timeline we can share yet. If you have timeframes for when you'd need this, definitely reach out to your account executive and share those with them as their input has meaningful impact on the engineering prioritization.

sumowesley commented 3 months ago

Hi @nirinchev, thank you for the reply. I'm not sure we have an account executive as such. We've been working on a free database for several months looking at how best to structure Realm/MongoDB for our needs.