alexrainman / CarouselView

CarouselView control for Xamarin Forms
MIT License
436 stars 176 forks source link

[UWP] - App crash when displaying the Carousel View #526

Closed lykscabrales closed 3 years ago

lykscabrales commented 5 years ago

The app is crashing when the page with a Carousel view that has been opened. But this is working fine with the Android and iOS platform. The crash issue in UWP has started after the upgrade of Xamarin.Forms to its latest version and when we transfer from PCL to .NET Standard 2.0. But previously it was also working fine.

I attached the screenshot of the error we've got.

Screen Shot 2019-06-19 at 4 20 20 PM
alexrainman commented 5 years ago

I am investigating this. If i cannot reproduce it after updating to latest XF then the issue is related to versioning.

morphinapg commented 5 years ago

I don't get a crash, but the CarouselView doesn't appear when I'm running my UWP app in release mode. Works perfectly fine in Debug mode, and works in Android in both modes. I have no way to test iOS at the moment. Not sure if this is the same issue or something different.

It does appear the object is loading in some form, because my code does not crash when trying to access it, but some properties return "The runtime refused to evaluate the expression at this time."

For example, in code I set ItemsSource, Position, and IsVisible, and the code doesn't throw an exception, but then when I break it just says "The runtime refused to evaluate the expression at this time." for those values.

This appears to be caused by "compile with .net native toolchain"

forlayo commented 5 years ago

I am getting exactly the same issue on UWP while running on Debug, as it's a unmanaged exception

System.ArgumentException: Delegate to an instance method cannot have null 'this'.\r\n at System.MulticastDelegate.ThrowNullThisInDelegateToInstance()\r\n at CarouselView.FormsPlugin.UWP.CarouselViewRenderer.FlipView_Loaded(Object sender, RoutedEventArgs e)

https://imgur.com/a/eYYgmDp

I am using latest version of Xamarin Forms ( 4.1.0.673156 ) and lastest version of CarouselView.FormsPlugin ( 5.2.0 )

Happens 100% of times for me.

carlosascastro commented 4 years ago

Adding my cents here.. I got this crash at OnAppearing by performing a Clear call over the ObservableCollection which is set as control's ItemSource.

public ProductPage(string productId)
{
    InitializeComponent();

    this.productId = productId;

    this.products = new ObservableCollection<ProductGalleryDTO>();
    this.ProductGallery.ItemsSource = this.products;
}

protected override void OnAppearing()
{
    base.OnAppearing();

    // Note: this causes the issue in my case
    //this.products.Clear();

    this.GetProductDetails();
}

Hope that helps.

DRAirey1 commented 2 years ago

I'm getting the same error on a page with a CarouselView. In my case, I have a CarouselView as a landing page for the app. This is the first page a new user will see and it gives them the option of signing up or signing in. After the user logs in, I replace the landing page CarouselView with a NavigationPage and use standard navigation for the app. When the user logs out, I again replace the root page with the original page with the CarouselView:

            var landingView = this.serviceProvider.GetRequiredService<LandingView>();
            this.MainPage = landingView;

And I get the error in the original post, but only on the second attempt. If I change the LandingView to be Transient instead of Singelton, then the problem goes away. It would appear that the CarouselView.OnAppearing isn't re-entrant in UWP.