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
21.89k stars 1.69k forks source link

Collectionview WinUI recycling item count calculation problem #20206

Open enkaradag opened 6 months ago

enkaradag commented 6 months ago

Description

Hi again,

For WinUI;

In .NET MAUI version 8.0.6 (last release), CollectionView was creating extremely high count of recycle items (creating 350 400 items for a 1000 set tough 15-20 was enough for its vertical size) It was continiously creating new recycle items while scrolling. So it was flickering and app was becoming unresponsive.

It is fixed here https://github.com/dotnet/maui/pull/20079

Now testing 8.0.7-preview.9929

CV works so much better now. But it still creates 5x more recycle items for rows. For below capture; CV needs 17 recycle items but it is creating 84 rows. When collectionview size is changed or recycle items vertical size is changed CV always creates 5x more than required recycle items. This makes whole app unresponsive for afew seconds. If a complex itemtemplate is defined that lasts longer.

It's not creating more recyle items while scrolling (just 1 or 2 sometimes), so scrolling performance is good comparing to 8.0.6

I tested CV for android, ios and maccatalyst. For those it creates just enough count of recycle items.

https://github.com/dotnet/maui/assets/57816471/557ac42f-4c75-4679-929f-240c5a5b9ae7

Steps to Reproduce

No response

Link to public reproduction project repository

https://github.com/enkaradag/collectionview_flicker_test2

Version with bug

Nightly / CI build (Please specify exact version)

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

PureWeen commented 6 months ago

@Foda thoughts?

Foda commented 6 months ago

@Foda thoughts?

Yup -- by default WinUI caches 4x the viewport size. We could lower this. The cache length increasing when resized is normal, but not by another 4x amount so we should investigate.

enkaradag commented 6 months ago

This is a useful info.

So, is it somehow possible to set ItemsStackPanel.CacheLength value in an maui project using a renderer?

Drawing the viewport lasts for milliseconds but app stays unresponsive for afew seconds more. This looks bad for a modern ui

ghost commented 6 months ago

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.