xamarin/Xamarin.Forms

ListView with Label.FormattedText in DataTemplate causes performance issues

开放

#5,087 创建于 2019年1月29日

 (24 条评论) (4 个反应) (0 位负责人)C# (1,926 个派生)batch import
a/listviewa/performancee/6 :clock6:help wantedm/high impact :black_large_square:p/iOS 🍎t/bug :bug:up-for-grabs

仓库指标

星标
 (5,644 个星标)
PR 合并指标
 (30 天内没有已合并 PR)

描述

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

贡献者指南