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

[Bug] UWP: CollectionView in CarouselView crashes when resizing the window #10897

Closed
JogyBlack opened this issue May 30, 2020 · 3 comments · Fixed by #12676
Closed

[Bug] UWP: CollectionView in CarouselView crashes when resizing the window #10897

JogyBlack opened this issue May 30, 2020 · 3 comments · Fixed by #12676
Assignees
Labels
a/carouselview a/collectionview blocker Issue blocks next stable release. Prioritize fixing and reviewing this issue. e/2 🕑 2 i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often t/bug 🐛
Milestone

Comments

@JogyBlack
Copy link
Contributor

Description

Xamarin.Forms app with a UWP project. A CarouselView contains a template with a CollectionView inside. When the page is displayed in a window, and the user starts resizing the window, at some point the app crashes.

Steps to Reproduce

This is the Page XAML:

  <CarouselView ItemsSource="{Binding CarouselItems}">
    <CarouselView.ItemTemplate>
      <DataTemplate>
        <CollectionView ItemsSource="{Binding Items}">
          <CollectionView.ItemTemplate>
            <DataTemplate>
              <Label Text="{Binding Text}" />
            </DataTemplate>
          </CollectionView.ItemTemplate>
        </CollectionView>
      </DataTemplate>
    </CarouselView.ItemTemplate>
  </CarouselView>

The ViewModel is a simple one:

  public class TestItemViewModel
  {
    public string Text { get; set; }
  }

  public class TestViewModel
  {
    public List<TestItemViewModel> Items { get; set; }
  }

  public class TestPageViewModel
  {
    public List<TestViewModel> CarouselItems { get; set; }
  }

The BindingContext of the page:

      TestPageViewModel vm = new TestPageViewModel();
      vm.CarouselItems = new List<TestViewModel>();
      vm.CarouselItems.Add(new TestViewModel() { Items = new List<TestItemViewModel>() { new TestItemViewModel() { Text = "Item1" }, new TestItemViewModel() { Text = "Item2" } } });
      BindingContext = vm;

Expected Behavior

The app should not crash when resized.

Actual Behavior

The app crashes when resized:
System.AccessViolationException
HResult=0x80004003
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source=
StackTrace:

No useful stack trace is available.

Basic Information

  • Version with issue: 4.6
  • Last known good version: Same crash with previous versions, ever since CarouselView was introduced
  • IDE: Visual Studio 2019
  • Platform Target Frameworks:
    • UWP: 16299
  • Nuget Packages:
  • Affected Devices: Windows Desktop
@JogyBlack JogyBlack added s/unverified New report that has yet to be verified t/bug 🐛 labels May 30, 2020
@JogyBlack
Copy link
Contributor Author

TestCarousel2.zip
Sample project - compile and run under Windows, then grab the border of the app window and start resizing it. After some resizes it crashes.

@jsuarezruiz jsuarezruiz added a/carouselview a/collectionview i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often labels Jun 1, 2020
@jsuarezruiz
Copy link
Contributor

Thanks for the reproduction sample. I have done some tests and can reproduce the issue. Could it be the same as #10673 fixed by #10686?. I will do more tests to verify it.

@jsuarezruiz jsuarezruiz removed the s/unverified New report that has yet to be verified label Jun 1, 2020
@fntc
Copy link
Contributor

fntc commented Jun 26, 2020

Getting that error when resizing:

System.IndexOutOfRangeException: Can't set CarouselView to position -1. ItemsSource has 3 items. at Xamarin.Forms.Platform.UWP.CarouselViewRenderer.UpdateFromPosition() at Xamarin.Forms.Platform.UWP.CarouselViewRenderer.OnElementPropertyChanged(Object sender, PropertyChangedEventArgs changedProperty) at System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e) at Xamarin.Forms.BindableObject.OnPropertyChanged(String propertyName) at Xamarin.Forms.Element.OnPropertyChanged(String propertyName) at Xamarin.Forms.BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, Object value, Boolean currentlyApplying, SetValueFlags attributes, Boolean silent) at Xamarin.Forms.BindableObject.SetValueCore(BindableProperty property, Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes) at Xamarin.Forms.BindableObject.SetValue(BindableProperty property, Object value, Boolean fromStyle, Boolean checkAccess) at Xamarin.Forms.Platform.UWP.CarouselViewRenderer.UpdateInitialPosition() at Xamarin.Forms.Platform.UWP.CarouselViewRenderer.OnListSizeChanged(Object sender, SizeChangedEventArgs e)

Xamarin.Forms 4.7.0.968

@samhouts samhouts added this to the 5.0.0 milestone Aug 13, 2020
@rmarinho rmarinho added the blocker Issue blocks next stable release. Prioritize fixing and reviewing this issue. label Oct 29, 2020
@jsuarezruiz jsuarezruiz self-assigned this Oct 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a/carouselview a/collectionview blocker Issue blocks next stable release. Prioritize fixing and reviewing this issue. e/2 🕑 2 i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often t/bug 🐛
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants