Xamarin.Forms icon indicating copy to clipboard operation
Xamarin.Forms copied to clipboard

[Bug] CarouselView crashes on iOS with null DataTemplate's BindingContext

Open aubiyko opened this issue 2 years ago • 0 comments

Description

CarouselView crashes while scrolling on iOS with null DataTemplate's BindingContext.

Steps to Reproduce

  1. Use reproduction code.
  2. Scroll in forward direction

Expected Behavior

Everything works.

Actual Behavior

System.ArgumentNullException: Value cannot be null.
Parameter name: key
  at System.Collections.Generic.Dictionary`2[TKey,TValue].FindEntry (TKey key) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/Collections/Generic/Dictionary.cs:380 
  at System.Collections.Generic.Dictionary`2[TKey,TValue].TryGetValue (TKey key, TValue& value) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/Collections/Generic/Dictionary.cs:888 
  at Xamarin.Forms.Platform.iOS.ItemsViewController`1[TItemsView].UpdateTemplatedCell (Xamarin.Forms.Platform.iOS.TemplatedCell cell, Foundation.NSIndexPath indexPath) [0x00031] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ItemsViewController.cs:278 
  at Xamarin.Forms.Platform.iOS.CarouselViewController.GetCell (UIKit.UICollectionView collectionView, Foundation.NSIndexPath indexPath) [0x0006a] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\CarouselViewController.cs:47 
  at (wrapper managed-to-native) UIKit.UIApplication.xamarin_UIApplicationMain(int,intptr,intptr,intptr,intptr&)
  at UIKit.UIApplication.UIApplicationMain (System.Int32 argc, System.String[] argv, System.IntPtr principalClassName, System.IntPtr delegateClassName) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.4.0.6/src/Xamarin.iOS/UIKit/UIApplication.cs:58 
  at UIKit.UIApplication.Main (System.String[] args, System.Type principalClass, System.Type delegateClass) [0x0003b] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.4.0.6/src/Xamarin.iOS/UIKit/UIApplication.cs:94 
  at XFiOSCarouselDataTemplateRotationBug.iOS.Application.Main (System.String[] args) [0x00001] in C:\Users\user1\source\repos\XFiOSCarouselDataTemplateRotationBug\XFiOSCarouselDataTemplateRotationBug.iOS\Main.cs:9

Basic Information

  • Version with issue: 5.0.0.2578+978-sha.076623b19-azdo.7433730, 5.0.0.2599-pre1+sha.ce1731b0a-azdo.7744984
  • Last known good version: 5.0.0.1931+616-sha.af2c1b01a-azdo.4399076
  • Platform Target Frameworks:
    • iOS: 11.1
  • NuGet Packages: Xamarin.Forms
  • Affected Devices: Simulator (iOS 16.4), iPhone 11 (iOS 16.5.1)

Environment

Show/Hide Visual Studio info
Microsoft Visual Studio Community 2022
Version 17.6.4
VisualStudio.17.Release/17.6.4+33815.320
Microsoft .NET Framework
Version 4.8.09037

Installed Version: Community

Visual C++ 2022   00482-90000-00000-AA409
Microsoft Visual C++ 2022

ASP.NET and Web Tools   17.6.326.62524
ASP.NET and Web Tools

Azure App Service Tools v3.0.0   17.6.326.62524
Azure App Service Tools v3.0.0

C# Tools   4.6.0-3.23259.8+c3cc1d0ceeab1a65da0217e403851a1e8a30086a
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Extensibility Message Bus   1.4.21 (main@8f226a8)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Mono Debugging for Visual Studio   17.6.41 (790a401)
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager   6.6.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

Razor (ASP.NET Core)   17.6.0.2327201+a6a61fdfa748eaa65aab53dab583276e26af4a3e
Provides languages services for ASP.NET Core Razor.

SQL Server Data Tools   17.6.13.0
Microsoft SQL Server Data Tools

SQL Server Reporting Services   16.0.20309.0
Microsoft SQL Server Reporting Services Designers 
Version 16.0.20309.0

Syntax Visualizer   1.0
An extension for visualizing Roslyn SyntaxTrees.

TypeScript Tools   17.0.20329.2001
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools   4.6.0-3.23259.8+c3cc1d0ceeab1a65da0217e403851a1e8a30086a
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools   17.6.0-beta.23174.5+0207bea1afae48d9351ac26fb51afc8260de0a97
Microsoft Visual F# Tools

Visual Studio IntelliCode   2.2
AI-assisted development for Visual Studio.

Visual Studio Spell Check Everywhere   VSSpellCheckEverywhere
An extension that enables spell checking within any Visual Studio file editor or tool window that uses WPF text boxes.
https://GitHub.com/EWSoftware/VSSpellChecker

Visual Studio Spell Checker   VSSpellChecker
An editor extension that checks the spelling of comments, strings, and plain text as you type or interactively with tool windows.
https://GitHub.com/EWSoftware/VSSpellChecker

VisualStudio.DeviceLog   1.0
Information about my package

VisualStudio.Mac   1.0
Mac Extension for Visual Studio

VSPackage Extension   1.0
VSPackage Visual Studio Extension Detailed Info

Xamarin   17.6.0.251 (d17-6@318364c)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer   17.6.6.0 (remotes/origin/d17-6@cb430751d1)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates   17.6.32 (98c12a2)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK   13.2.0.6 (d17-5/a200af1)
Xamarin.Android Reference Assemblies and MSBuild support.
    Mono: 6dd9def
    Java.Interop: xamarin/java.interop/d17-5@149d70fe
    SQLite: xamarin/sqlite/3.40.1@68c69d8
    Xamarin.Android Tools: xamarin/xamarin-android-tools/d17-5@9f02d77


Xamarin.iOS and Xamarin.Mac SDK   16.4.0.6 (97731c92c)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

Xcode 14.3.1 (14E300c)

Reproduction Link

MainPage.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:iOS="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
             x:Class="XFiOSCarouselDataTemplateBug.MainPage"
             iOS:Page.UseSafeArea="True">
    <CarouselView>
        <CarouselView.ItemsSource>
            <x:Array Type="{Type x:String}">
                <x:String>1</x:String>
                <x:Null/>
            </x:Array>
        </CarouselView.ItemsSource>
        <CarouselView.ItemsLayout>
            <LinearItemsLayout Orientation="Horizontal"/>
        </CarouselView.ItemsLayout>
        <CarouselView.ItemTemplate>
            <DataTemplate>
                <Label Text="{Binding ., TargetNullValue='End'}"/>
            </DataTemplate>
        </CarouselView.ItemTemplate>
    </CarouselView>
</ContentPage>

Note: Orientation does not matter.

aubiyko avatar Jul 11 '23 08:07 aubiyko