dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.2k stars 1.75k forks source link

[WinAppSDK] Attaching controls to the visual tree is 40x slower on MAUI than on bare WinUI #6791

Open jeromelaban opened 2 years ago

jeromelaban commented 2 years ago

Description

Attaching a deep tree of controls to the live tree is 40x slower on MAUI than on bare WinUI 3, for similar operations.

Steps to Reproduce

Considering this code:

private StackLayout MakeLayout()
{
    var current = new StackLayout()
    {
        Children = { new Label() { Text = "Inner" } }
    };

    for (int x = 0; x < 99; x++)
    {
        var panel = new StackLayout();

        panel.Children.Add(current);

        current = panel;
    }

    return current;
}

Attaching the resulting layout to any parent (anything in the live visual tree) is costly:

image

The equivalent in WinUI:

private StackPanel MakePanel()
{
    var current = new StackPanel()
    {
        Children = { new TextBlock() { Text = "Inner" } }
    };

    for (int x = 0; x < 99; x++)
    {
        var panel = new StackPanel();

        panel.Children.Add(current);

        current = panel;
    }

    return current;
}

Version with bug

Release Candidate 2 (current)

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

net6.0-windows10.0.19041

Did you find any workaround?

None.

Relevant log output

No response

VincentBu commented 2 years ago

I create a WinUI project and I get the following result: image

did I miss something?

jeromelaban commented 2 years ago

@VincentBu I'm not sure of what you mean by this trace. I don't know what the origin of the problem is, only that the two pieces of code have very different performance characteristics.

ghost commented 2 years ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

MartyIX commented 1 year ago

Is the performance behavior better in .NET 7?

MartyIX commented 7 months ago

@jeromelaban Do you happen to know if the behavior is better in .NET 8?