WinUI crashes if SfSegmentedControl is in a hidden element
Hi there,
I am seeing a crash in MAUI WinUI if an SfSegmentedControl is in a layout that has IsVisible="False" set on it using version 25.2.4. The callstack is below.
thanks,
M
System.Private.CoreLib.dll!System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(int errorCode) Unknown
WinRT.Runtime.dll!WinRT.DelegateExtensions.DynamicInvokeAbi(System.Delegate del, object[] invoke_params) Unknown
WinRT.Runtime.dll!ABI.System.Collections.Generic.IVectorMethods<Microsoft.UI.Xaml.UIElement>.Append(WinRT.IObjectReference obj, Microsoft.UI.Xaml.UIElement value) Unknown
WinRT.Runtime.dll!ABI.System.Collections.Generic.IListMethods<Microsoft.UI.Xaml.UIElement>.Add(WinRT.IObjectReference obj, Microsoft.UI.Xaml.UIElement item) Unknown
Microsoft.WinUI.dll!Microsoft.UI.Xaml.Controls.UIElementCollection.Add(Microsoft.UI.Xaml.UIElement item) Unknown
Microsoft.Maui.dll!Microsoft.Maui.Platform.WrapperView.Child.set(Microsoft.UI.Xaml.FrameworkElement value) Unknown
Microsoft.Maui.dll!Microsoft.Maui.Handlers.ViewHandler<Microsoft.Maui.ILayout, Microsoft.Maui.Platform.LayoutPanel>.SetupContainer() Unknown
Microsoft.Maui.dll!Microsoft.Maui.Handlers.ViewHandler.HasContainer.set(bool value) Unknown
Microsoft.Maui.dll!Microsoft.Maui.Handlers.ViewHandler.MapContainerView(Microsoft.Maui.IViewHandler handler, Microsoft.Maui.IView view) Unknown
Microsoft.Maui.dll!Microsoft.Maui.PropertyMapper<Microsoft.Maui.IView, Microsoft.Maui.IViewHandler>.Add.AnonymousMethod__0(Microsoft.Maui.IElementHandler h, Microsoft.Maui.IElement v) Unknown
Microsoft.Maui.dll!Microsoft.Maui.PropertyMapperExtensions.AppendToMapping.AnonymousMethod__0(Microsoft.Maui.IElementHandler handler, Microsoft.Maui.IElement view, System.Action<Microsoft.Maui.IElementHandler, Microsoft.Maui.IElement> action) Unknown
Microsoft.Maui.dll!Microsoft.Maui.PropertyMapperExtensions.ModifyMapping.__newMethod|0(System.__Canon handler, System.__Canon view) Unknown
Microsoft.Maui.dll!Microsoft.Maui.PropertyMapper<Microsoft.Maui.IView, Microsoft.Maui.IViewHandler>.Add.AnonymousMethod__0(Microsoft.Maui.IElementHandler h, Microsoft.Maui.IElement v) Unknown
Microsoft.Maui.dll!Microsoft.Maui.PropertyMapper.UpdatePropertyCore(string key, Microsoft.Maui.IElementHandler viewHandler, Microsoft.Maui.IElement virtualView) Unknown
Microsoft.Maui.dll!Microsoft.Maui.PropertyMapper.UpdateProperty(Microsoft.Maui.IElementHandler viewHandler, Microsoft.Maui.IElement virtualView, string property) Unknown
Microsoft.Maui.dll!Microsoft.Maui.Handlers.ElementHandler.UpdateValue(string property) Unknown
Microsoft.Maui.dll!Microsoft.Maui.Handlers.ViewHandler.MapClip(Microsoft.Maui.IViewHandler handler, Microsoft.Maui.IView view) Unknown
Microsoft.Maui.dll!Microsoft.Maui.PropertyMapper<Microsoft.Maui.IView, Microsoft.Maui.IViewHandler>.Add.AnonymousMethod__0(Microsoft.Maui.IElementHandler h, Microsoft.Maui.IElement v) Unknown
Microsoft.Maui.dll!Microsoft.Maui.PropertyMapper.UpdatePropertyCore(string key, Microsoft.Maui.IElementHandler viewHandler, Microsoft.Maui.IElement virtualView) Unknown
Microsoft.Maui.dll!Microsoft.Maui.PropertyMapper.UpdateProperty(Microsoft.Maui.IElementHandler viewHandler, Microsoft.Maui.IElement virtualView, string property) Unknown
Microsoft.Maui.dll!Microsoft.Maui.Handlers.ElementHandler.UpdateValue(string property) Unknown
Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Element.OnPropertyChanged(string propertyName) Unknown
Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.BindableObject.SetValueActual(Microsoft.Maui.Controls.BindableProperty property, Microsoft.Maui.Controls.BindableObject.BindablePropertyContext context, object value, bool currentlyApplying, Microsoft.Maui.Controls.Internals.SetValueFlags attributes, Microsoft.Maui.Controls.SetterSpecificity specificity, bool silent) Unknown
Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.BindableObject.SetValueCore(Microsoft.Maui.Controls.BindableProperty property, object value, Microsoft.Maui.Controls.Internals.SetValueFlags attributes, Microsoft.Maui.Controls.BindableObject.SetValuePrivateFlags privateAttributes, Microsoft.Maui.Controls.SetterSpecificity specificity) Unknown
Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.BindableObject.SetValue(Microsoft.Maui.Controls.BindableProperty property, object value) Unknown
Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.VisualElement.Clip.set(Microsoft.Maui.Controls.Shapes.Geometry value) Unknown
Syncfusion.Maui.Buttons.dll!Syncfusion.Maui.Buttons.SfSegmentedControl.SetClipBounds.AnonymousMethod__0() Unknown
Microsoft.Maui.dll!Microsoft.Maui.Dispatching.Dispatcher.DispatchImplementation.AnonymousMethod__0() Unknown
Microsoft.InteractiveExperiences.Projection.dll!ABI.Microsoft.UI.Dispatching.DispatcherQueueHandler.Do_Abi_Invoke(nint thisPtr) 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
> CavePlannerApp.dll!CavePlannerApp.WinUI.Program.Main(string[] args) Line 32 C#
Hi Martin,
Thank you for reaching out to us. Based on the information you shared, we have checked the reported issue. However, we were unable to replicate the problem on our end. In our testing, we set the `IsVisible` property to `False` for the layout containing the SegmentedControl, and it worked as expected on the Windows platform.
To assist you further, we have attached the tested sample for your reference. Please review the sample and let us know if you're still experiencing the issue. If not, we kindly request that you modify our sample to replicate the issue in your scenario and provide the modified sample for further investigation.
Alternatively, if modifying our sample is not feasible, please share the sample in which you originally encountered this issue. This will enable us to analyze the problem more effectively and provide a suitable solution.
Regards,
Vidyalakshmi M.
Attachment: MauiSegmentedControl_87e21ecd.zip
Thanks for that. The problem happens when I add Padding="0" to the SfSegmentedControl as below.
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:buttons="clr-namespace:Syncfusion.Maui.Buttons;assembly=Syncfusion.Maui.Buttons"
x:Class="MauiSegmentedControl.MainPage">
<Grid IsVisible="False">
<buttons:SfSegmentedControl x:Name="segmentedControl" Padding="0">
<buttons:SfSegmentedControl.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>Day</x:String>
<x:String>Week</x:String>
<x:String>Month</x:String>
<x:String>Year</x:String>
</x:Array>
</buttons:SfSegmentedControl.ItemsSource>
</buttons:SfSegmentedControl>
</Grid>
</ContentPage>
Hi Martin,
Regarding the issue “Crash in the WinUI
platform occurs if the SfSegmentedControl with padding set to ’0’ is in a layout
that has IsVisible set to "False"
We have found and fixed the reported scenario from our end. We will include the issue fix in our upcoming weekly NuGet release scheduled for May 28, 2024. We appreciate your patience until then.
Regards,
Vidyalakshmi M.
Hi Martin,
Regarding the
issue “Crash in the WinUI
platform occurs if the SfSegmentedControl
with padding set to ’0’ is in a layout that has IsVisible set to "False"
We have fixed the reported issue and included the issue fix in our latest weekly NuGet release update version 25.2.6, which is available for download at nuget.org
Root cause: The crash occurs when the layout containing the SegmentedControl is hidden (`IsVisible` set to `false`) and the padding for the SegmentedControl is set to `0`. This combination results in negative bounds for the SegmentedControl, leading to the crash.
We thank you for your support and appreciate your patience in waiting for this update. Please get in touch with us if you require any further assistance.
Regards,
Vidyalakshmi M.
- 4 Replies
- 2 Participants
-
MA Martin
- May 15, 2024 12:30 AM UTC
- May 28, 2024 01:59 PM UTC