Error in Xamarin.iOS: NaN is not a valid value for height
See original GitHub issueDescription
Hello, I’m having problems with FFImageLoading in Xamarin.iOS. I’m using it in a shared .net standard project and it works in Android. The images are in the shared folder, as Embedded resource.
I’ve tried with a png and svg. With and without an assembly reference, and all other sorts of things I could think of.
It works in Android, but on iOS I get the error: ‘NaN is not a valid value for height’.
Steps to Reproduce
-
I did step 1 and 2 from the wiki: https://github.com/luberda-molinet/FFImageLoading/wiki/Xamarin.Forms-API
-
Next, in xaml I’ve added FFImageLoading reference in the header and changed a working image tag with png to an SvgCachedImage with svg.
-
I set the source of the image in code
-
I’ve also tried with a png image, adding an assembly, setting direct path(without resource://), without the transformation, adding MinimumHeightRequest and MinimumWidthRequest, deleted the bin and obj folders, clean project, rebuild project,…
Expected Behavior
A red icon, like on Android
Actual Behavior
A crash when opening the page with this image (it’s not the first page of my app). Stacktrace:
2019-05-16 13:57:50.429 SuivoMobile.iOS[6634:1302016] [AppCenterCrashes] ERROR: +[MSWrapperLogger MSWrapperLog:tag:level:]/7 Unhandled Exception: System.ArgumentException: NaN is not a valid value for height at Xamarin.Forms.Size…ctor (System.Double width, System.Double height) [0x0001b] in D:\a\1\s\Xamarin.Forms.Core\Size.cs:22 at FFImageLoading.Forms.CachedImage.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00143] in C:\projects\ffimageloading\source\FFImageLoading.Forms\CachedImage.cs:523 at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:645 at Xamarin.Forms.VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) [0x00054] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:703 at Xamarin.Forms.StackLayout.CalculateNaiveLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, Xamarin .Forms.StackOrientation orientation, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint) [0x000a8] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:163 at Xamarin.Forms.StackLayout.CalculateLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint, System.Boolean processExpanders) [0x00058] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:123 at Xamarin.Forms.StackLayout.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00019] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:80 at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:763 at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:645 at Xamarin.Forms.Layou t.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:131 at Xamarin.Forms.VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) [0x00054] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:703 at Xamarin.Forms.Grid.CalculateAutoCells (System.Double width, System.Double height) [0x000e5] in D:\a\1\s\Xamarin.Forms.Core\GridCalc.cs:131 at Xamarin.Forms.Grid.MeasureGrid (System.Double width, System.Double height, System.Boolean requestSize) [0x0000c] in D:\a\1\s\Xamarin.Forms.Core\GridCalc.cs:483 at Xamarin.Forms.Grid.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x0002a] in D:\a\1\s\Xamarin.Forms.Core\GridCalc.cs:58 at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:763 at Xamarin.Forms.VisualElement.GetSizeReque st (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:645 at Xamarin.Forms.Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:131 at Xamarin.Forms.VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) [0x00054] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:703 at Xamarin.Forms.StackLayout.CalculateNaiveLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, Xamarin.Forms.StackOrientation orientation, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint) [0x000a8] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:163 at Xamarin.Forms.StackLayout.CalculateLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint, System.Boolean processExpan ders) [0x00058] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:123 at Xamarin.Forms.StackLayout.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x0005b] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:57 at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x0014b] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:263 at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:223 at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:801 at Xamarin.Forms.VisualElement.SetSize (System.Double width, System.Double height) [0x00021] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:1033 at Xamarin.Forms.VisualElement.set_Bounds (Xamarin.Forms.Rectangle value) [0x0005d] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:277 at Xamarin.Forms.VisualElement.Layout (Xamarin.Forms.Rectangle bounds) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:687 at Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Xamarin.Forms.VisualElement child, Xamarin.Forms.Rectangle region) [0x001da] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:177 at Xamarin.Forms.Page.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x0010d] in D:\a\1\s\Xamarin.Forms.Core\Page.cs:189 at Xamarin.Forms.Page.UpdateChildrenLayout () [0x000c6] in D:\a\1\s\Xamarin.Forms.Core\Page.cs:264 at Xamarin.Forms.Page.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Page.cs:245 at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:801 at Xamarin.Forms.VisualElement.SetSize (System.Double width, System.Double height) [0x00021] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:1033 at Xamarin.Forms.VisualElement.set_Bounds (Xamarin.Forms.Rectangle value) [ 0x0005d] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:277 at Xamarin.Forms.VisualElement.Layout (Xamarin.Forms.Rectangle bounds) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:687 at Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Xamarin.Forms.VisualElement child, Xamarin.Forms.Rectangle region) [0x0005f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:146 at Xamarin.Forms.Page.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x0010d] in D:\a\1\s\Xamarin.Forms.Core\Page.cs:189 at Xamarin.Forms.Page.UpdateChildrenLayout () [0x000c6] in D:\a\1\s\Xamarin.Forms.Core\Page.cs:264 at Xamarin.Forms.Page.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Page.cs:245 at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:801 at Xamarin.Forms.Page.OnChildMeasureInvalidated (Xamarin.Forms.VisualElement ch ild, Xamarin.Forms.Internals.InvalidationTrigger trigger) [0x000a9] in D:\a\1\s\Xamarin.Forms.Core\Page.cs:301 at Xamarin.Forms.Page.OnChildMeasureInvalidated (System.Object sender, System.EventArgs e) [0x00013] in D:\a\1\s\Xamarin.Forms.Core\Page.cs:227 at Xamarin.Forms.VisualElement.InvalidateMeasureInternal (Xamarin.Forms.Internals.InvalidationTrigger trigger) [0x0000b] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:833 at Xamarin.Forms.VisualElement.set_IsPlatformEnabled (System.Boolean value) [0x0001c] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:535 at Xamarin.Forms.Platform.iOS.Platform+<>c.<.cctor>b__50_0 (Xamarin.Forms.BindableObject bindable, System.Object oldvalue, System.Object newvalue) [0x0000a] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:20 at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.Se tValueFlags attributes, System.Boolean silent) [0x00120] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:625 at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x0015b] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:417 at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x0003d] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:573 at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:99 at Xamarin.Forms.Platform.iOS.Platform.SetRenderer (Xamarin.Forms.VisualElement bindable, Xamarin.Forms.Platform.iOS.IVisualElementRenderer value) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:209 at Xamarin .Forms.Platform.iOS.NavigationRenderer.CreateViewControllerForPage (Xamarin.Forms.Page page) [0x00008] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\NavigationRenderer.cs:353 at Xamarin.Forms.Platform.iOS.NavigationRenderer+<OnPushAsync>d__51.MoveNext () [0x0001d] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\NavigationRenderer.cs:340 — End of stack trace from previous location where exception was thrown — at Xamarin.Forms.NavigationPage+<PushAsyncInner>d__84.MoveNext () [0x00085] in D:\a\1\s\Xamarin.Forms.Core\NavigationPage.cs:394 — End of stack trace from previous location where exception was thrown — at Xamarin.Forms.NavigationPage+<PushAsync>d__55.MoveNext () [0x0014e] in D:\a\1\s\Xamarin.Forms.Core\NavigationPage.cs:219 — End of stack trace from previous location where exception was thrown —
Basic Information
- Version with issue: FFImageLoading v2.4.9.961
- Xamarin.Froms version: v3.4.0.1039999
Code
in Xaml:
<ffSvg:SvgCachedImage VerticalOptions="Center" x:Name="ImageSubmitted" WidthRequest="30" HeightRequest="30" HorizontalOptions="FillAndExpand" > <ffSvg:SvgCachedImage.Transformations> <ffTransformations:TintTransformation EnableSolidColor="True" HexColor="#ff0000" /> </ffSvg:SvgCachedImage.Transformations> </ffSvg:SvgCachedImage> </StackLayout>
C: (I’ve tried multiple thing, but for now, it’s this:
Uri uri = new Uri("resource://SuivoMobile.resources.carnew.svg")); EmbeddedResourceImageSource em = new EmbeddedResourceImageSource(uri); ImageSubmitted.Source = uri;
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (4 by maintainers)
Top GitHub Comments
Installed v2.4.11.982 and working. Thanks @daniel-luberda !
Working 😃