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

[Bug] [UWP] Regression bug on CollectionView included in FlyoutPage.Detail #15356

Open
DDHSchmidt opened this issue May 6, 2022 · 7 comments
Labels
a/collectionview p/UWP s/unverified New report that has yet to be verified t/bug 🐛

Comments

@DDHSchmidt
Copy link

Description

Service Release 9 (5.0.0.2337) introduced a regression that leads to an exception/crash on UWP whenever we revisit a view that contains a CollectionView.
We use a FlyoutPage in our mainpage and whenever we present a FlyoutPage.Detail with a CollectionView for the second time, it will crash with a stacktrace containing the lines

System.NotImplementedException: The layout is not implemented
   at Xamarin.Forms.Platform.UWP.StructuredItemsViewRenderer`1.SelectListViewBase()
   at Xamarin.Forms.Platform.UWP.ItemsViewRenderer`1.SetUpNewElement(ItemsView newElement)
   at Xamarin.Forms.Platform.UWP.SelectableItemsViewRenderer`1.SetUpNewElement(ItemsView newElement)
   at Xamarin.Forms.Platform.UWP.ItemsViewRenderer`1.OnElementChanged(ElementChangedEventArgs`1 args)
   at Xamarin.Forms.Platform.UWP.VisualElementRenderer`2.SetElement

Downgrading to Service Release 8 (5.0.0.2291) eliminates the crash.

We suspect the regression was introduced with PullRequest 14780 since it includes a check for StructuredItemsView

Steps to Reproduce

  1. Open a Flyout page, containing a CollectionView on UWP
  2. Navigate to another Detail view
  3. Revisit the first view

Expected Behavior

FlyoutPage renders the content, including all CollectionViews

Actual Behavior

Crash with "System.NotImplementedException: The layout is not implemented"

Basic Information

  • Version with issue: 5.0.0.2337
  • Last known good version: 5.0.0.2291
  • Platform Target Frameworks:
    • UWP: 16299

Reproduction Link

Please see the attached reproduction project
UWPCollectionViewNavigationCrash.zip

Workaround

Downgrade to Service Release 8 (5.0.0.2291)

@jfversluis
Copy link
Member

@YZahringer I know it has been a while, but still wanted to ping you to see if you maybe have an idea on this one :)

@YZahringer
Copy link
Contributor

@jfversluis I think the regression is caused by the ItemsLayout null assignation on https://github.com/xamarin/Xamarin.Forms/pull/14780/files#r734946106.

As commented, I had my doubts in the past about this, but the memory leak persisted otherwise.

A possible way to solve this regression and avoid the memory leak, would be to assign a new LinearItemsLayout or GridItemsLayout instead of null.

@DDHSchmidt
Copy link
Author

So... can this be tested or will we have to remain on the old version forever?

@DDHSchmidt
Copy link
Author

@jfversluis & @YZahringer
I'm more than willing to test anything you throw at me.
If there is a way to to bundle this change in a NuGet package I'll gladly try it out in our apps.

@shajiraghav
Copy link

Any ETA for fix?
I am using a workaround of assigning ItemsLayout with a new LinearItemsLayout on revisiting the view.

@mrgenixus
Copy link

LinearItemsLayout

@shajiraghav Do you have any example code I could reference for your work around? I'm having this issue in a production project and would like to update to the latest build, but can't because of this issue on UWP

@melvyniandrag
Copy link

melvyniandrag commented Nov 3, 2023

Hello,
I am having this issue when the CollectionView when I have the collectionview inside a scroll view.

To make my apps responsive I usually put a ScrollView in my content pages, and put a grid in the scroll view.

Then I use this pattern I picked up somewhere on the internet:

        void UpdateLayout()
        {

            if (width < CUTOFF_WIDTH && height < CUTOFF_HEIGHT)
            {
                this.Content = scrollView;
                scrollView.Content = mainGrid;
                SetupScrollingPortraitLayout();
            }
            else if ( width >= CUTOFF_WIDTH && height < CUTOFF_HEIGHT)
            {
                this.Content = scrollView;
                scrollView.Content = mainGrid;
                SetupScrollingLandscapeLayout();
            }
            else if (width < CUTOFF_WIDTH && height >= CUTOFF_HEIGHT)
            {
                scrollView.Content = null;
                this.Content = mainGrid;
                SetupPortraitLayout();
            }
            else // width >= CUTOFF_WIDTH && height >= CUTOFF_HEIGHT
            {
                scrollView.Content = null;
                this.Content = mainGrid;
                SetupLandscapeLayout();
            }

        }

I call the above in OnSizeAllocated whenever the page size has changed. If I get rid of this craziness and just leave the scroll view at all times, the crash goes away. I just have the scroll view for very small screen sizes like on desktop if the user shrinks the window on a small laptop screen.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a/collectionview p/UWP s/unverified New report that has yet to be verified t/bug 🐛
Projects
None yet
Development

No branches or pull requests

6 participants