CommunityToolkit / Windows

Collection of controls for WinUI 2, WinUI 3, and Uno Platform developers. Simplifies and demonstrates common developer tasks building experiences for Windows with .NET.
https://aka.ms/windowstoolkitdocs
Other
596 stars 74 forks source link

WrapLayout gallery sample never loads, is unusably slow under Windows App SDK #515

Open Arlodotexe opened 2 months ago

Arlodotexe commented 2 months ago

Describe the bug

The WrapLayout sample in the gallery never fully loads when running under Windows App SDK but is fine when running UWP.

https://github.com/user-attachments/assets/c01919ed-80da-42b8-80ac-9f43feb0a961

Steps to reproduce

1. Clone the repo
2. Generate the gallery solution, include the Primitives component and the wasdk multitarget/head.
3. Build and deploy the wasdk gallery.
4. Navigate to the 'WrapLayout' sample page and observe laggy behavior.

Expected behavior

Control should load and be reasonably responsive.

Screenshots

No response

Code Platform

Windows Build Number

Other Windows Build number

No response

App minimum and target SDK version

Other SDK version

No response

Visual Studio Version

No response

Visual Studio Build Number

No response

Device form factor

No response

Additional context

No response

Help us help you

Yes, I'd like to be assigned to work on this item.

Arlodotexe commented 1 month ago

Looks like there's no slowdowns or unexpected bugs when AoT is disabled. Might be a binding issue or an indication of a deeper layout problem when AoT is on.

We'll need to run a profiler to see what the hot paths are during the slowdown.

Arlodotexe commented 1 month ago

Looks like the hot paths are found on both the MeasureOverride and ArrangeOverride calls in WrapLayout, with the majority of time spent on ABI.Microsoft.UI.Xaml.Controls.IVirtualizingLayoutContextMethods.GetOrCreateElementAt(WinRT.IObjectReference, int) in both methods:

MeasureOverride: Image

ArrangeOverride: Image

This seems abnormal, possibly due to a change in CsWinRT?

Arlodotexe commented 1 month ago

Updating to the latest CsWinRT 2.1.5 has no effect, issue is still present.