maui
maui copied to clipboard
[Android] Slow scrolling, laggy performance
Description
It is a list using CollectionView with elements using Border. It's a list of only 5 items, but there must be something wrong somewhere because it lags considerably.

Steps to Reproduce
- Download or sync https://github.com/jsuarezruiz/netmaui-surfing-app-challenge
- Launch the App on Android and scroll the main page.
Version with bug
6.0.486 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android 12 and 13
Did you find any workaround?
No response
Relevant log output
No response
This bug has been reported so many times, none of them will be fixed
In traces, I can see that the CollectionView calls SurfingApp!SurfingApp.Views.Templates.PostItemTemplate..ctor() again and again. Looks like it recreates the whole view on every scroll.
Attaching traces. They contain everything that happens during the swipe gesture: maui-app-trace.speedscope.json.zip
In traces, I can see that the CollectionView calls SurfingApp!SurfingApp.Views.Templates.PostItemTemplate..ctor() again and again. Looks like it recreates the whole view on every scroll.
Attaching traces. They contain everything that happens during the swipe gesture: maui-app-trace.speedscope.json.zip
Reviewed and can see the same. PostItemTemplate is created again and again.
Related: https://github.com/xamarin/Xamarin.Forms/issues/8718#issuecomment-767615301
I have the same problem. How do you upload such an app to the Play Store? you will be laughed at immediately. certain things need to be fixed as a matter of priority.
Hey guys, I've developed a workaround to this issue that you can use until the MAUI team provides an official fix. Please try it out and let me know whether it works for you too.
https://gist.github.com/jedusei/e15f45e1ae385d8b57413c168d3ef730
Hello when can I expect this fix for net 6?
THIS IS WHAT I recognized IN ALMOST ALL .NET NATIVE CONTROLS if LOTS of XAML Markups (FASTER ON RELEASE MODE)... Yes it is real native, But this undergo lots of compilations, logics and codes before it landed to native view. But it is getting better now.
Hola chicos, he desarrollado una solución para este problema que pueden usar hasta que el equipo de MAUI proporcione una solución oficial. Por favor, pruébalo y hazme saber si funciona para ti también.
https://gist.github.com/jedusei/e15f45e1ae385d8b57413c168d3ef730
This should improve scrolling with collectionview?
Reviewing this app, the first thing I noticed that the PostItemTemplate.xaml has about 100 lines of styles inside. I moved this into the main Styles.xaml, so it isn't created for every row.
Next, I recording a .speedscope while scrolling (tested the net8.0 branch): surfer.zip
35% of the time is spent in:

This is deeply nested doing interop from C# -> Java -> C# -> Java many levels deep.
I think we should remove this C# method somehow:
https://github.com/dotnet/maui/blob/3859318f971b39b9d4a0e48492a3daed012cb695/src/Core/src/Platform/Android/WrapperView.cs#L93-L114
And put everything in Java, so nothing does interop at all here. I will investigate if it's even possible, because there may be a lot of C# logic happening here.