-
Notifications
You must be signed in to change notification settings - Fork 1.9k
ListView with Label.FormattedText in DataTemplate causes performance issues #5087
Comments
#3335 the same issue (?) |
@AndreiMisiukevich #3335 specifically references Android. My issue is happening on iOS, so I'm unsure if it's the same issue or not. Also, from #3335..
My Application Output does not have the messages, and the terrible scrolling behavior even occurs in Release builds for me. So it would seem that the 2 issues are different.(at least on the surface, they seem to be) |
Hm, this is going to be a challenge to debug. On my iPhone the scrolling looks ok. |
@kingces95, yes, newer phones seem to work fine, probably because of the performance increase over an iPhone 6. |
I have the same issue on Android. There is one interesting point how to reproduce it. If I quickly scroll through the list (fling) the problem does not appear, but if I swipe, the list will scroll with significant lags. In my application I use a DataTemplateSelector to select the type of cells to display and lags occur in those places where I touch and swipe cells containing FormattedString, and disappear if the cells become invisible. p.s. Debug output contains an infinite number of the following messages: |
Looks like #3168 is related issue. |
@kingces95 Actually, you do have the issue. As your first swipe is starting to end, right at 2 seconds into the video, you can see that the post "jumps". That's the performance issue. You can also see the issue with your third swipe, when the post jumps again. |
I'm seeing this same issue on iOS as well. |
this is a real performance killer in my applications any idea of timeframe ? |
One suggestion is creating a formatted string cache so that we don't have to re-build each attributed text over and over. |
Any other idea :D ? |
@jonathanantoine I haven't tried this, but recently HTML formatted text was added to Label. Update your Nuget package and see if you can leverage that. Also, once CollectionView is ready, performance should be somewhat better. |
Where a label has GC_MINOR: (Nursery full) time 24.41ms, stw 25.18ms promoted 484K major size: 3056K in use: 2258K los size: 2048K in use: 1461K |
Same issue in Android. The performance hit was noticable in 3.6.0.344457, but it became unacceptable in 4.4.0.991477. We've used FormattedText to concat two DateTimes with a hyphen in the middle. The solution was to do the concatenation in ViewModel instead of View and to get rid of FormattedText. |
We gave up and rewrote every page of XAML that used formatted text to not use it as the performance was below what a customer would accept. |
What annoys me is they keep adding new features but have yet to fix the basics. |
@chrisfoulds Completely agree, these kinds of issues need to be addressed first. I understand the Xamarin team have alot of work to prioritize but @samhouts can we please get the essentials working prior to adding new shiny features. Every time a new feature gets added theres always a handful of new tickets that open on them and things like these get left way behind. This was a actually a pretty hard to spot issue and will probably catch alot of devs by surprise. |
We created CollectionView (yes, a shiny new control, don't be mad at me 😂) with the hope of resolving performance issues with ListView. It's using more performant native controls, and it has fewer layers of abstraction. Would you be willing to convert your ListView to a CollectionView to see if this issue is resolved there? Thanks! |
@samhouts when we get the chance we will check on CollectionView, we had partially migrated to CollectionView in some of our projects but had to roll back some due to bugginess/issues on iOS that was unacceptable for production. Some tickets I had raised and other devs, we just need to find some time to go back and update and check if those issues have been resolved. As far as android is concerned we have been very impressed with collectionview over listview, much more performant and flexible so we look forward to fully migrating hopefully not too far away 👍 |
The same issues still happens when using CollectionView @samhouts . |
Wow i just had this problem with xf 4.8 and collectionview. |
Hi, as a workaround, can create a Label CustomRenderer and assign So write Native Spans, i think performance are better. |
I'm having the same issue .... and using the latest Xamarin forms version. |
Description
I am currently working on an Instagram type app where there is a "feed" that contains posts of an image and some text. In that text, there could be user mentions or hashtags. I needed to show those in blue, so I used FormattedString and Spans, and using the FormattedText property on the label. However, when the list is loaded, scrolling performance is degraded.
However, the scrolling performance issues go away when I switch to using the Text property on the label, the scrolling performance issues went away, but I also lose my highlighting.
I would like to know if I am doing something wrong. I originally thought the issue was the images(which are typically the issue), but once I started playing with the text, I noticed that the text was the cause of the scrolling issues.
Steps to Reproduce
Expected Behavior
Scrolling performance shouldn't be changed when using FormattedText vs. Text with a Label.
Actual Behavior
Performance is changed significantly.
Basic Information
Reproduction Link
ListViewTest.zip
The text was updated successfully, but these errors were encountered: