Timeline for mono AOT Webassembly export?

This topic was covered a few years ago here:

I was wondering if there was any progress on compiling a monogame project into a single file, full aot wasm, webassembly package from visual studio?

This is apparently already possible for dev projects very similar to monogame. For example, the Uno Platform (a UI oriented, C# cross platform effort) has already done it a few months ago:

That just uses mono-wasm, and right now, you will get worse performance with mono-wasm version than with Bridge.NET version.

Thanks for the quick reply!

Do you have any recent benchmarks? I read that mono-wasm become much more mature since last year.

In any case, how/when would aot-wasm feature in monogame become available then? Is this something that the monogame dev community would have to do (like Uno) or is this going to work automatically out of the box once when .NET 5 (or a mature preview of it) is released?

Can I can have a version github project that uses mono-wasm? I really need it

1 Like

Bridge.NET is depreacated for years now. The site and the repository no longer exist. Monogame 3.8.1 is on .NET 6. Wonā€™t it compile for WebAssembly now?

Will it? Anyone got a sample?

If someone has got it working Iā€™d like to know too.
The farthest I got is a message that it fails to load SDL2, or a dependency, probably because there is no compatible library for WebAssembly.

I have a working prototype here.
You can clone it and use it as a template.

Here are two live sites:
http://nkast.gr/wasm/AetherPhysics2d/Samples/
http://nkast.gr/wasm/MGJ3/

Earlier today someone from discord send me this video where he ported
his game/project on multiple platforms, including wasm.

For any further developments watch my fork at github to get notified for new releases.

2 Likes

Ah, from what I see you made a special framework for Blazor/WebGL? I had briefly looked into that, but then decided that I donā€™t know enough of either MonoGame or WebGL to do that.
I will try to play around with that, thanks.

Indeed!
The Wasm/WebGL bindings are in a separate library.

Okay, I will have to look into it, but this may be what I have been looking for, for some time.

Out of curiosity, where is the repo/code for the wasm specific monogame framework? Or is that actually just the same as DesktopGL?

The repo is at https://github.com/kniEngine/kni

If you are interested to look into the implementation then begin with those two .targets. They contain a list of files that implement graphics and audio (WebGL and WebAudio).
https://github.com/kniEngine/kni/blob/main/MonoGame.Framework/BlazorAudio.targets
https://github.com/kniEngine/kni/blob/main/MonoGame.Framework/Blazor.targets

1 Like

Hi, I see there are NuGet packages including one for Blazor. Sorry if this is an ignorant question, but do those work straightforwardly in conjunction with the MonoGame templates? (Iā€™m not too familiar with C# project configuration, but would love to use this.)

Hi,

look at my preview post here .
There isnā€™t a template yet. That github repository will eventually become the basis of the template.
At the moment you can download the source and start building from there.
I still have to to iron out how a couple of thing, like for example making the content builder to work seemingly.

2 Likes

Hello,

Thereā€™s now a BlazorGL template for VS2022.
The template supports automatic content build.

You have to install the SDK from the 3.8.9102 release.

For those who used the project from the WebGLxnaProj repo
you have to merge the latest updates and install the SDK which
includes the mgcb and the build targets.

3 Likes

I downloaded and installed the 3.8.9102 release and selected VS2022 only.

I donā€™t see the new template when I try to create a new project in VS2022.
Should the new blazor template be available in the list of templates?

Also I unzipped MGCBEditor.zip and tried to run ProtonType.exe but it crashes on startup.


That is what you should see. sometimes it takes a couple of restarts for VS2022
to update the template cache. Try running this command in the command prompt.
ā€œC:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\devenvā€ /updateconfiguration

The MGCBEditor is an additional WPF editor thatā€™s under development.
Do you have .net framework 4.8 installed? If you can find the error from
the windows Event Viewer I can see what I can do.

The SDK installs the pipeline editor as well. Type ā€˜Kni PipelineEditorā€™ on
windows Start and you should see it.

2 Likes

Thank you!!!

I have created a project form the template and run it sucessfully.

Here is the event viewer information. I do have .net framework 4.8 installed.
I can carry on with the pipelineEditor.

Application: ProtonType.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NotSupportedException

Application: ProtonType.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.NotSupportedException Exception Info: System.IO.FileLoadException at System.Reflection.RuntimeAssembly._nLoad(System.Reflection.AssemblyName, System.String, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, System.Threading.StackCrawlMark ByRef, IntPtr, Boolean, Boolean, Boolean) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(System.Reflection.AssemblyName, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, System.Threading.StackCrawlMark ByRef, IntPtr, Boolean, Boolean, Boolean) at System.Reflection.RuntimeAssembly.InternalLoadFrom(System.String, System.Security.Policy.Evidence, Byte[], System.Configuration.Assemblies.AssemblyHashAlgorithm, Boolean, Boolean, System.Threading.StackCrawlMark ByRef) at System.Reflection.Assembly.LoadFrom(System.String) at tainicom.ProtonType.App.Modules.ModulesMgr.LoadModule(System.String) at tainicom.ProtonType.App.Modules.ModulesMgr.LoadModules(System.String, System.String) at tainicom.ProtonType.App.Modules.ModulesMgr.LoadModules() at tainicom.ProtonType.App.Models.MainModelā€¦ctor() at tainicom.ProtonType.App.ViewModels.MainViewModel.Initialize(tainicom.ProtonType.App.Views.MainWindow) at tainicom.ProtonType.App.Views.MainWindow.Window_Loaded(System.Object, System.Windows.RoutedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(System.Object, System.Windows.RoutedEventArgs, Boolean) at System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject, System.Windows.RoutedEventArgs) at System.Windows.BroadcastEventHelper.BroadcastEvent(System.Windows.DependencyObject, System.Windows.RoutedEvent) at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(System.Object) at MS.Internal.LoadedOrUnloadedOperation.DoWork() at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks() at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks() at System.Windows.Media.MediaContext.RenderMessageHandlerCore(System.Object) at System.Windows.Media.MediaContext.RenderMessageHandler(System.Object) at System.Windows.Interop.HwndTarget.OnResize() at System.Windows.Interop.HwndTarget.HandleMessage(MS.Internal.Interop.WindowMessage, IntPtr, IntPtr) at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef) at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate) at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)

Good to know! :slightly_smiling_face:

As for the WPF editor, probably the system locked it because itā€™s was downloaded from the internet.
By right-click to see the properties of the folder and/or the executable you will be able to unlock it and give it executing permissions.

1 Like