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.04k stars 1.73k forks source link

[Performance] CollectionView slow first render #24994

Open OvrBtn opened 5 days ago

OvrBtn commented 5 days ago

Description

Context

This is a dupe of https://github.com/dotnet/maui/issues/15204 I'm creating this issue to throw in here anything I find/record while testing to avoid making a bunch of messy comments in original issue.

All the videos were recorded on physical android device (Samsung Galaxy A50) in release configuration. All dotnet-traces were recorded using android emulator in release configuration.

This issue was also present in .net 7, I haven't tested version before.

Using a fork last synced on 24.09.24 - issue is still present.

Issue showcase

Using linked repro

https://github.com/user-attachments/assets/b0adf04a-ba5b-4ac0-82f0-d8d725b67f70

Simplified situation with CollectionView having just 1 element, demo running in Maui.Controls.Sample.Sandbox

Here I've copied to MAUI's codebase XAML and code from linked repro - SimpleCollectionView1Page and it's ViewModel and Model to be exact.

https://github.com/user-attachments/assets/e2958005-7f4d-4388-9051-53f3bae87248

Even with single element in CollectionView navigation is still slow.

Here is a recorded dotnet-trace: maui-app_20240929_201458-SimpleCV-WithCV.speedscope.json

Similar situation like above but the CollectionView is removed and only what was in the DataTemplate is left as content of the page

https://github.com/user-attachments/assets/1207ac5b-741c-46a3-8dcd-9fdcc0d37053

As you can see navigation is faster. I made this recording to show that probably the CollectionView is at fault. Maybe by comparing dotnet-trace someone will catch something?

Recorded dotnet-trace: maui-app_20240929_090419-SimpleCV-WithoutCV.speedscope.json

Steps to Reproduce

Videos should show everything, if something is not clear please let me know.

Link to public reproduction project repository

https://github.com/OvrBtn/MAUIPerf

Version with bug

Unknown/Other

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

similar-issues-ai[bot] commented 5 days ago

We've found some similar issues:

If any of the above are duplicates, please consider closing this issue out and adding additional context in the original issue.

Note: You can give me feedback by ๐Ÿ‘ or ๐Ÿ‘Ž this comment.

OvrBtn commented 5 days ago

@jonathanpeppers sorry for ping but in the original issue you asked for .speedscope so maybe you will find this useful.

OvrBtn commented 5 days ago

I guess the most eye catching difference is the measurement Example with CollectionView: image Example without CollectionView: image

Exactly the same stuff to draw on screen and yet huge difference.