Xamarin.forms: Crash with Certain Values of Corner Radius on Uwp

Created on 24 Jul 2018  路  2Comments  路  Source: xamarin/Xamarin.Forms

Description

On Uwp, setting certain bound valid values for CornerRadius can cause the button to crash.
This occurs on the latest pre-release as well as current Xamarin.Forms

Steps to Reproduce

  1. Create a button with a 'WidthRequest' and 'HeightRequest' of 50.
  2. Bind the CornerRadius to some property. Set the initial value to '25'.
  3. While the app is running, change the bound value for CornerRadius to '5'.

Expected Behavior

The radius changes.

Actual Behavior

An exception is thrown claiming an invalid value for TopLeft. The exception is below:

{System.ArgumentException: Invalid value for TopLeft property on CornerRadius.
at Windows.UI.Xaml.CornerRadius.Validate(Double topLeft, Double topRight, Double bottomRight, Double bottomLeft)
at Xamarin.Forms.Platform.UWP.FormsButton.UpdateBorderRadius()
at Xamarin.Forms.Platform.UWP.FormsButton.OnBorderRadiusChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
at Xamarin.Forms.Platform.UWP.TaskExtensions.<>c.b__2_1(Object e)
at System.Threading.WinRTSynchronizationContextBase.Invoker.InvokeCore()}

Basic Information

This occurs only on Uwp and is confirmed as non-reproducible on Android.
Hard-coding the CornerRadius to 5 does not trigger the issue.
A CornerRadius of both 4 and 6 work in the above scenario
If the HeightRequest and WidthRequest change, the exact value that triggers the crash changes as well.

Found while trying to make a rounded button.

  • Version with issue:
    Xamarin.Forms Version 3.1.0.637273
    Xamarin.Forms Version 3.2.0.637442-pre1

  • Last known good version: Unknown

  • IDE: Visual Studio 2017 15.7.5
  • Platform Target Frameworks:

    • UWP: 16299

  • Nuget Packages:
    Both the current version and the pre-release have been tested and confirmed with this issue.

    Xamarin.Forms Version 3.1.0.637273
    Microsoft.NETCore.UniversalWindowsPlatform 6.1.5

    and

    Xamarin.Forms Version 3.2.0.637442-pre1
    Microsoft.NETCore.UniversalWindowsPlatform 6.2.0-Preview1-26502-02

  • Affected Devices:
    Dell Latitude 7270

Reproduction Link

https://github.com/jkastner/Xamarin.FormsCornerRadiusBug

3 UWP bug

All 2 comments

This is related to a very old very stupid default value coming back to haunt us. The value should always be 5 that triggers the crash best I can tell.

Having double-checked, I agree that the only value that triggers the crash is 5. I thought I saw others when I first spotted the bug, but I think I perhaps only got partway through typing '50' or somesuch.

Was this page helpful?
0 / 5 - 0 ratings