enisn / UraniumUI

Uranium is a Free & Open-Source UI Kit for MAUI.
Apache License 2.0
1.11k stars 130 forks source link

TreeView ineffeciencies causing huge trees to take forever #589

Open Stryxus opened 6 months ago

Stryxus commented 6 months ago

I am working on a reverse engineering project with an archive filesystem which has been be translated so I can make use of it with the TreeView control. I have discovered that doing node.Children.Add() causes a graphical update or something else at least which is taking a long time and ends up hanging the application. There arent many children getting added, a 131 child job takes about 30 seconds which is very slow.

I have confirmed this is not my code, it hangs when node.Children.Add() is called.

I have tried setting the Children ObservableCollection directly since it has a setter but, that does not seem to update the control at all.

Is there any chance this could get looked at? Perhaps add an update to the Children setter or, let us call an update ourselves after adding all the Children?

I am still relatively new to MAUI so I cannot contribute to this myself. I am using .NET 8 MAUI on the latest release UraniumUI.

Stryxus commented 6 months ago

Iv discovered that it takes exponentially longer, the more elements are in the tree.

enisn commented 6 months ago

TreeView uses BindableLayout. Probably bottleneck is BindableLayout itself. https://github.com/enisn/UraniumUI/blob/92fdfd90157e6f065cde26a06a310ad37700b997/src/UraniumUI.Material/Controls/TreeView.cs#L92

But, my first approach while building TreeView was using CollectionView, but using multiple-level CollectionView made the application unusable, its performance was much worse than the current state, and it was crashing randomly while scrolling. I'm not sure how to increase performance but I can build a custom item-recycling logic for BindableLayout

mos379 commented 4 months ago

Is there something specific about Android? I can quickly load a huge amount on windows, but Android constantly shows me Performing a full GC