Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[regression/8.0.0-preview.1.7762] [WinUI] An exception is thrown after removing an item from its close button #16324

Closed
1 task done
marchev-prgs opened this issue Jul 24, 2023 · 13 comments
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView blocked Work that is currently blocked external high It doesn't work at all, crashes or has a big impact. partner/winui WinUI / Project Reunion partner Issue or Request from a partner team platform/windows 🪟 s/triaged Issue has been reviewed s/try-latest-version Please try to reproduce the potential issue on the latest public version t/bug Something isn't working

Comments

@marchev-prgs
Copy link

marchev-prgs commented Jul 24, 2023

Description

I get the exception with 8.0.0-preview.6.8686, which I don't see listed in the versions list below)

An exception is thrown when an item is removed by clicking a close-button inside the item.
I have a simple item template, just a label and a close-button:

    <DataTemplate x:Key="t1">
        <HorizontalStackLayout>
            <Label Text="{Binding}" Margin="0, 0, 10, 0" />
            <Button Text="X" Clicked="ButtonClose_Clicked" />
        </HorizontalStackLayout>
    </DataTemplate>

When I click the close button an exception is thrown:
Message: Child collection must not be modified during measure or arrange.

Interestingly, the stack trace is null.

cv_exc2_app

cv_exc2_exc
ee-455020fde0ca)

Steps to Reproduce

  1. Get the repo from the link
  2. Go to folder \Maui\CollectionViewThrowsExceptionWhenClosingAnItem
  3. Run the app in WinUI
  4. Click the X button (the close button of the item in the CollectionVew)

Expected: The item should be removed and the CollectionView should become empty.
Actual: An exception is thrown.

Link to public reproduction project repository

https://github.com/telerik/ms-samples/tree/main/Maui/CollectionViewThrowsExceptionWhenClosingAnItem

Version with bug

8.0.0-preview.1.7762

Last version that worked well

7.0.92

Affected platforms

Windows

Affected platform versions

Did you find any workaround?

#16324 (comment)

Relevant log output

No response

Depends on

VS bug #1900743

@marchev-prgs marchev-prgs added the t/bug Something isn't working label Jul 24, 2023
@jsuarezruiz jsuarezruiz added area-controls-collectionview CollectionView, CarouselView, IndicatorView partner Issue or Request from a partner team labels Jul 24, 2023
@jsuarezruiz jsuarezruiz added this to the Backlog milestone Jul 31, 2023
@ghost
Copy link

ghost commented Jul 31, 2023

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

@PureWeen PureWeen added the i/regression This issue described a confirmed regression on a currently supported version label Aug 1, 2023
@PureWeen PureWeen modified the milestones: Backlog, .NET 8 GA Aug 1, 2023
@samhouts samhouts changed the title [WinUI] An exception is thrown after removing an item from its close button [regression/8.0.0-preview.6.8686] [WinUI] An exception is thrown after removing an item from its close button Aug 1, 2023
@XamlTest
Copy link

XamlTest commented Aug 10, 2023

Verified this on Visual Studio Enterprise 17.8.0 Preview 1.0. This issue does not repro on Windows 11(8.0.100-preview.6.23330.14), Android 13.0-API33 and iOS 16.4 with below Project:

CollectionViewThrowsExc2.zip

NoException

@XamlTest XamlTest added s/triaged Issue has been reviewed s/try-latest-version Please try to reproduce the potential issue on the latest public version labels Aug 10, 2023
@ghost
Copy link

ghost commented Aug 10, 2023

Hi @marchev-prgs. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.

You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@marchev-prgs
Copy link
Author

Interestingly, I still get an exception - "Child collection must not be modified during measure or arrange."
Unfortunately, the exception is the "No installed components were detected." exception, so I cannot give you stack trace as well.
I am running VS 17.8.0 Preview 1.0 and maui is 8.0.0-preview.7.8842.

@ghost ghost removed the s/try-latest-version Please try to reproduce the potential issue on the latest public version label Aug 11, 2023
@marchev-prgs
Copy link
Author

I figured I can give you what I see in the Call Stack window of VS. I doubt it's of much use, but I guess it wouldn't hurt:

CollectionViewThrowsExc2.dll!CollectionViewThrowsExc2.WinUI.App.InitializeComponent.AnonymousMethod__3_1(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e) Line 67 C#
Microsoft.WinUI.dll!WinRT._EventSource_global__Microsoft_UI_Xaml_UnhandledExceptionEventHandler.EventState.GetEventInvoke.AnonymousMethod__1_0(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e) Unknown
Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.UnhandledExceptionEventHandler.Do_Abi_Invoke(nint thisPtr, nint sender, nint e) Unknown
[Native to Managed Transition]
[Managed to Native Transition]
Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.Controls.IItemsControlOverridesMethods.OnItemsChanged(WinRT.IObjectReference _obj, object e) Unknown
Microsoft.WinUI.dll!Microsoft.UI.Xaml.Controls.ItemsControl.OnItemsChanged(object e) Unknown
Microsoft.WinUI.dll!Microsoft.UI.Xaml.Controls.ItemsControl.Microsoft.UI.Xaml.Controls.IItemsControlOverrides.OnItemsChanged(object e) Unknown
Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.Controls.IItemsControlOverrides.Do_Abi_OnItemsChanged_4(nint thisPtr, nint e) Unknown
[Native to Managed Transition]
[Managed to Native Transition]
WinRT.Runtime.dll!ABI.System.Collections.Specialized.NotifyCollectionChangedEventHandler.NativeDelegateWrapper.Invoke(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) Unknown
System.ObjectModel.dll!System.Collections.ObjectModel.ObservableCollection<Microsoft.Maui.Controls.Platform.ItemTemplateContext>.OnCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e) Unknown
Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Platform.ObservableItemTemplateCollection.Remove(System.Collections.Specialized.NotifyCollectionChangedEventArgs args) Unknown
Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Platform.ObservableItemTemplateCollection.InnerCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs args) Unknown
Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Platform.ObservableItemTemplateCollection.InnerCollectionChanged.AnonymousMethod__0() Unknown
Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.DispatcherExtensions.DispatchIfRequired(Microsoft.Maui.Dispatching.IDispatcher dispatcher, System.Action action) Unknown
Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Platform.ObservableItemTemplateCollection.InnerCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs args) Unknown
System.ObjectModel.dll!System.Collections.ObjectModel.ObservableCollection.OnCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e) Unknown
System.Private.CoreLib.dll!System.Collections.ObjectModel.Collection.Remove(string item) Unknown
CollectionViewThrowsExc2.dll!CollectionViewThrowsExc2.MainPage.ButtonClose_Clicked(object sender, System.EventArgs e) Line 21 C#
Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Button.Microsoft.Maui.Controls.Internals.IButtonElement.PropagateUpClicked() Unknown
Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.ButtonElement.ElementClicked(Microsoft.Maui.Controls.VisualElement visualElement, Microsoft.Maui.Controls.Internals.IButtonElement ButtonElementManager) Unknown
Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Button.SendClicked() Unknown
Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Button.Microsoft.Maui.IButton.Clicked() Unknown
Microsoft.Maui.dll!Microsoft.Maui.Handlers.ButtonHandler.OnClick(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) Unknown
Microsoft.WinUI.dll!WinRT._EventSource_global__Microsoft_UI_Xaml_RoutedEventHandler.EventState.GetEventInvoke.AnonymousMethod__1_0(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) Unknown
Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.RoutedEventHandler.Do_Abi_Invoke(nint thisPtr, nint sender, nint e) Unknown
[Native to Managed Transition]
[Managed to Native Transition]
Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.Controls.IControlOverridesMethods.OnPointerReleased(WinRT.IObjectReference _obj, Microsoft.UI.Xaml.Input.PointerRoutedEventArgs e) Unknown
Microsoft.WinUI.dll!Microsoft.UI.Xaml.Controls.Control.OnPointerReleased(Microsoft.UI.Xaml.Input.PointerRoutedEventArgs e) Unknown
Microsoft.WinUI.dll!Microsoft.UI.Xaml.Controls.Control.Microsoft.UI.Xaml.Controls.IControlOverrides.OnPointerReleased(Microsoft.UI.Xaml.Input.PointerRoutedEventArgs e) Unknown
Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.Controls.IControlOverrides.Do_Abi_OnPointerReleased_3(nint thisPtr, nint e) Unknown
[Native to Managed Transition]
[Managed to Native Transition]
Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.IApplicationStaticsMethods.Start(WinRT.IObjectReference _obj, Microsoft.UI.Xaml.ApplicationInitializationCallback callback) Unknown
Microsoft.WinUI.dll!Microsoft.UI.Xaml.Application.Start(Microsoft.UI.Xaml.ApplicationInitializationCallback callback) Unknown
CollectionViewThrowsExc2.dll!CollectionViewThrowsExc2.WinUI.Program.Main(string[] args) Line 31 C#

@mauroa mauroa self-assigned this Aug 30, 2023
@samhouts samhouts added potential-regression This issue described a possible regression on a currently supported version., verification pending and removed i/regression This issue described a confirmed regression on a currently supported version labels Sep 5, 2023
@mauroa
Copy link
Contributor

mauroa commented Sep 6, 2023

The root cause of the bug looks directly related to WinUI core issues with observable collections and collection views (ListView in this case). Bret already linked an existing and related bug in WinUI. I'll try to file a new one specific to this issue and attach a repro solution.

@samhouts samhouts changed the title [regression/8.0.0-preview.6.8686] [WinUI] An exception is thrown after removing an item from its close button [regression/8.0.0-preview.1.7762] [WinUI] An exception is thrown after removing an item from its close button Sep 8, 2023
@samhouts samhouts added high It doesn't work at all, crashes or has a big impact. i/regression This issue described a confirmed regression on a currently supported version and removed potential-regression This issue described a possible regression on a currently supported version., verification pending labels Sep 8, 2023
@samhouts
Copy link
Member

samhouts commented Sep 8, 2023

Confirmed that this regressed between 7.0.92...8.0.0-preview.1.7762. #10999 and #13146 seem sus, but it could be one of the memory leaks fixes on bindings, too, perhaps?

@jsuarezruiz
Copy link
Contributor

Cannot reproduce the issue with Windows 10:
issue-16324
Probably related with latests WinUI versions, will check with Windows 11.

@PureWeen PureWeen modified the milestones: .NET 8 GA, .NET 8 SR1 Sep 27, 2023
@PureWeen PureWeen added the partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with label Oct 3, 2023
@emaf emaf assigned emaf and unassigned mauroa Oct 3, 2023
@samhouts samhouts added the p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint label Oct 5, 2023
@emaf
Copy link
Contributor

emaf commented Oct 11, 2023

Unfortunatly this is an issue on WinUI related to microsoft/microsoft-ui-xaml#6350.

We are working with the WinUI team to get this fixed, and as a workaround you can release the button's pointer capture before removing the item from the list.

For example, the sample code linked on this issue would look like:

private void ButtonClose_Clicked(object sender, EventArgs e)
{
	Button button = (Button)sender;

#if WINDOWS
	((Microsoft.UI.Xaml.Controls.Button)button.Handler.PlatformView).ReleasePointerCaptures();
#endif

	string item = (string)button.BindingContext;
	this.items.Remove(item);
}

@samhouts samhouts added external partner/winui WinUI / Project Reunion blocked Work that is currently blocked labels Oct 12, 2023
@PureWeen PureWeen modified the milestones: .NET 8 SR1, .NET 8 SR2 Nov 1, 2023
@PureWeen
Copy link
Member

PureWeen commented Nov 3, 2023

I'm going to backlog this issue for now. We're going to wait for this to be resolved by WinUI

@PureWeen PureWeen removed partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with i/regression This issue described a confirmed regression on a currently supported version labels Nov 3, 2023
@PureWeen PureWeen modified the milestones: .NET 8 SR2, Backlog Nov 3, 2023
@ghost
Copy link

ghost commented Nov 3, 2023

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

@busitech
Copy link

@samhouts samhouts removed the p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint label Apr 23, 2024
@PureWeen PureWeen added the s/try-latest-version Please try to reproduce the potential issue on the latest public version label May 3, 2024
Copy link
Contributor

Hi @marchev-prgs. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.

You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@dotnet-policy-service dotnet-policy-service bot removed this from the Backlog milestone May 11, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jun 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView blocked Work that is currently blocked external high It doesn't work at all, crashes or has a big impact. partner/winui WinUI / Project Reunion partner Issue or Request from a partner team platform/windows 🪟 s/triaged Issue has been reviewed s/try-latest-version Please try to reproduce the potential issue on the latest public version t/bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

8 participants