realm-dotnet icon indicating copy to clipboard operation
realm-dotnet copied to clipboard

Web Assembly/WebGL Support

Open Mohsens22 opened this issue 3 years ago • 17 comments

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?

Mohsens22 avatar Jan 22 '21 22:01 Mohsens22

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.

nirinchev avatar Jan 23 '21 00:01 nirinchev

Any news on this one?

Mohsens22 avatar Dec 23 '21 14:12 Mohsens22

Unfortunately, nothing to report here.

nirinchev avatar Jan 03 '22 12:01 nirinchev

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?

Mohsens22 avatar Jan 06 '22 17:01 Mohsens22

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.

nirinchev avatar Jan 06 '22 18:01 nirinchev

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.

moritz-mg avatar Mar 31 '22 20:03 moritz-mg

.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 :)

timahrentlov avatar Jun 20 '22 19:06 timahrentlov

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

moritz-mg avatar Jun 24 '22 07:06 moritz-mg

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

connde avatar Jun 28 '23 11:06 connde

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.

nirinchev avatar Jun 28 '23 12:06 nirinchev

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.

kyurkchyan avatar Sep 20 '23 18:09 kyurkchyan

@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.

nirinchev avatar Sep 22 '23 22:09 nirinchev

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.

kyurkchyan avatar Sep 23 '23 05:09 kyurkchyan

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.

nirinchev avatar Sep 25 '23 11:09 nirinchev

@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.

sumowesley avatar Apr 17 '24 11:04 sumowesley

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.

nirinchev avatar Apr 17 '24 19:04 nirinchev

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.

sumowesley avatar Apr 18 '24 07:04 sumowesley