Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
A piece of code like that crashes iOS app, exception handling (try/catch) does not help.
CGRect clsRect = new CGRect(1, 1, 25, 25);
CGSize clsRadius = new CGSize(13.5, 13.5);
CGPath clsPath = CGPath.FromRoundedRect(clsRect, clsRadius.Width, clsRadius.Height);
In my xamarin.forms app the code is inside a custom renderer. As a workaround I created a wrapper with correct parameter checks and an exception for wrong parameter values.
This is iOS itself who is aborting:
Assertion failed: (corner_width >= 0 && 2 * corner_width <= CGRectGetWidth(rect)), function CGPathCreateWithRoundedRect, file /BuildRoot/Library/Caches/com.apple.xbs/Sources/Quartz2D_Sim/Quartz2D-1033.1/CoreGraphics/Paths/CGPath.cc, line 189.
We should probably add bounds checks ourselves and raise normal exceptions instead.
Is it normal for iOS to crash like that with an assertion? Do apple guys consider that a bug?
Unlike .NET Apple API are not very consistent in their error handling*. Some returns `nil` (if applicable), some will write to `stderr` (and do nothing, which can be confusing) and some will assert (effectively killing the running app).
In general we don't duplicate Apple argument checks. Code duplication slows down execution and takes more space. However if we can avoid a crash, like this case, then we will add the code to throw an ArgumentException.
* We often file bugs on rdar  and it's being said (not by Apple) that duplicates (of the same bugs) often set their priority. Still I encourage you to file such issues with us _and_ Apple for the benefits of all iOS developers :-)
Actually I did that already i.e. posted a bug to apple, was curious what to expect from that. Thanks for clarification.
PR (master) https://github.com/xamarin/xamarin-macios/pull/966
PR merged: https://github.com/xamarin/xamarin-macios/commit/5504f45bb4e7370a1e39adfecb84af6b6c7a83e7