paint-brush
New Software Release: Uno Platform 4.1 Offers 30% Performance Boost, and More Compatibility!by@mx2ei1
197 reads

New Software Release: Uno Platform 4.1 Offers 30% Performance Boost, and More Compatibility!

by Uno PlatformMarch 21st, 2022
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

This release packs over 200 new feature requests, bugs, and issues you raised. We welcome a few great contributions from our community, which is now over 210 contributors strong. We’ve made numerous changes to a wide range of parts from the Uno Platform, such as style resolution, layout and measure pass performance, memory consumption and allocations which result in up to 30% performance improvements in some scenarios. We've changed the way MeasureOverride is invoked when InvalidateMeasure is called, where previously all ancestors of a control would be re-executing MeasureOverride, even if their size was not changing. We're working to get this improvement on Android and iOS soon.

People Mentioned

Mention Thumbnail

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - New Software Release: Uno Platform 4.1 Offers 30% Performance Boost, and More Compatibility!
Uno Platform HackerNoon profile picture


It has been just over 3 months since our 4.0 release, and we’ve used that time to focus on performance as well as bringing the latest .NET 6 innovation to Uno Platform. By simply updating your application to the newest bits you will notice a significant boost to your app performance.


This release packs over 200 new feature requests, bugs, and issues you raised. We welcomed a few great contributions from our community, which is now over 210 contributors strong! Thanks for all you bring to Uno Platform.


Let’s unpack the 4.1 release.

Performance updates

For this release, we’ve made numerous changes to a wide range of parts from the Uno Platform, such as Style resolution, layout and measure pass performance, memory consumption and allocations which result in up to 30% performance improvements in some scenarios.

Measure Dirty Path

The measure pass (MeasureOverride and InvalidateMeasure) is an important contributor to the computations performed to layout the UI, and any optimization performed in this area can significantly improve the time to show the first UI or improve binding update.


We’ve changed the way MeasureOverride is invoked when InvalidateMeasure is called, where previously all ancestors of a control would be re-executing MeasureOverride, even if their size was not changing. With the new update, MeasureOverride is not invoked recursively if the size is not changing and only for the elements that need it. This change is called dirty path invalidation, allowing the skipping of elements that don’t have their size invalidated.


This new optimization allows for UI that changes elements deep in the visual tree to have minimal impact on their parents, making changes more responsive.


This optimization is currently available for WebAssembly and Skia backends. We’re working to get this improvement on Android and iOS soon.

WebAssembly Memory Profiler Support

Troubleshooting memory issues is not an easy task but can be made more efficient with tooling. .NET WebAssembly is not providing such tooling, but as it uses the Mono virtual machine underneath, tooling like ones found in the Xamarin space.


We took the task of enabling memory profiling for WebAssembly, by including the mono logging profiler in the runtime, giving the ability to create memory profiles that can be opened using the Xamarin Profiler.



About Uno Platform

For those new to Uno Platform – it allows for creation of pixel-perfect, single-source C# and XAML apps which run natively on Windows, iOS, Android, macOS, Linux and Web via WebAssembly. Uno Platform is free and Open Source (Apache 2.0) and available on GitHub.


This change is now available as part of Uno.Wasm.Bootstrap 3.2 and later can be enabled easily by setting new flags in the project file.


You can head to the documentation on how to profile the memory of your Uno Platform WebAssembly application.

Memory allocations improvements

Memory allocations during critical paths of the layout and rendering has also been improved significantly. Reducing allocations is reducing the time spent managing memory by the GC, improving the overall performance of the application.


These improvements were done through the inclusion of an Array Pooling system linked to the MemoryManager class. This allows for dynamic management pooled arrays based on the memory pressure detected by the GC.


Additionally, a refactoring of delegate and lambda-based pieces of code was included. In many cases, using C# lambdas makes code easy to read, but can have adverse effects on multicast delegates invocations, display class creations and memory allocations of multicast delegates (64 bytes each under monovm). Replacing those with simple classes with either interface virtual methods invocations both improves memory allocation and invocation performance. Additionally, on WebAssembly AOT, delegates are creating a very costly interpreter/AOT transition. Virtual methods invocations don’t have this issue.

Merged Styles Tooling for enhanced performance

We’re happy to introduce an open-source tool called XAML Merger to enhance the performance of applications. This is an enhancement of Microsoft’s WinUI Resource Dictionaries merging tool used in WinUI 2.x, providing it in an easy-to-use NuGet package internal compatible with UWP/WinAppSDK and Uno Platform projects.


Merging dictionaries has a great impact on all platforms, including UWP and WinUI. For instance, resolving a single resource in Uno.Material went down 32% in WinAppSDK on Windows with resources merged.


ResourceDictionary XAML files are a central part of the styling system of XAML-based platforms. For readability, in most cases, dictionaries are split in many files (one per control type, generally) in applications and Uno itself, requiring the use of “Merged Dictionaries”. Those merged dictionaries cannot lookup up in the tree for color resources, and developers generally tend to add duplicate inner merged dictionaries referencing color or brushes to have a common look and feel for controls.


This architecture allows for dictionaries to be used as a single entity which recursively looks up every inner dictionary for resources, creating an individual Dictionary<,> lookups through a linear walking of the merged dictionary tree.


While this choice makes the developer’s life easier, it is also very computation intensive. During static resources resolution, the Application.Resources dictionary is queried extremely often to resolve templates and their resources.


To reduce the impact of these lookups, merging dictionaries is a good way to get a single dictionary lookup, greatly improving the creation time of UI elements.

For example, Uno Platform had an internal number of dictionaries for all controls of about 81. This number could also be added to Uno.Material and any other library which uses individual resource dictionaries for its styles and resources.

Android 12 support

Uno Platform now brings the support for Android 12 SDK and its dependencies and removes the support for Android 10 SDK. As a reminder, this only means that you need to build your application with Android SDKs 11 or 12, and your application can still run properly on Android 5 or later.


Note that building for Android 12 is easier when using Visual Studio 2022, where the JDK 11 is installed automatically, without any additional setup.

.NET 6 Mobile Preview 13 and VS 2022 17.2 Preview 1 support

The .NET team has introduced the Preview 13 of their mobile bindings, introducing a set of low-level breaking changes in the macOS and iOS APIs. This change is unlikely to impact most net6 Uno applications, but libraries that make use of the “native” primitives such as `nint` and `nfloat` will require some code changes.


To build your application for Uno 4.1 and Visual Studio 2022 17.2 Preview 1, you’ll need to run uno-check first.


Note that Visual Studio 17.0 and 17.1 stable builds are not supported for .NET 6 mobile targets so naturally Uno Platform will face the same constraints.


It’s also worth noting that in .NET 6 mobile Preview 14 Microsoft will introduce an additional (and likely final) set of binary breaking changes, and we’ll publish an update to Uno NuGet package.

Once you have 17.2 Preview 1 or later installed, use `uno-check –preview` to set up your environment.

Uno Platform VS Code Plugin Updates

We’re also updating the Visual Studio Code integration with:

Improvements over code changes detection, so that code completion shows up-to-date content from code in your application.


The ability to set a port number the remote-control tooling, which can be particularly useful when you publish your application in a containeri.

Head over to our VS Code plugin to get started!

Figma Plugin Updates

The Uno Platform Plugin for Figma is an Uno Platform WASM application. Therefore, all performance updates we made in 4.1 are automatically included in the plugin, making it faster on launch and updates. In addition, we spent a lot of time documenting the plugin so you can more easily try it out.


The best way to try the plugin is to go through the quick start and run the eCommerce sample application.

Other updates

  • DPI Scaling support on Skia
  • Folder Picker for Skia WPF
  • Canvas.ZIndex on Skia
  • x:Bind to properties during Hot Reload

Contributors Highlights

  • @LokiMidgard, @marknoble, @ConroyG and @ReenigneCA for documentation updates
  • @Youssef1313 for Literal parsing and LineGeometry, RectangleGeometry, and EllipseGeometry in Skia
  • @mikernet for password autofill fixes on iOS
  • @workgroupengineering for Runtime testing DynamicData support and FileOpenPicker on Skia
  • @peterfoot for the Skia/WPF folder picker
  • @pkar and @pdecostervgls for additional unit tests
  • @ahoefling for WinAppSDK single project support for the unoapp-net6-winui template
  • @mikebmcl for Skia GTK window fixes
  • @nor0x for DisplayInformation localization fixes
  • @trungnt2910 for FileOpenPicker wasm fixes

New to Uno Platform?

If you are new to Uno Platform, the best way to get started is to follow our official getting started guide. Before you get started, make sure you’ve prepared your dev environment for Uno Platform app development.


The tutorial walks you through creating a small multi-platform application with Uno Platform and how to run your applications on all platforms supported by Uno Platform.


Get Started,

Jerome Laban, CTO, Uno Platform

P.S. For those unfamiliar with Uno Platform, it allows C# and XAML developers to build single-codebase. Check out the Uno Platform Learning Resources for Beginners.