Skip to content

[WinUI] Creating a complex grid is very slow #21787

@MartyIX

Description

@MartyIX

Description

I have a non-trivial grid which I create by hand (not in XAML but by code) and it can easily take hundreds of milliseconds to show such a grid.

Steps to Reproduce

  1. Fetch https://github.com/MartyIX/maui/tree/feature/2024-04-11-grid-perf (MartyIX@dbb147d)
  2. cd src/Controls/samples/Controls.Sample.Sandbox
  3. dotnet publish -f net8.0-windows10.0.19041.0 -c Release -p:PublishReadyToRun=false -p:WindowsPackageType=None
  4. dotnet trace collect --format speedscope -- .\bin\Release\net8.0-windows10.0.19041.0\win10-x64\publish\Maui.Controls.Sample.Sandbox.exe
  5. Click "Generate Grid" to generate a 30x30 grid and see how long it took.

It can take 900 ms, and then it speeds up after a several clicks to about 600 ms but it does not drop under that bound.

image

Speedscope

Maui.Controls.Sample.Sandbox.exe_20240411_223826.speedscope.json

image

From the data, it's clear that

public static void AddWithSpan(this Grid grid, IView view, int row = 0, int column = 0, int rowSpan = 1, int columnSpan = 1)
takes a lot of time but it's very much unclear to me how to speed it up because it seems there is no batching support in MAUI right now.

Link to public reproduction project repository

https://github.com/MartyIX/maui/tree/feature/2024-04-11-grid-perf

Version with bug

8.0.20 SR4

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Windows, I was not able test on other platforms

Affected platform versions

Windows 10, Windows 11

Did you find any workaround?

No.

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-layoutStackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenterlayout-gridperf/generalThe issue affects performance (runtime speed, memory usage, startup time, etc.) (sub: perf)platform/windowst/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions