Uno Platform Does WebAssembly Threading Months Before .NET 7 – Visual Studio Magazine

New

Uno Platform Uses WebAssembly Threading Months Before .NET 7

Uno Platform beat Microsoft when it comes to multi-threading in WebAssembly, the technology behind Microsoft’s Blazor client-side web development framework.

Multithreading support in WebAssembly (or wasm) is available for .NET 7, coming in November, but Uno Platform already has it in its latest update, Uno Platform 4.4. Uno Platform says its open-source offering “enables the creation of single-source, pixel-perfect C# and XAML applications that run natively on Windows, iOS, Android, macOS, Linux, and web via WebAssembly.”

Multithreading in .NET 7 has been in the works for years, sparked by a December 2019 GitHub issue calling for “multithreading which is already available in WEBASM to be exposed on the Blazor client side”. As detailed in the month of February Visual Studio Magazine article titled “.NET 7 WebAssembly Plans: Mixed-Mode AOT, Multi-Threading, Web Crypto”, Microsoft’s Daniel Roth then announced “Multithreading support in Blazor WebAssembly is planned for .NET 7. Plans may still change, we’ll see how it goes.”

But on the Uno platform, it already works.

“Another exciting update is experimental Threading support in .NET 7,” Uno Platform said in a June 28 blog post.

Uno Platform, often in partnership with Microsoft, has been active in WebAssembly innovations. For example, it was the first to provide the ability to build WebAssembly applications in Visual Studio on Windows using Ahead of Time (AOT) compilation. He also borrowed Xamarin technology to add brand new memory profiler support to .NET WebAssembly and was very active in helping to flesh out WinUI 3 technology. With v4.4, these innovations continue.

Uno platform
[Click on image for larger view.] Uno platform (source: Uno platform).

“Our team has been working with the .NET team to provide early feedback on the hard work they’ve put into enabling Wasm threading over the past few months,” Uno Platform said yesterday. “This is another big open source win for everyone, because ultimately the .NET and Uno Platform communities will benefit from this feature. We are happy to be able to contribute to this journey by being one of the first to bring Wasm threading to our community.

“Uno.UI and Uno Bootstrapper have been updated to include thread support. On the Uno.UI side, this means you can create threads or tasks and use CoreDispatcher or DispatcherQueue to return to the main thread. This allows Web Apps to perform expensive tasks outside of the UI thread and avoid freezing the UI.”

As noted, Uno Platform is not the very first to tackle such support, as evidenced by the Threads Proposal for WebAssembly project on GitHub, intended for discussion, prototype specification, and implementation. ‘a proposal for threading support in WebAssembly.

Uno Platform itself experimented with WebAssembly threading a few years ago, when wasm multi-threading was primarily available through techniques such as the use of WebWorkers and other mechanisms that allow WebAssembly applications to use multi-paradigms. -Traditional web threading.

Microsoft’s experimental WebAssembly multi-threading support can be followed in the appropriate name”[tracking] Experimental support for WebAssembly multithreading” GitHub issue in the dotnet/runtime repository, which lists high-level goals, including:

  • The threading runtime must be distributed in the same browser-wasm runtime package
  • Thread must be opt-in only
  • Wasm bindings and runtime are thread safe and GC aware co-op

In the Uno Platform 4.4 update, besides threading support, there are also many other new features, including:

  • Smooth animations via Skottie integration
  • High fidelity rendering via TextBlock for Skia Rewrite
  • Updates to Uno Platform Project Default Template
  • WebAssembly performance updates (including WebAssembly exception support)
  • New scenarios via new GamePad API support

Other assorted tweaks and minor changes include:

  • We’ve made some changes to the way Android drawables are resolved. This time on net6.0 and later we are generating the table of drawables instead of relying on reflection. This provides cost-free startup for that part and saves about 40 ms.
  • On iOS and macOS, we made many changes to interoperability costs, such as converting Color to CGColor without intermediaries, avoiding calling specific methods that might recreate managed objects during layout to relieve pressure on the GC
  • On Android, we moved TextBlock Paint creation to Java to avoid invoking many small methods from C#, and make a big JavaScript call, saving 10% when creating text color.
  • We changed the way SelectorItem handles selection animations to avoid using DateTime.Now as the time source. In .NET 6 and later, these calls have to go through libicu for localization, which makes it more expensive than just using Stopwatch.

In total, Uno Platform has implemented and resolved over 90 new feature requests and issues.

“Uno Platform 4.4 is our 4th release in 2022, we are now on a rapid release schedule of once every six weeks that we are aiming for,” the company said. “The release contains lots of UI and performance improvements on all target platforms. Firstly, on the UI side, you will be able to produce beautiful smooth animations on .NET Android based targets, . NET iOS and Skia, as well as faithful renderings of all your text to Skia-based targets. exceptions. Finally, we’ve also enabled new input scenarios via GamePad API support and improved default project templates.”

About the Author


David Ramel is an editor and writer for Converge360.



Comments are closed.