Declined
Last Updated: 31 Jan 2024 09:22 by ADMIN
Robert
Created on: 25 Jan 2022 13:49
Category: ListView
Type: Bug Report
0
[UWP] ListView crashes

This is from our production app. Cannot reproduce it, don't know exactly when or why it happens; we just have crashes logged to have happened to 9 users in the past year with a total of 30 occurences.

These are unhandled UWP exceptions, which mean that our app goes poof :)

System.ArgumentException: Value does not fall within the expected range at
System.ThrowHelper.ThrowAddingDuplicateWithKeyArgumentException(Object) + 0xf     at
Telerik.UI.Xaml.Controls.Data.ListView.Model.BaseLayoutStrategy.RecycleLocally() + 0x320     at Telerik.UI.Xaml.Controls.Data.ListView.Model.BaseLayoutStrategy.MeasureContent(RadSize, Double, Double) + 0xd     at Telerik.UI.Xaml.Controls.Data.ListView.Model.LayoutController.MeasureVertical(RadSize) + 0x1b9     at Telerik.UI.Xaml.Controls.Data.ListView.Model.LayoutController.MeasureContent(RadSize) + 0x42     at Telerik.UI.Xaml.Controls.Data.ListViewModel.MeasureContent(RadSize) + 0x2e     at Telerik.UI.Xaml.Controls.Data.RadListView.OnContentPanelMeasure(RadSize) + 0x17f     at Telerik.UI.Xaml.Controls.Data.ListView.ListViewPanel.MeasureOverride(Size) + 0x60     at Windows.UI.Xaml.FrameworkElement.global::Windows.UI.Xaml.IFrameworkElementOverrides.MeasureOverride(Size) + 0x26

 

System.ArgumentException: An item with the same key has already been added    at
System.ThrowHelper.ThrowAddingDuplicateWithKeyArgumentException(Object) + 0xf     at Telerik.UI.Xaml.Controls.Data.ListView.Model.BaseLayoutStrategy.RecycleLocally() + 0x320     at Telerik.UI.Xaml.Controls.Data.ListView.Model.BaseLayoutStrategy.MeasureContent(RadSize, Double, Double) + 0xd     at Telerik.UI.Xaml.Controls.Data.ListView.Model.LayoutController.MeasureVertical(RadSize) + 0x1b9     at Telerik.UI.Xaml.Controls.Data.ListView.Model.LayoutController.MeasureContent(RadSize) + 0x42     at Telerik.UI.Xaml.Controls.Data.ListViewModel.MeasureContent(RadSize) + 0x2e     at Telerik.UI.Xaml.Controls.Data.RadListView.OnContentPanelMeasure(RadSize) + 0x17f     at Telerik.UI.Xaml.Controls.Data.ListView.ListViewPanel.MeasureOverride(Size) + 0x60     at Windows.UI.Xaml.FrameworkElement.global::Windows.UI.Xaml.IFrameworkElementOverrides.MeasureOverride(Size) + 0x26

12 comments
ADMIN
Didi
Posted on: 31 Jan 2024 09:22

Item status changes to Declined, due to inactivity.

 

Regards,
Didi
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Robert
Posted on: 09 Mar 2022 13:01

Hi,

We went into production today with some changes - a larger buffer and a changed layout with grids instead of stacklayouts and removed verticaloptions.

I'll be monitoring the logs to see what happens after our users upgrade to the new version.

ADMIN
Didi
Posted on: 21 Feb 2022 11:40

Hi Robert,

Yes, give all suggestions a try and let me know if they were of help resolving the exception. 

Regards,
Didi
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Robert
Posted on: 21 Feb 2022 10:57

Hello,

We can't reproduce it either. We'll see about BufferItemsCount, grid-in-stack, and Fill in the next release, then keep monitoring the logs. Not much else that either of us can do...

Yes, we use Prism for navigation, and this is basically a report page, one of many, people navigate between them.

ADMIN
Didi
Posted on: 14 Feb 2022 15:50

Hello Robert,

Thank you for the provided ListView definition.

I have updated my sample app, still cannot reproduce the crash. I have noticed the following.

- the LoadOnDemand is used and the BufferItemsCount is bound to PageSize property, the issue may occur because of this binding, if you resize the window, the page's size changes. 

- ListView is inside Star grid row, but the grid is inside a StackLayout. Regarding the usage of stack in a combination of ListView, we have this article in our documentation.: https://docs.telerik.com/devtools/xamarin/troubleshooting/controls-are-not-appearing 

- Prism is mentioned in the page's namespaces. Do you use prism for navigation between the pages? 

The issue may occur because of the above listed findings. I will need a repro project to research the case in details.

Regards,
Didi
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Robert
Posted on: 08 Feb 2022 09:05
OK, sorry, it's not a grid error, we have a grid in a grid, and RowDefinitions="*" for the grid that contains the listview :)
Robert
Posted on: 08 Feb 2022 09:04

Hi,

Grid.Row on the listview seems to be an error - probably left from copypasting from another earlier layout. We can try removing that and VerticalOptions and pushing into production in the next release, but that's in a couple of weeks. It's not an error we have ever been able to reproduce so we'll have to wait and see if there's any improvement with our users.

Here's the entire page XAML (it's a flyout detail page).

Note that this is for "An item with the same key has already been added." - the "Value does not fall within the expected range." exception doesn't mention which page is involved.

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
    x:Class="ournamespace.UI.Pages.Reports.InventoryStatusReportPage"
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:conv="clr-namespace:ournamespace.UI.Converters"
    xmlns:local="clr-namespace:ournamespace.UI.Pages.Reports"
    xmlns:models="clr-namespace:ournamespace.Models;assembly=ournamespace.Models"
    xmlns:prism="http://prismlibrary.com"
    xmlns:rend="clr-namespace:ournamespace.UI.Renderers"
    xmlns:telerikDataControls="clr-namespace:Telerik.XamarinForms.DataControls;assembly=Telerik.XamarinForms.DataControls"
    xmlns:telerikListView="clr-namespace:Telerik.XamarinForms.DataControls.ListView;assembly=Telerik.XamarinForms.DataControls"
    xmlns:telerikListViewCommands="clr-namespace:Telerik.XamarinForms.DataControls.ListView.Commands;assembly=Telerik.XamarinForms.DataControls"
    x:Name="page"
    prism:ViewModelLocator.AutowireViewModel="True">
 
    <ContentPage.Resources>
        <ResourceDictionary>
            <conv:NotConverter x:Key="NotConverter" />
        </ResourceDictionary>
        <DataTemplate x:Key="MobileHeader">
            <Grid ColumnDefinitions="*,100,100" RowDefinitions="38,2">
                <Label Grid.Column="0" Style="{StaticResource ReportHeaderLabel}" Text="Naziv" />
                <Label Grid.Column="1" HorizontalTextAlignment="Center" Style="{StaticResource ReportHeaderLabel}" Text="J.mj." />
                <Label Grid.Column="2" HorizontalTextAlignment="End" Style="{StaticResource ReportHeaderLabel}" Text="Ukupno" />
                <BoxView Grid.Row="1" Grid.ColumnSpan="3" BackgroundColor="LightGray" HeightRequest="2" />
            </Grid>
        </DataTemplate>
        <DataTemplate x:Key="inventoryStatusHeader">
            <Grid ColumnDefinitions="140,*,80,120" RowDefinitions="38,2">
                <Label Grid.Column="0" Style="{StaticResource ReportHeaderLabel}" Text="Šifra" />
                <Label Grid.Column="1" Style="{StaticResource ReportHeaderLabel}" Text="Naziv" />
                <Label Grid.Column="2" HorizontalTextAlignment="Center" Style="{StaticResource ReportHeaderLabel}" Text="J.mj." />
                <Label Grid.Column="3" HorizontalOptions="End" Style="{StaticResource ReportHeaderLabel}" Text="Ukupno" />
                <BoxView Grid.Row="1" Grid.ColumnSpan="4" BackgroundColor="LightGray" HeightRequest="2" />
            </Grid>
        </DataTemplate>
    </ContentPage.Resources>
    <StackLayout Margin="0" Padding="0" x:DataType="local:InventoryStatusReportPageViewModel" BackgroundColor="{OnPlatform Android={StaticResource Droid_DefaultBackgroundColor}}" Spacing="0">
        <local:NavigationBar />
        <BoxView IsVisible="{OnPlatform UWP=False, Android={OnIdiom Tablet=False, Phone=True}}" Style="{StaticResource BoxViewLine}" />
        <Grid Margin="0" Padding="15" BackgroundColor="{OnPlatform Android={StaticResource Droid_DefaultBackgroundColor}, UWP={StaticResource UWP_DefaultBackgroundColor}}" HorizontalOptions="FillAndExpand" RowDefinitions="Auto,*" RowSpacing="0" VerticalOptions="FillAndExpand">
            <StackLayout Grid.Row="0" Margin="0" Padding="0" Spacing="0">
                <StackLayout Margin="0" Padding="0" Orientation="Vertical" Spacing="0">
                    <Label FontSize="{OnPlatform Android=18, UWP=24}" HorizontalOptions="Start" IsVisible="{OnPlatform UWP=True, Android=False}" Text="{Binding Parameter.DisplayName}" TextColor="{OnPlatform Android={StaticResource Droid_DefaultTextColor}, UWP={StaticResource UWP_AccentTextColor}}" VerticalOptions="Center" />
                    <rend:CustomButton Margin="0,5" BackgroundColor="{StaticResource Droid_AccentTextColor}" ButtonType="PrimaryButton" Command="{Binding PrintItemCommand}" CornerRadius="{OnPlatform Android=5}" HeightRequest="{OnPlatform Android=35}" IsVisible="{Binding CanPrint}" Text="Ispiši izvještaj" TextColor="{OnPlatform Android=White}" />
                </StackLayout>
 
                <StackLayout Padding="{OnIdiom Phone='0,15,15,15', Default=15}" HorizontalOptions="Center" IsVisible="{Binding NoItemsOrLoadingError}">
                    <Label FontSize="Body" IsVisible="{Binding IsBusy, Converter={StaticResource NotConverter}}" Text="{Binding EmptyListMessage}" TextColor="{OnPlatform Android={StaticResource Droid_DefaultTextColor}, UWP={StaticResource UWP_DefaultTextColor}}" />
                </StackLayout>
            </StackLayout>
 
            <Grid Grid.Row="1" HorizontalOptions="FillAndExpand" IsVisible="{Binding HasItems}" RowDefinitions="*" VerticalOptions="FillAndExpand">
                <telerikDataControls:RadListView
                    Grid.Row="0"
                    HeaderTemplate="{OnIdiom Phone={StaticResource MobileHeader}, Default={StaticResource inventoryStatusHeader}}"
                    HorizontalOptions="FillAndExpand"
                    IsLoadOnDemandActive="{Binding IsBusy}"
                    IsLoadOnDemandEnabled="True"
                    ItemsSource="{Binding ReportItems}"
                    LoadOnDemandBufferItemsCount="{Binding PageSize}"
                    LoadOnDemandMode="Automatic" SelectionMode="None" VerticalOptions="FillAndExpand" VerticalScrollBarVisibility="Always">
 
                    <telerikDataControls:RadListView.Commands>
                        <telerikListViewCommands:ListViewUserCommand Command="{Binding LoadItemsCommand}" Id="LoadOnDemand" />
                    </telerikDataControls:RadListView.Commands>
 
                    <telerikDataControls:RadListView.ItemStyle>
                        <telerikListView:ListViewItemStyle BorderColor="#e0e0e0" BorderLocation="Bottom" BorderWidth="1" />
                    </telerikDataControls:RadListView.ItemStyle>
 
                    <telerikDataControls:RadListView.ItemTemplate>
                        <DataTemplate>
                            <telerikListView:ListViewTemplateCell>
                                <telerikListView:ListViewTemplateCell.View>
                                    <Grid x:DataType="models:InventoryStatus" ColumnDefinitions="{OnIdiom Phone='*,100,100', Default='140,*,80,120'}" RowDefinitions="{OnPlatform Android='50', UWP='40'}" RowSpacing="0">
                                        <Label Grid.Column="{OnPlatform UWP=0, Android={OnIdiom Phone=0, Tablet=0}}" IsVisible="{OnIdiom Phone=False, Default=True}" Style="{StaticResource ReportLabel}" Text="{Binding ItemCode}" />
                                        <Label Grid.Column="{OnPlatform UWP=1, Android={OnIdiom Tablet=1, Phone=0}}" Style="{StaticResource ReportLabel}" Text="{Binding ItemName}" />
                                        <Label Grid.Column="{OnPlatform UWP=2, Android={OnIdiom Tablet=2, Phone=1}}" HorizontalOptions="{OnPlatform UWP=CenterAndExpand, Android=FillAndExpand}" HorizontalTextAlignment="{OnPlatform Android=Center}" Style="{StaticResource ReportLabel}" Text="{Binding UnitOfMeasure}" />
                                        <Label Grid.Column="{OnPlatform UWP=3, Android={OnIdiom Tablet=3, Phone=2}}" HorizontalTextAlignment="End" Style="{StaticResource ReportLabel}" Text="{Binding ItemsTotal, StringFormat='{0:N2}'}" />
                                    </Grid>
                                </telerikListView:ListViewTemplateCell.View>
                            </telerikListView:ListViewTemplateCell>
                        </DataTemplate>
                    </telerikDataControls:RadListView.ItemTemplate>
                </telerikDataControls:RadListView>
            </Grid>
        </Grid>
    </StackLayout>
 
</ContentPage>
ADMIN
Didi
Posted on: 08 Feb 2022 07:46

Hi Robert, 

Thank you for the additional information provided.

I will need the complete page's definition where the ListView is added. It is in Grid.Row 0 but what is the height request of the row. Also could you please remove the ListView VerticalOptions="FillAndExpand" and test whether this will solve the issue, or keep just Fill as option. 

Thank you for the understanding.

Regards,
Didi
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Robert
Posted on: 07 Feb 2022 06:52

We have something logged on our own. Here's info for a couple of users with exceptions that contain "ListView":

User 1
M San Grupa d.d. Desktop UWP Windows 10.0.19042.1466 64-bit

User 2
BIOSTAR Group P43-A7 Desktop UWP Windows 10.0.18363.592 64-bit
BIOSTAR Group P43-A7 Desktop UWP Windows 10.0.19042.1415 64-bit

User 3
LENOVO 10KYS00D00 Desktop UWP Windows 10.0.19041.1415 64-bit

User 4
Gigabyte Technology Co., Ltd. B365M D3H-RD Desktop UWP Windows 10.0.19042.1415 64-bit

 

I was unfortunately mistaken about the number of crashes. Turns out that we clear everything from our log older than one month :/ So it seems like it's a much more frequent type of crash than I initially thought.

Windows versions vary. User 2 above even had it happen on 19H2 and 20H2.

Not sure if something changed with 21H1. We don't have a lot of sample data to see that.

ADMIN
Didi
Posted on: 04 Feb 2022 14:57

Hello Robert,

Can you share the device details from that user's metadata.  For example, if you are using AppCenter analytics, it will usually tell you the device model and OS version.

I look forward to your reply.

Regards,
Didi
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Robert
Posted on: 02 Feb 2022 06:00

Hi,

We haven't been unable to reproduce it either. It has never happened to us during development and testing, and it seems very rare and random in production. One user does seem to be having lots of problems; during the first month of 2022, we have 15 "value does not fall" exceptions for them.

Attaching the entire project is unfortunately not legally possible.

We don't use an ItemTemplateSelector.

RadListViews are defined like this:

<ContentPage.Resources>
        <DataTemplate x:Key="MobileHeader">
            <Grid ColumnDefinitions="*,100,100" RowDefinitions="38,2">
                <Label Grid.Column="0" Style="{StaticResource ReportHeaderLabel}" Text="Naziv" />
                <Label Grid.Column="1" HorizontalTextAlignment="Center" Style="{StaticResource ReportHeaderLabel}" Text="J.mj." />
                <Label Grid.Column="2" HorizontalTextAlignment="End" Style="{StaticResource ReportHeaderLabel}" Text="Ukupno" />
                <BoxView Grid.Row="1" Grid.ColumnSpan="3" BackgroundColor="LightGray" HeightRequest="2" />
            </Grid>
        </DataTemplate>
        <DataTemplate x:Key="inventoryStatusHeader">
            <Grid ColumnDefinitions="140,*,80,120" RowDefinitions="38,2">
                <Label Grid.Column="0" Style="{StaticResource ReportHeaderLabel}" Text="Šifra" />
                <Label Grid.Column="1" Style="{StaticResource ReportHeaderLabel}" Text="Naziv" />
                <Label Grid.Column="2" HorizontalTextAlignment="Center" Style="{StaticResource ReportHeaderLabel}" Text="J.mj." />
                <Label Grid.Column="3" HorizontalOptions="End" Style="{StaticResource ReportHeaderLabel}" Text="Ukupno" />
                <BoxView Grid.Row="1" Grid.ColumnSpan="4" BackgroundColor="LightGray" HeightRequest="2" />
            </Grid>
        </DataTemplate>
    </ContentPage.Resources>
<telerikDataControls:RadListView
    Grid.Row="0"
    HeaderTemplate="{OnIdiom Phone={StaticResource MobileHeader}, Default={StaticResource inventoryStatusHeader}}"
    HorizontalOptions="FillAndExpand"
    IsLoadOnDemandActive="{Binding IsBusy}"
    IsLoadOnDemandEnabled="True"
    ItemsSource="{Binding ReportItems}"
    LoadOnDemandBufferItemsCount="{Binding PageSize}"
    LoadOnDemandMode="Automatic" SelectionMode="None" VerticalOptions="FillAndExpand" VerticalScrollBarVisibility="Always">
 
                    <telerikDataControls:RadListView.Commands>
                        <telerikListViewCommands:ListViewUserCommand Command="{Binding LoadItemsCommand}" Id="LoadOnDemand" />
                    </telerikDataControls:RadListView.Commands>
 
                    <telerikDataControls:RadListView.ItemStyle>
                        <telerikListView:ListViewItemStyle BorderColor="#e0e0e0" BorderLocation="Bottom" BorderWidth="1" />
                    </telerikDataControls:RadListView.ItemStyle>
 
                    <telerikDataControls:RadListView.ItemTemplate>
                        <DataTemplate>
                            <telerikListView:ListViewTemplateCell>
                                <telerikListView:ListViewTemplateCell.View>
                                    <Grid x:DataType="models:InventoryStatus" ColumnDefinitions="{OnIdiom Phone='*,100,100', Default='140,*,80,120'}" RowDefinitions="{OnPlatform Android='50', UWP='40'}" RowSpacing="0">
                                        <Label Grid.Column="{OnPlatform UWP=0, Android={OnIdiom Phone=0, Tablet=0}}" IsVisible="{OnIdiom Phone=False, Default=True}" Style="{StaticResource ReportLabel}" Text="{Binding ItemCode}" />
                                        <Label Grid.Column="{OnPlatform UWP=1, Android={OnIdiom Tablet=1, Phone=0}}" Style="{StaticResource ReportLabel}" Text="{Binding ItemName}" />
                                        <Label Grid.Column="{OnPlatform UWP=2, Android={OnIdiom Tablet=2, Phone=1}}" HorizontalOptions="{OnPlatform UWP=CenterAndExpand, Android=FillAndExpand}" HorizontalTextAlignment="{OnPlatform Android=Center}" Style="{StaticResource ReportLabel}" Text="{Binding UnitOfMeasure}" />
                                        <Label Grid.Column="{OnPlatform UWP=3, Android={OnIdiom Tablet=3, Phone=2}}" HorizontalTextAlignment="End" Style="{StaticResource ReportLabel}" Text="{Binding ItemsTotal, StringFormat='{0:N2}'}" />
                                    </Grid>
                                </telerikListView:ListViewTemplateCell.View>
                            </telerikListView:ListViewTemplateCell>
                        </DataTemplate>
                    </telerikDataControls:RadListView.ItemTemplate>
                </telerikDataControls:RadListView>
ADMIN
Didi
Posted on: 01 Feb 2022 12:08

Hello Robert, 

Thank you for the provided stack-trace. We have been reported similar crash before. Here is the link: https://feedback.telerik.com/xamarin/1385234-listview-uwp-sporadic-exception-when-navigating-between-pages - It seems it happens on page navigation and when RadListView ItemTemplateSelector is used. Still we didn't manage to reproduce the crash on our side. 

I have tried to reproduce the exceptions you have reported but I couldn't. Could you please share whether an ItemTemplateSelector is used in the RadListView control. Would it be possible to open a support ticket and attach the project where the issue can be reproduced? 

I look forward to your reply.

Regards,
Didi
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.