xamarin/Xamarin.Forms

ListView with Label.FormattedText in DataTemplate causes performance issues

Ouverte

#5 087 ouverte le 29 janv. 2019

 (24 commentaires) (4 réactions) (0 personne assignée)C# (1 926 forks)batch import
a/listviewa/performancee/6 :clock6:help wantedm/high impact :black_large_square:p/iOS 🍎t/bug :bug:up-for-grabs

Métriques du dépôt

Stars
 (5 644 étoiles)
Métriques de merge PR
 (Métriques PR en attente)

Description

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

  1. Run sample app below
  2. Scroll up and down
  3. Notice scrolling performance issues.
  4. Stop app, go to MainPage.xaml, in the DataTemplate for the list view, comment out the label using FormattedText and uncomment out the label using Text.
  5. Run app again
  6. Notice that there aren't any scrolling performance issues.

Expected Behavior

Scrolling performance shouldn't be changed when using FormattedText vs. Text with a Label.

Actual Behavior

Performance is changed significantly.

Basic Information

  • Version with issue: XF 3.4.0.1029999
  • Last known good version: N/A
  • IDE: VS for Mac
  • Platform Target Frameworks:
    • iOS: 12.1
  • Nuget Packages:
    • FreshMvvm
    • Newtonsoft.Json
    • PropertyChanged.Fody
    • Xamarin.Essentials
    • Xamarin.FFImageLoading.Forms
    • Xamarin.FFImageLoading.Transformations
  • Affected Devices:
    • iPhone 6 - 11.2.1

Reproduction Link

ListViewTest.zip

Guide contributeur