Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[iOS] UI Frozen When Adding Many Children To a Layout #3417

Open
endarea opened this issue Jul 27, 2018 · 4 comments
Open

[iOS] UI Frozen When Adding Many Children To a Layout #3417

endarea opened this issue Jul 27, 2018 · 4 comments
Labels
a/performance e/8 🕗 8 help wanted We welcome community contributions to any issue, but these might be a good place to start! inactive Issue is older than 6 months and needs to be retested p/iOS 🍎 t/bug 🐛 up-for-grabs We welcome community contributions to any issue, but these might be a good place to start!

Comments

@endarea
Copy link

endarea commented Jul 27, 2018

Description

To best describe this issue the repro project has the main page split in two:
1. On the left I create a StackView to which I add 1000 simple labels, programatically, at the press of the "FORMS" button. While the content is rendered the UI is completely frozen for many seconds, depending on the number of children. The rendering time increases exponentially, 200 children will not take twice as long as 100 children, but much more, reaching 35 seconds for 1000 labels on an iPhone X Simulator (iOS 11.4)

  • setting the children in XAML leads to the same poor performance
  • surprisingly, the Android version is smoother, though it's still slower than the native approach

2. On the right, at the press of "NATIVE" button I add a ContentView for which I have created some crude renderers (iOS and Android), enough to be able to add the same 1000 labels to the view from the native projects. The difference is huge, as illustrated by the screenshot.

freeze

EnsureChildrenOrder, BringSubviewToFront seem to be the bottleneck.

I have found some good discussions on the Forums about this, but no solution/workaround was found:

Expected Behavior

The UI shouldn't be frozen for so long, on 200 elements the usability is already reduced. A ListView is not always feasible to use, I'm thinking about an usecase where I would want to display a Data Grid to the users, set in a ScrollView with Orientation set to Both

Basic Information

  • Version with issue: 3.1.0.637273
  • Last known good version: -
  • IDE:
  • Platform Target Frameworks:
    • iOS: 11.4
    • Android: 8.1
  • Affected Devices: tried it on iPad Air 2, iPhone 5s, various simulators (including iPhone X) and Huawei Nexus 6P (API 27)

Reproduction Link

FreezeRepro.zip

@pauldipietro pauldipietro added this to New in Triage Jul 27, 2018
@jassmith jassmith moved this from New to Ready For Work in Triage Jul 30, 2018
@samhouts samhouts added this to To do in iOS Ready For Work Oct 15, 2018
@samhouts samhouts removed this from Ready For Work in Triage Oct 15, 2018
@samhouts samhouts added the inactive Issue is older than 6 months and needs to be retested label Jan 24, 2019
@samhouts samhouts added help-wanted up-for-grabs We welcome community contributions to any issue, but these might be a good place to start! help wanted We welcome community contributions to any issue, but these might be a good place to start! and removed help-wanted labels Jun 28, 2019
@bnSonic
Copy link

bnSonic commented Aug 18, 2019

Phew - it was 2015 when this problem was tracked down (as shown in the links in the original posting)
Now we have August 2019, Xamarin.Forms 4.x
This Problem still exists!

I'm running into this problem because:

  • For reasons i cannot use a ListView (don't let me get down that rabbit hole at this place :))
  • So i added a ScrollView on my Page
  • I create a StackLayout and add a lot Views to it (=this is fast)
  • then i do a: MyScrollView.Content = MyStackLayout; (= THIS takes a LONG TIME - as described above in the original posting and analyzed in the links in that posting

I was not able to Patch it with Mono.Cecil (because i'm not aware how that works and the sample from 2015 that you can find in the links doesn't work here on iOS)

It doesn't matter if i'm using a StackLayout or an AbsoluteLayout
The Bindings doesn't matter (i removed them all for measurement - it's a UI thing)

Really: Is there any chance to workaround that performance problem? Any chance to build a more complex or scrolling layout with good performance when you cannot use ListView?

@velocitysystems
Copy link
Contributor

@bnSonic I would recommend looking into the new CollectionView.

@samhouts samhouts removed the inactive Issue is older than 6 months and needs to be retested label Feb 6, 2020
@samhouts samhouts added the inactive Issue is older than 6 months and needs to be retested label Jul 17, 2020
@samhouts samhouts added this to the 5.0.0 milestone Aug 13, 2020
@samhouts samhouts added this to To do in vNext+1 (5.0.0) Aug 14, 2020
@samhouts samhouts removed this from the 5.0.0 milestone Nov 2, 2020
@AlleSchonWeg
Copy link
Contributor

Hi,
i have the same issue. I can't use ListView, because i need scrolling in both directions. I can confirm that:
MyScrollView.Content = MyStackLayout;
takes very long. 300 views take 9 seconds with iOS and a with android a few ms.
Somebody knows a workaround?
Thank you.

@AlleSchonWeg
Copy link
Contributor

@PureWeen
Is PR 8232 (#8231) also the fix for this issue?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a/performance e/8 🕗 8 help wanted We welcome community contributions to any issue, but these might be a good place to start! inactive Issue is older than 6 months and needs to be retested p/iOS 🍎 t/bug 🐛 up-for-grabs We welcome community contributions to any issue, but these might be a good place to start!
Projects
Development

No branches or pull requests

6 participants