This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 52533 - Xamarin.Forms v2.3.4.192-pre2 Regression: System.ArgumentException: NaN is not a valid value for width
Summary: Xamarin.Forms v2.3.4.192-pre2 Regression: System.ArgumentException: NaN is no...
Status: VERIFIED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms (show other bugs)
Version: 2.3.4
Hardware: PC Mac OS
: Normal normal
Target Milestone: 15.1
Assignee: Samantha Houts
URL: https://github.com/brminnick/Xamarin....
: 52289 52389 52624 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-02-15 19:03 UTC by Brandon Minnick
Modified: 2017-03-17 12:42 UTC (History)
10 users (show)

See Also:
Tags: AC
Is this bug a regression?: Yes
Last known good build: 2.3.3.180


Attachments
Please find attached logs (56 bytes, text/plain)
2017-03-17 12:42 UTC, Prasad Raghorte
Details

Description Brandon Minnick 2017-02-15 19:03:22 UTC
Using Xamarin.Forms v2.3.4.192-pre2, I get the following exception when creating a ListView on Xamarin.iOS: System.ArgumentException: NaN is not a valid value for width. 

This exception is not thrown when running on Xamarin.Android 

Reproduction Steps

1. Download the Reproduction Code from GitHub (link below) and open NaNReproduction.sln in Xamarin Studio
2. In the Solution Explorer, Right-click on NaNReproduction.iOS and select Set As Startup Project
3. Build, Deploy, and Run the app on an iOS 10.2 Simulator

Reproduction Code (Readme Included):
https://github.com/brminnick/Xamarin.Forms-NaN-is-not-a-valid-value-for-width-reproduction
Comment 1 Stephane Delcroix 2017-02-17 10:29:58 UTC
brandon, your web service takes AGES (multiple minutes) to return an answer...
Comment 2 Stephane Delcroix 2017-02-17 11:25:08 UTC
I suspect this issue is introduce by the change in https://github.com/xamarin/Xamarin.Forms/pull/529

LabelRenderer.GetDeisredSize returns +Inf as widthConstraint, and it was previously returning 30.5x20.5
Comment 3 Luis Aguilera 2017-02-18 00:21:33 UTC
C9 is now closed. We'll move this bug to the next scheduled milestone, "15.1". We'll continue working on these issues, and will attempt to resolve them ASAP.
Comment 4 Samantha Houts 2017-02-18 00:52:45 UTC
https://github.com/xamarin/Xamarin.Forms/pull/776
Comment 5 Samantha Houts 2017-02-21 20:09:52 UTC
*** Bug 52624 has been marked as a duplicate of this bug. ***
Comment 6 Jimmy [MSFT] 2017-03-02 23:08:52 UTC
*** Bug 52289 has been marked as a duplicate of this bug. ***
Comment 7 Samantha Houts 2017-03-06 22:37:54 UTC
Should be fixed in 2.3.4-pre3. Thank you!
Comment 8 Reuben Turk 2017-03-10 07:21:01 UTC
Not sure if it is the same issue or a separate one, but I still get this error with 2.3.4.211-pre3.

I get "System.ArgumentException: NaN is not a valid value for width" in iOS (Android is fine) if I put padding on a stack layout in a ListView.GroupHeaderTemplate.

This XAML will reproduce it:

<ListView CachingStrategy="RecycleElement"
          ItemsSource="{Binding}"
          GroupDisplayBinding="{Binding Name}"
          IsGroupingEnabled="true"
          ItemSelected="OnSelectedItem"
          HasUnevenRows="true">
    <ListView.GroupHeaderTemplate>
        <DataTemplate>
            <ViewCell>
                <StackLayout Orientation="Horizontal" Padding="20" >
                    <Label Text="{Binding Name}" />
                </StackLayout>
            </ViewCell>
        </DataTemplate>
    </ListView.GroupHeaderTemplate>
    <ListView.ItemTemplate>
        <DataTemplate>
            <ViewCell>
                <StackLayout>
                    <Image Source="{Binding Logo}" />
                </StackLayout>
            </ViewCell>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>


The key part that seems to cause it is <StackLayout Orientation="Horizontal" Padding="20" >
If I take either of those 2 attributes out it stops breaking.

The backtrace for the error I got is:

System.ArgumentException: NaN is not a valid value for width
  at Xamarin.Forms.Size..ctor (System.Double width, System.Double height) [0x00008] in C:\BuildAgent\work\ca3766cfc22354a1\Xamarin.Forms.Core\Size.cs:19
  at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in C:\BuildAgent\work\ca3766cfc22354a1\Xamarin.Forms.Core\VisualElement.cs:456
  at Xamarin.Forms.VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) [0x00054] in C:\BuildAgent\work\ca3766cfc22354a1\Xamarin.Forms.Core\VisualElement.cs:527
  at Xamarin.Forms.StackLayout.CompressHorizontalLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, System.Double widthConstraint, System.Double heightConstraint) [0x000f0] in C:\BuildAgent\work\ca3766cfc22354a1\Xamarin.Forms.Core\StackLayout.cs:242
  at Xamarin.Forms.StackLayout.CompressNaiveLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, Xamarin.Forms.StackOrientation orientation, System.Double widthConstraint, System.Double heightConstraint) [0x00020] in C:\BuildAgent\work\ca3766cfc22354a1\Xamarin.Forms.Core\StackLayout.cs:275
  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) [0x00066] in C:\BuildAgent\work\ca3766cfc22354a1\Xamarin.Forms.Core\StackLayout.cs:111
  at Xamarin.Forms.StackLayout.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x0005b] in C:\BuildAgent\work\ca3766cfc22354a1\Xamarin.Forms.Core\StackLayout.cs:44
  at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x000c7] in C:\BuildAgent\work\ca3766cfc22354a1\Xamarin.Forms.Core\Layout.cs:229
  at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in C:\BuildAgent\work\ca3766cfc22354a1\Xamarin.Forms.Core\Layout.cs:194
  at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in C:\BuildAgent\work\ca3766cfc22354a1\Xamarin.Forms.Core\VisualElement.cs:629
  at Xamarin.Forms.VisualElement.SetSize (System.Double width, System.Double height) [0x00021] in C:\BuildAgent\work\ca3766cfc22354a1\Xamarin.Forms.Core\VisualElement.cs:773
  at Xamarin.Forms.VisualElement.set_Bounds (Xamarin.Forms.Rectangle value) [0x0005d] in C:\BuildAgent\work\ca3766cfc22354a1\Xamarin.Forms.Core\VisualElement.cs:157
  at Xamarin.Forms.VisualElement.Layout (Xamarin.Forms.Rectangle bounds) [0x00000] in C:\BuildAgent\work\ca3766cfc22354a1\Xamarin.Forms.Core\VisualElement.cs:511
  at Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Xamarin.Forms.VisualElement child, Xamarin.Forms.Rectangle region) [0x0016b] in C:\BuildAgent\work\ca3766cfc22354a1\Xamarin.Forms.Core\Layout.cs:148
  at Xamarin.Forms.Platform.iOS.ViewCellRenderer+ViewTableCell.LayoutSubviews () [0x0006e] in C:\BuildAgent\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\Cells\ViewCellRenderer.cs:88
  at at (wrapper managed-to-native) ObjCRuntime.Messaging:void_objc_msgSendSuper_CGRect (intptr,intptr,CoreGraphics.CGRect)
  at UIKit.UIView.set_Frame (CoreGraphics.CGRect value) [0x0002b] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/build/ios/native/UIKit/UIView.g.cs:3139
  at Xamarin.Forms.Platform.iOS.HeaderWrapperView.LayoutSubviews () [0x00014] in C:\BuildAgent\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\Renderers\ListViewRenderer.cs:1024
  at at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/UIKit/UIApplication.cs:79
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/UIKit/UIApplication.cs:63
  at MyProject.iOS.Application.Main (System.String[] args) [0x00008] in /Users/reuben/Projects/MyProject/iOS/Main.cs:17
Comment 9 Stephane Delcroix 2017-03-10 09:36:55 UTC
#c8 is unrelated. there's another issue open about it
Comment 10 Rui Marinho 2017-03-10 15:21:01 UTC
Sorry, should be fixed in 2.3.4-pre4.
Comment 11 Reuben Turk 2017-03-11 01:29:14 UTC
For reference, the issue mentioned in #c9 is https://bugzilla.xamarin.com/show_bug.cgi?id=52389
Comment 12 Reuben Turk 2017-03-11 02:58:15 UTC
2.3.4-pre4 seems to have fixed it. Thank you.
Comment 13 Brandon Minnick 2017-03-12 22:52:37 UTC
Using the same reproduction code, I confirmed the NaN error is gone in Xamarin.Forms v2.3.4-pre4, however, v2.3.4-pre4 now renders the ViewCell/Grid improperly on iOS. Android renders properly.

Screenshots of improperly rendered ViewCell:
https://github.com/brminnick/Xamarin.Forms-NaN-is-not-a-valid-value-for-width-reproduction/issues/1

Reproduction Code (Readme Included):
https://github.com/brminnick/Xamarin.Forms-NaN-is-not-a-valid-value-for-width-reproduction
Comment 14 Jimmy [MSFT] 2017-03-13 16:00:32 UTC
*** Bug 52389 has been marked as a duplicate of this bug. ***
Comment 15 Samantha Houts 2017-03-13 18:43:02 UTC
@Brandon Minnick:

Your improperly rendered ViewCell is Bug 51536. It should only affect the iPhone SE at this time, and you can workaround it by using RetainElement. There is an active PR with the fix (https://github.com/xamarin/Xamarin.Forms/pull/787) that should be merged very soon.

Thank you!
Comment 16 Prasad Raghorte 2017-03-17 12:41:29 UTC
Bug verified on below Environment and is working fine hence marking it verified:
OS: Mac OS Sierra 10.12
Xamarin Studio Enterprise
Version 6.3 (build 834)
Installation UUID: 02abd52f-d54e-47dd-91de-9b9360a27c1b
Runtime:
	Mono 4.8.0 (mono-4.8.0-branch/8f6d0f6) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 408000520

NuGet
Version: 3.5.0.0

Xamarin.Profiler
Version: 1.3.3
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

Apple Developer Tools
Xcode 8.2.1 (11766.1)
Build 8C1002

Xamarin.iOS
Version: 10.8.0.20 (Visual Studio Enterprise Trial)
Hash: f94cf26
Branch: d15-1
Build date: 2017-03-14 12:37:51-0400

Xamarin.Android
Version: 7.2.0.2 (Visual Studio Enterprise Trial)
Android SDK: /Users/globallogic/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
		5.1    (API level 22)
		6.0    (API level 23)
		7.0    (API level 24)
		7.1    (API level 25)

SDK Tools Version: 25.2.5
SDK Platform Tools Version: 25.0.3
SDK Build Tools Version: 25.0.1

Java SDK: /usr
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Xamarin.Mac
Version: 3.2.0.20 (Visual Studio Enterprise Trial)

Xamarin Inspector
Version: 1.2.0-rc.3
Hash: 5e5e341
Branch: d15-1
Build date: Fri, 10 Mar 2017 22:41:39 GMT

Build Information
Release ID: 603000834
Git revision: bb1dff522ee38d9963b4d97f6cfa0f92c85e8ecb
Build date: 2017-03-14 13:38:37-04
Xamarin addins: 8aac7919dc66c1ce0d9d75fe150ddc1ab15fd941
Build lane: monodevelop-lion-d15-1

Operating System
Mac OS X 10.12.2
Darwin NAG1-DMAC-N07188 16.3.0 Darwin Kernel Version 16.3.0
    Thu Nov 17 20:23:58 PST 2016
    root:xnu-3789.31.2~1/RELEASE_X86_64 x86_64
Comment 17 Prasad Raghorte 2017-03-17 12:42:27 UTC
Created attachment 20414 [details]
Please find attached logs

Logs generated during verification of BUG.

Note You need to log in before you can comment on or make changes to this bug.