Skip to content

ArgumentOutOfRange exception when scrolling ItemRepeater with images too fast #10281

@FrozenAssassine

Description

@FrozenAssassine

Describe the bug

I have an ItemsRepeater and attached to it is an AnnotatedScrollBar. When I scroll up and down pretty fast. The whole app crashes and throws the "System.ArgumentOutOfRangeException" in WinRT.Runtime.dll

I have only tested with images. Maybe it happens even with something else, but images are my main thing to show there so that's what I tested for.

As you can also see in the video, when I start scrolling everything works, it's not even a problem, that the images do not render directly. I guess it's normal due to the virtualization. The problem appears after some time, when the app starts with the loading cursor and becomes completely unresponsive.

Steps to reproduce the bug

<ScrollView x:Name="imageItemRepeaterScroller" Grid.Column="0" HorizontalScrollMode="Disabled" VerticalScrollBarVisibility="Hidden">
    <ItemsRepeater x:Name="imageRenderer">
        <ItemsRepeater.Layout>
            <LinedFlowLayout ItemsStretch="Fill" LineHeight="160" LineSpacing="5" MinItemSpacing="5"/>
        </ItemsRepeater.Layout>
        <ItemsRepeater.ItemTemplate>
            <DataTemplate x:DataType="x:String">
                <Image Source="{x:Bind }" Stretch="UniformToFill" />
            </DataTemplate>
        </ItemsRepeater.ItemTemplate>
    </ItemsRepeater>
</ScrollView>
<AnnotatedScrollBar Grid.Column="1" 
    x:Name="annotatedScrollBar"
    Margin="4,0,48,0"
    VerticalAlignment="Stretch"
    HorizontalAlignment="Right"
    Loaded="annotatedScrollBar_Loaded"/>
private void annotatedScrollBar_Loaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
    imageItemRepeaterScroller.ScrollPresenter.VerticalScrollController = annotatedScrollBar.ScrollController;
}

//load some images:
var images = Directory.GetFiles("C:\\Users\\MYUSER\\Pictures\\Screenshots");
var items = new ObservableCollection<string>(images);
imageRenderer.ItemsSource = items;

Now launch the app, you should see a list of 200 screenshots. Hope you have, otherwise maybe select a different folder. Now start scrolling really fast up and down using the annotatedScrollBar and at some point the app will crash with a "System.ArgumentOutOfRangeException" in WinRT.Runtime.dll exception.

Expected behavior

I don't want it to crash. There is no problem if it loads or shows nothing for a short time, but a crash is
inappropriate.

Screenshots

Bildschirmaufnahme.2025-01-07.144349.mp4

NuGet package version

WinUI 3 - Windows App SDK 1.6.3: 1.6.241114003

Windows version

Windows 11 (24H2): Build 26100

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Crashwhenever user reports a crash or app freezearea-ItemsRepeaterbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions