AndreiMisiukevich / CardView

CardsView | CarouselView | CoverflowView | CubeView for Xamarin.Forms
MIT License
711 stars 114 forks source link

Poor performance when resizing UWP application #416

Closed daltzctr closed 2 years ago

daltzctr commented 2 years ago

Problem Summary: Whenever I render a page that has a large amount of data (say 1000 rows of a ListView), the entire CarouselView will slow the application down tremendously when doing any rendering work.

Details: My CarouselView is binded to a List of ContentView "pages". Each "page" has it's own layout, commands, etc. Whenever I navigate to a page and press a button that renders ~200 items of a ListView and attempt to resize the application after this has been rendered, performance is greatly degraded. This performance persists when navigating between "pages" or "carousel items" and will only be resolved whenever the root CarouselView gets garbaged collected.

Expected Behavior: CarouselView does not attempt to render non-visible items.

Attached config:


        <cards:CarouselView
            x:Name="CarouselPageRoot"
            Grid.Column="0"
            Grid.ColumnSpan="{x:OnPlatform UWP=1,
                                           Android=2}"
            BackgroundColor="Transparent"
            IsAutoNavigatingAnimationEnabled="False"
            IsCyclical="False"
            IsPanSwipeEnabled="True"
            IsUserInteractionEnabled="{x:OnPlatform UWP=False,
                                                    Android=True}"
            IsViewReusingEnabled="{x:OnPlatform UWP=False,
                                                Android=True}"
            ItemAppeared="CarouselPageRoot_ItemAppeared"
            ItemDisappearing="CarouselPageRoot_ItemDisappearing"
            MoveThresholdDistance="40">
            <cards:CarouselView.ItemTemplate>
                <DataTemplate>
                    <ContentView Content="{Binding .}" />
                </DataTemplate>
            </cards:CarouselView.ItemTemplate>
        </cards:CarouselView>
AndreiMisiukevich commented 2 years ago

try to set MaxChildrenCount to 2 and DesiredMaxChildrenCount to 2

daltzctr commented 2 years ago

Looks like the issue still seems to be occurring with MaxChildrenCount and DesiredMaxChildrenCount both set to 2.

AndreiMisiukevich commented 2 years ago

Sorry, I don't think I can fix it. Xamarin Forms does not have good performance especially on UWP

daltzctr commented 2 years ago

@AndreiMisiukevich Is there a way to let the GC know when a page is no longer rendered to GC? It seems that even with the above options, the page is constantly kept. I'm fine with sacrificing a bit of scrolling performance to let this page constructor rerun.

AndreiMisiukevich commented 2 years ago

I don't understand why the perfornace decreases in case of window resizing. It doesn't create a new one each time you resize the window, right?

Also, you manually can remove the page from carouselview (e.g. when ItemDisappeared is raised). Just remove all CarouselView children except CurrentView

daltzctr commented 2 years ago

It seems like it's trying to rerender each of the Grid elements, even when it's not visible on the screen.

Yeah, I can give that a shot.