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

[Windows] ListView and flicker while scrolling #20252

Open MartyIX opened 6 months ago

MartyIX commented 6 months ago

Description

Scrolling of a ListView control instance with many items can lead to a weird visual artifacts on Windows (not tested other platforms).

Steps to Reproduce

  1. Run https://github.com/MartyIX/MauiListView202401 (see commit) on Windows as a standard MAUI app.
  2. Scroll the ListView.

This is what I can see:

Link to public reproduction project repository

https://github.com/MartyIX/MauiListView202401

Version with bug

8.0.6

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

Did you find any workaround?

No. Maybe https://github.com/dotnet/maui/pull/20144 is a fix for this issue. I need to test it once it's merged.

Relevant log output

No response

XamlTest commented 4 months ago

Verified this on VS 17.10.0 Preview 1.0(8.0.7). Repro on Windows 11 release mode with below Project: MauiListView202401.zip

MartyIX commented 1 month ago

I can see in a demo WinUI app: https://github.com/MartyIX/LineHeight202404/tree/demo/202406/listview (https://github.com/MartyIX/LineHeight202404/commit/25f1bf5d872c42b4602fb2f30d357223e3ca674b) that there is no such flicker:

animation

MartyIX commented 1 month ago

So the thing is that MAUI does not actually use WinUI's list view but it has its own implementation AFAIK:

https://github.com/dotnet/maui/blob/9f0d6166e62f6cba5e659a957aaa9cb7e71dea48/src/Compatibility/Core/src/Windows/ListViewRenderer.cs

And likely the reason why the flicker appears is because Maui.Controls.Platform.Compatibility.CellControl.SetCell can take a lot of time in total (I was scrolling for a few seconds):

image