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

IndicatorView with DataTemplate - improvements #24776

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kubaflo
Copy link
Contributor

@kubaflo kubaflo commented Sep 15, 2024

Issues Fixed

Fixes #21980
Fixes #24739
Closes #24717

Before After
Screen.Recording.2024-09-15.at.15.18.43.mov
Screen.Recording.2024-09-15.at.15.17.04.mov
Simulator.Screen.Recording.-.iPhone.15.Pro.Max.-.2024-09-15.at.15.38.21.mp4
Simulator.Screen.Recording.-.iPhone.15.Pro.Max.-.2024-09-15.at.15.36.58.mp4

@kubaflo kubaflo requested a review from a team as a code owner September 15, 2024 14:28
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Sep 15, 2024
Copy link
Contributor

Hey there @kubaflo! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@PureWeen
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@rmarinho
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).


[Test]
[Category(UITestCategories.IndicatorView)]
public void IndicatorViewShouldRenderCorrectly()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going to trigger a build of the test on Windows again. But, could be crashing.

From the test output:
The app was expected to be running still, investigate as possible crash

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! Unfortunately, I have no way of investigating it on Windows. Could you maybe look at this, if this PR makes sense in general?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once rebased, I can try to run the test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MartyIX Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I click "Change source" button like this:

animation

... then the exception: System.Runtime.InteropServices.COMException: 'No installed components were detected. is thrown on line https://github.com/kubaflo/maui/blob/ed0c4eb85ccadb0506233c2884ab75ce0f88fa85/src/Core/src/Platform/Windows/WrapperView.cs#L57

Stacktrace is:

   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
   at WinRT.DelegateExtensions.DynamicInvokeAbi(Delegate del, Object[] invoke_params)
   at ABI.System.Collections.Generic.IListMethods`2.AppendDynamic(IObjectReference obj, T value)
   at ABI.System.Collections.Generic.IVectorMethods`1.Append(IObjectReference obj, T value)
   at ABI.System.Collections.Generic.IListMethods`1.Add(IObjectReference obj, T item)
   at Microsoft.UI.Xaml.Controls.UIElementCollection.Add(UIElement item)
   at Microsoft.Maui.Platform.WrapperView.set_Child(FrameworkElement value) in Z:\maui\src\Core\src\Platform\Windows\WrapperView.cs:line 57
   at Microsoft.Maui.Handlers.ViewHandler`2.SetupContainer() in Z:\maui\src\Core\src\Handlers\View\ViewHandlerOfT.Windows.cs:line 28
   at Microsoft.Maui.Handlers.ImageHandler.SetupContainer() in Z:\maui\src\Core\src\Handlers\Image\ImageHandler.Windows.cs:line 40
   at Microsoft.Maui.Handlers.ViewHandler.set_HasContainer(Boolean value) in Z:\maui\src\Core\src\Handlers\View\ViewHandler.cs:line 121
   at Microsoft.Maui.Handlers.ViewHandler.MapContainerView(IViewHandler handler, IView view) in Z:\maui\src\Core\src\Handlers\View\ViewHandler.cs:line 421
   at Microsoft.Maui.PropertyMapper`2.<>c__DisplayClass5_0.<Add>b__0(IElementHandler h, IElement v) in Z:\maui\src\Core\src\PropertyMapper.cs:line 172
   at Microsoft.Maui.PropertyMapperExtensions.<>c__DisplayClass4_0`2.<AppendToMapping>b__0(IElementHandler handler, IElement view, Action`2 action) in Z:\maui\src\Core\src\PropertyMapperExtensions.cs:line 102
   at Microsoft.Maui.PropertyMapperExtensions.<>c__DisplayClass0_0`2.<ModifyMapping>g__newMethod|0(TViewHandler handler, TVirtualView view) in Z:\maui\src\Core\src\PropertyMapperExtensions.cs:line 23
   at Microsoft.Maui.PropertyMapper`2.<>c__DisplayClass5_0.<Add>b__0(IElementHandler h, IElement v) in Z:\maui\src\Core\src\PropertyMapper.cs:line 172
   at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView) in Z:\maui\src\Core\src\PropertyMapper.cs:line 47
   at Microsoft.Maui.PropertyMapper.UpdateProperty(IElementHandler viewHandler, IElement virtualView, String property) in Z:\maui\src\Core\src\PropertyMapper.cs:line 72
   at Microsoft.Maui.Handlers.ElementHandler.UpdateValue(String property) in Z:\maui\src\Core\src\Handlers\Element\ElementHandler.cs:line 87
   at Microsoft.Maui.Handlers.ImageHandler.MapBackground(IImageHandler handler, IImage image) in Z:\maui\src\Core\src\Handlers\Image\ImageHandler.Windows.cs:line 102
   at Microsoft.Maui.PropertyMapper`2.<>c__DisplayClass5_0.<Add>b__0(IElementHandler h, IElement v) in Z:\maui\src\Core\src\PropertyMapper.cs:line 172
   at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView) in Z:\maui\src\Core\src\PropertyMapper.cs:line 47
   at Microsoft.Maui.PropertyMapper.UpdateProperty(IElementHandler viewHandler, IElement virtualView, String property) in Z:\maui\src\Core\src\PropertyMapper.cs:line 72
   at Microsoft.Maui.Handlers.ElementHandler.UpdateValue(String property) in Z:\maui\src\Core\src\Handlers\Element\ElementHandler.cs:line 87
   at Microsoft.Maui.Controls.VisualElement.MapBackgroundColor(IViewHandler handler, IView view) in Z:\maui\src\Controls\src\Core\VisualElement\VisualElement.Mapper.cs:line 38
   at Microsoft.Maui.PropertyMapperExtensions.<>c__DisplayClass2_0`2.<ReplaceMapping>b__0(TViewHandler h, TVirtualView v, Action`2 p) in Z:\maui\src\Core\src\PropertyMapperExtensions.cs:line 66
   at Microsoft.Maui.PropertyMapperExtensions.<>c__DisplayClass1_0`2.<ModifyMapping>g__newMethod|0(IElementHandler handler, IElement view) in Z:\maui\src\Core\src\PropertyMapperExtensions.cs:line 46
   at Microsoft.Maui.PropertyMapper`2.<>c__DisplayClass5_0.<Add>b__0(IElementHandler h, IElement v) in Z:\maui\src\Core\src\PropertyMapper.cs:line 172
   at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView) in Z:\maui\src\Core\src\PropertyMapper.cs:line 47
   at Microsoft.Maui.PropertyMapper.UpdateProperty(IElementHandler viewHandler, IElement virtualView, String property) in Z:\maui\src\Core\src\PropertyMapper.cs:line 72
   at Microsoft.Maui.Handlers.ElementHandler.UpdateValue(String property) in Z:\maui\src\Core\src\Handlers\Element\ElementHandler.cs:line 87
   at Microsoft.Maui.Controls.Element.UpdateHandlerValue(String property, Boolean valueChanged) in Z:\maui\src\Controls\src\Core\Element\Element.cs:line 686
   at Microsoft.Maui.Controls.VisualElement.UpdateHandlerValue(String property, Boolean valueChanged) in Z:\maui\src\Controls\src\Core\VisualElement\VisualElement.cs:line 1998
   at Microsoft.Maui.Controls.Element.OnBindablePropertySet(BindableProperty property, Object original, Object value, Boolean changed, Boolean willFirePropertyChanged) in Z:\maui\src\Controls\src\Core\Element\Element.cs:line 644
   at Microsoft.Maui.Controls.BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, Object value, Boolean currentlyApplying, SetValueFlags attributes, SetterSpecificity specificity, Boolean silent) in Z:\maui\src\Controls\src\Core\BindableObject.cs:line 662
   at Microsoft.Maui.Controls.BindableObject.SetValueCore(BindableProperty property, Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes, SetterSpecificity specificity) in Z:\maui\src\Controls\src\Core\BindableObject.cs:line 590
   at Microsoft.Maui.Controls.BindableObject.SetValue(BindableProperty property, Object value) in Z:\maui\src\Controls\src\Core\BindableObject.cs:line 495
   at Microsoft.Maui.Controls.VisualElement.set_BackgroundColor(Color value) in Z:\maui\src\Controls\src\Core\VisualElement\VisualElement.cs:line 550
   at Microsoft.Maui.Controls.IndicatorStackLayout.ResetIndicatorStylesNonBatch() in Z:\maui\src\Controls\src\Core\IndicatorView\IndicatorStackLayout.cs:line 142
   at Microsoft.Maui.Controls.IndicatorStackLayout.ResetIndicatorCount(Int32 oldCount) in Z:\maui\src\Controls\src\Core\IndicatorView\IndicatorStackLayout.cs:line 120
   at Microsoft.Maui.Controls.IndicatorStackLayout.ResetIndicatorCount(Int32 oldCount) in Z:\maui\src\Controls\src\Core\IndicatorView\IndicatorStackLayout.cs:line 123
   at Microsoft.Maui.Controls.IndicatorView.<>c.<.cctor>b__65_0(BindableObject bindable, Object oldValue, Object newValue) in Z:\maui\src\Controls\src\Core\IndicatorView\IndicatorView.cs:line 28
   at Microsoft.Maui.Controls.BindableObject.OnBindablePropertySet(BindableProperty property, Object original, Object value, Boolean didChange, Boolean willFirePropertyChanged) in Z:\maui\src\Controls\src\Core\BindableObject.cs:line 675
   at Microsoft.Maui.Controls.Element.OnBindablePropertySet(BindableProperty property, Object original, Object value, Boolean changed, Boolean willFirePropertyChanged) in Z:\maui\src\Controls\src\Core\Element\Element.cs:line 642
   at Microsoft.Maui.Controls.BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, Object value, Boolean currentlyApplying, SetValueFlags attributes, SetterSpecificity specificity, Boolean silent) in Z:\maui\src\Controls\src\Core\BindableObject.cs:line 662
   at Microsoft.Maui.Controls.BindableObject.SetValueCore(BindableProperty property, Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes, SetterSpecificity specificity) in Z:\maui\src\Controls\src\Core\BindableObject.cs:line 590
   at Microsoft.Maui.Controls.BindableObject.SetValue(BindableProperty property, Object value) in Z:\maui\src\Controls\src\Core\BindableObject.cs:line 495
   at Microsoft.Maui.Controls.IndicatorView.set_Count(Int32 value) in Z:\maui\src\Controls\src\Core\IndicatorView\IndicatorView.cs:line 84
   at Microsoft.Maui.Controls.IndicatorView.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e) in Z:\maui\src\Controls\src\Core\IndicatorView\IndicatorView.cs:line 197
   at Microsoft.Maui.Controls.IndicatorView.ResetItemsSource(IEnumerable oldItemsSource) in Z:\maui\src\Controls\src\Core\IndicatorView\IndicatorView.cs:line 188
   at Microsoft.Maui.Controls.IndicatorView.<>c.<.cctor>b__65_3(BindableObject bindable, Object oldValue, Object newValue) in Z:\maui\src\Controls\src\Core\IndicatorView\IndicatorView.cs:line 52
   at Microsoft.Maui.Controls.BindableObject.OnBindablePropertySet(BindableProperty property, Object original, Object value, Boolean didChange, Boolean willFirePropertyChanged) in Z:\maui\src\Controls\src\Core\BindableObject.cs:line 675
   at Microsoft.Maui.Controls.Element.OnBindablePropertySet(BindableProperty property, Object original, Object value, Boolean changed, Boolean willFirePropertyChanged) in Z:\maui\src\Controls\src\Core\Element\Element.cs:line 642
   at Microsoft.Maui.Controls.BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, Object value, Boolean currentlyApplying, SetValueFlags attributes, SetterSpecificity specificity, Boolean silent) in Z:\maui\src\Controls\src\Core\BindableObject.cs:line 662
   at Microsoft.Maui.Controls.BindableObject.SetValueCore(BindableProperty property, Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes, SetterSpecificity specificity) in Z:\maui\src\Controls\src\Core\BindableObject.cs:line 590
   at Microsoft.Maui.Controls.Internals.TypedBinding`2.ApplyCore(Object sourceObject, BindableObject target, BindableProperty property, Boolean fromTarget, SetterSpecificity specificity) in Z:\maui\src\Controls\src\Core\TypedBinding.cs:line 325
   at Microsoft.Maui.Controls.Internals.TypedBinding`2.Apply(Boolean fromTarget) in Z:\maui\src\Controls\src\Core\TypedBinding.cs:line 167
   at Microsoft.Maui.Controls.Internals.TypedBinding`2.PropertyChangedProxy.<OnPropertyChanged>b__16_0() in Z:\maui\src\Controls\src\Core\TypedBinding.cs:line 506
   at Microsoft.Maui.Controls.DispatcherExtensions.DispatchIfRequired(IDispatcher dispatcher, Action action) in Z:\maui\src\Controls\src\Core\DispatcherExtensions.cs:line 59
   at Microsoft.Maui.Controls.Internals.TypedBinding`2.PropertyChangedProxy.OnPropertyChanged(Object sender, PropertyChangedEventArgs e) in Z:\maui\src\Controls\src\Core\TypedBinding.cs:line 506
   at Microsoft.Maui.Controls.BindingExpression.WeakPropertyChangedProxy.OnPropertyChanged(Object sender, PropertyChangedEventArgs e) in Z:\maui\src\Controls\src\Core\BindingExpression.cs:line 599
   at Microsoft.Maui.Controls.BindableObject.OnPropertyChanged(String propertyName) in Z:\maui\src\Controls\src\Core\BindableObject.cs:line 408
   at Microsoft.Maui.Controls.Element.OnPropertyChanged(String propertyName) in Z:\maui\src\Controls\src\Core\Element\Element.cs:line 665
   at Microsoft.Maui.Controls.BindableObject.OnBindablePropertySet(BindableProperty property, Object original, Object value, Boolean didChange, Boolean willFirePropertyChanged) in Z:\maui\src\Controls\src\Core\BindableObject.cs:line 674
   at Microsoft.Maui.Controls.Element.OnBindablePropertySet(BindableProperty property, Object original, Object value, Boolean changed, Boolean willFirePropertyChanged) in Z:\maui\src\Controls\src\Core\Element\Element.cs:line 642
   at Microsoft.Maui.Controls.BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, Object value, Boolean currentlyApplying, SetValueFlags attributes, SetterSpecificity specificity, Boolean silent) in Z:\maui\src\Controls\src\Core\BindableObject.cs:line 662
   at Microsoft.Maui.Controls.BindableObject.SetValueCore(BindableProperty property, Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes, SetterSpecificity specificity) in Z:\maui\src\Controls\src\Core\BindableObject.cs:line 590
   at Microsoft.Maui.Controls.BindingExpression.ApplyCore(Object sourceObject, BindableObject target, BindableProperty property, Boolean fromTarget, SetterSpecificity specificity) in Z:\maui\src\Controls\src\Core\BindingExpression.cs:line 165
   at Microsoft.Maui.Controls.BindingExpression.Apply(Boolean fromTarget) in Z:\maui\src\Controls\src\Core\BindingExpression.cs:line 60
   at Microsoft.Maui.Controls.BindingExpression.BindingExpressionPart.<PropertyChanged>b__50_0() in Z:\maui\src\Controls\src\Core\BindingExpression.cs:line 698
   at Microsoft.Maui.Controls.DispatcherExtensions.DispatchIfRequired(IDispatcher dispatcher, Action action) in Z:\maui\src\Controls\src\Core\DispatcherExtensions.cs:line 59
   at Microsoft.Maui.Controls.BindingExpression.BindingExpressionPart.PropertyChanged(Object sender, PropertyChangedEventArgs args) in Z:\maui\src\Controls\src\Core\BindingExpression.cs:line 698
   at Microsoft.Maui.Controls.BindingExpression.WeakPropertyChangedProxy.OnPropertyChanged(Object sender, PropertyChangedEventArgs e) in Z:\maui\src\Controls\src\Core\BindingExpression.cs:line 599
   at Maui.Controls.Sample.Issues.Issue21980ViewModel.OnPropertyChanged(String propertyName) in Z:\maui\src\Controls\tests\TestCases.HostApp\Issues\Issue21980.xaml.cs:line 55
   at Maui.Controls.Sample.Issues.Issue21980ViewModel.set_Images(IReadOnlyList`1 value) in Z:\maui\src\Controls\tests\TestCases.HostApp\Issues\Issue21980.xaml.cs:line 40
   at Maui.Controls.Sample.Issues.Issue21980ViewModel.<.ctor>b__10_0() in Z:\maui\src\Controls\tests\TestCases.HostApp\Issues\Issue21980.xaml.cs:line 49
   at Microsoft.Maui.Controls.Command.<>c__DisplayClass4_0.<.ctor>b__0(Object o) in Z:\maui\src\Controls\src\Core\Command.cs:line 80
   at Microsoft.Maui.Controls.Command.Execute(Object parameter) in Z:\maui\src\Controls\src\Core\Command.cs:line 122
   at Microsoft.Maui.Controls.ButtonElement.ElementClicked(VisualElement visualElement, IButtonElement ButtonElementManager) in Z:\maui\src\Controls\src\Core\Button\ButtonElement.cs:line 39
   at Microsoft.Maui.Controls.Button.SendClicked() in Z:\maui\src\Controls\src\Core\Button\Button.cs:line 250
   at Microsoft.Maui.Controls.Button.Microsoft.Maui.IButton.Clicked() in Z:\maui\src\Controls\src\Core\Button\Button.cs:line 484
   at Microsoft.Maui.Handlers.ButtonHandler.OnClick(Object sender, RoutedEventArgs e) in Z:\maui\src\Core\src\Handlers\Button\ButtonHandler.Windows.cs:line 95
   at ABI.Microsoft.UI.Xaml.RoutedEventHandler.Do_Abi_Invoke(IntPtr thisPtr, IntPtr sender, IntPtr e)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commenting out this BackgroundColor assignment:

https://github.com/kubaflo/maui/blob/ed0c4eb85ccadb0506233c2884ab75ce0f88fa85/src/Controls/src/Core/IndicatorView/IndicatorStackLayout.cs#L142-L144

prevents the crash:

animation

Intuitively, the issue seems to be caused by the interaction with WrapperView when setting this but I'm not sure. The exception is not really helpful.

Copy link
Contributor

@MartyIX MartyIX Oct 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw: @mattleibow mentions the exception here: #8997 (comment). Perhaps it's relevant here. IDK.

edit: https://github.com/microsoft/microsoft-ui-xaml/discussions?discussions_q=is%3Aopen+no+installed+components+were+detected. (No clear reason mentioned, it seems to be a "blanket exception".)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested, and can reproduce @MartyIX feedback. @kubaflo Do you want me (or someone from the team) to focus on Windows fix?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsuarezruiz that would be great! I have no Windows machine

@jsuarezruiz
Copy link
Contributor

@kubaflo Could you rebase to fix the conflicts? Thanks in advance.

@PureWeen PureWeen added this to the .NET 9 SR1 milestone Oct 23, 2024
@kubaflo kubaflo force-pushed the indicator-view-with-custom-template branch from a206dc8 to 556c819 Compare October 25, 2024 23:08
@kubaflo
Copy link
Contributor Author

kubaflo commented Oct 25, 2024

@jsuarezruiz rebased and fixed conflicts

@kubaflo kubaflo force-pushed the indicator-view-with-custom-template branch from 556c819 to ed0c4eb Compare October 25, 2024 23:26
@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Ready To Review
5 participants