Skip to content

dotnet/maui

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

Fixes: #11885

Looking at the JITStats report in PerfView (for MSBuild.exe):

| Name                                    | JitTime (ms) |
| ---                                     |          --: |
| Microsoft.Maui.Controls.Build.Tasks.dll |        214.0 |
| Mono.Cecil                              |        119.0 |

It appears that `Microsoft.Maui.Controls.Build.Tasks.dll` spends a lot
of time in the JIT. What is confusing, is this was an incremental
build where everything should already be loaded. The JIT's work should
be done already? I don't see the same behavior for Android MSBuild
tasks or Windows App SDK tasks.

The cause appears to be usage of `[LoadInSeparateAppDomain]` in .NET MAUI.

However, we can't just *remove this* as there would be complications...

`[LoadInSeparateAppDomain]` also conveniently resets all `static`
state when `<XamlCTask/>` runs again. Meaning that future incremental
builds would potentially use old (garbage) values. There are several
places that cache Mono.Cecil objects for performance reasons. Really
weird bugs would result if we didn't address this.

To make things correct *and* remove `[LoadInSeparateAppDomain]`:

* Move all `static` state to a `XamlCache` class as instance values.

* Each `ILContext` has an instance of `XamlCache`.

* Any child `ILContext`'s such as with `DataTemplate` are passed the
  parent's `XamlCache`.

* Various `static` extension methods now require a `XamlCache` to be
  passed in. This allows unit tests to do this as well.

* Other `*Visitor` or `*Converter` types have an instance of
  `ILContext`, so they can access `ILContext.Cache` as needed.

Unfortunately, I had to make small changes to lots of lines for this.

Testing these changes inside Visual Studio with a `dotnet new maui`
project template:

    Before:
    XamlCTask = 743 ms
    XamlCTask = 706 ms
    XamlCTask = 692 ms
    After:
    XamlCTask = 128 ms
    XamlCTask = 134 ms
    XamlCTask = 117 ms

This saves about ~587ms on incremental builds on all platforms, an 82%
improvement. This will help even more on large solutions with multiple
.NET MAUI projects, where `<XamlCTask/>` runs multiple times.
73a06de

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time

.NET Multi-platform App UI (.NET MAUI)

Build Status Build Status

.NET Multi-platform App UI (.NET MAUI) is a cross-platform framework for creating mobile and desktop apps with C# and XAML. Using .NET MAUI, you can develop apps that can run on Android, iOS, iPadOS, macOS, and Windows from a single shared codebase.

Getting Started

Overview

.NET Multi-platform App UI (.NET MAUI) is the evolution of Xamarin.Forms that expands capabilities beyond mobile Android and iOS into desktop apps for Windows and macOS. With .NET MAUI, you can build apps that perform great for any device that runs Windows, macOS, Android, & iOS from a single codebase. Coupled with Visual Studio productivity tools and emulators, .NET and Visual Studio significantly speed up the development process for building apps that target the widest possible set of devices. Use a single development stack that supports the best of breed solutions for all modern workloads with a unified SDK, base class libraries, and toolchain. Read More

.NET MAUI Weather App on all platforms

Current News

Follow the .NET MAUI Blog and visit the News wiki page for more news and updates.

FAQs

Do you have questions? Do not worry, we have prepared a complete FAQ answering the most common questions.

How to Engage, Contribute, and Give Feedback

Some of the best ways to contribute are to try things out, file issues, join in design conversations, and make pull-requests. Proposals for changes specific to MAUI can be found here for discussion.

See CONTRIBUTING, CODE-OF-CONDUCT and the Development Guide.