maui: [WinUI] Silent crash when updating binding at runtime while thumb scrolling

Description

Application getting crashed without any exception while thumb scrolling(Dragging thumb).

Steps to Reproduce

  1. Create a sample with MainPage ->ScrollView -> StackLayout- > N number of labels till scrollviewer becomes scrollable.
  2. Create a ViewModel class with string Property.
  3. Set the ViewModel as BindingContext of MainPage or StackLayout.
  4. Bind the ViewModel string property to three or more label Text property.
  5. Subscribe ScrollView.Scrolled event, Inside the body update BindingContext of the MainPage or StackLayout.
  6. Now deploy the sample and scroll using thumb, application will get crashed without any exception.

Note

Try binding ViewModel.string property to more label if crashing not occurs.

Code snippet

MainPage.Xaml

  <ScrollView Scrolled="ScrollView_Scrolled">
        <StackLayout x:Name="Stack">
            <Label Text="{Binding Name}"/>
            <Label Text="Hello"/>
            <Label Text="Hello"/>
            <Label Text="Hello"/>
            <Label Text="{Binding Name}"/>
            <Label Text="{Binding Name}"/>
            <Label Text="{Binding Name}"/>
            <Label Text="{Binding Name}"/>
            <Label Text="{Binding Name}"/>
            <Label Text="{Binding Name}"/>
            <Label Text="{Binding Name}"/>
            <Label Text="Hello"/>
            <Label Text="Hello"/>
            <Label Text="Hello"/>
               ....
               ....
            <Label Text="Hello"/>
        </StackLayout>
    </ScrollView>

ViewModel:

public class NumberViewModel : INotifyPropertyChanged
{
    private string name = "hello";
    public string Name
    {
        get { return name; }
        set { name = value; this.RaisePropertyChanged(nameof(Name)); }
    }

   public event PropertyChangedEventHandler PropertyChanged;
   public void RaisePropertyChanged(string propName)
   {
        if (this.PropertyChanged != null)
        {
            this.PropertyChanged(this, new PropertyChangedEventArgs(propName));
        }
   }
}

MainPage.Xaml.cs

public MainPage()
{
    InitializeComponent();
    this.BindingContext = new NumberViewModel();
}
private void ScrollView_Scrolled(object sender, ScrolledEventArgs e)
{
     this.BindingContext = new NumberViewModel() { Name = "Updated" };
}

Video: https://user-images.githubusercontent.com/59435340/175104231-a8c8f96e-d093-42ec-99b3-65c140668af2.mp4

Version with bug

6.0.400 (current)

Last version that worked well

6.0 Release Candidate 3

Affected platforms

Windows

Affected platform versions

10.0.17763.0

Did you find any workaround?

When setting ScrollViewer(platform view) scrollbar visibility to Visible exception not occurring.

Relevant log output

The program '[32648] SampleApp.exe' has exited with code 3221225477 (0xc0000005) 'Access violation'.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 20 (8 by maintainers)

Most upvoted comments

@RanjithkumarSyncfusion ok, thanks for your info, I can repro as you say. image