Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] iOS layout crash #766

Closed
davidortinau opened this issue Apr 16, 2021 · 0 comments
Closed

[Bug] iOS layout crash #766

davidortinau opened this issue Apr 16, 2021 · 0 comments
Assignees
Labels
fixed-in-6.0.100-preview.5 Look for this fix in 6.0.100-preview.5! t/bug Something isn't working
Projects

Comments

@davidortinau
Copy link
Contributor

Description

This layout throws an error:

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
x:Class="LayoutLab.BusinessTumblePage" 
BackgroundColor="Maroon" 
Title="StackLayout">
	<ContentPage.Content>
    <ScrollView>
      <StackLayout Spacing="0" Padding="0" BackgroundColor="Maroon">
        <BoxView HorizontalOptions="FillAndExpand" HeightRequest="100" VerticalOptions="Start" Color="Gray" />
        <Button CornerRadius="30"
                TranslationY="-30"
                HeightRequest="60" WidthRequest="60" BackgroundColor="Orange" HorizontalOptions="Center" VerticalOptions="Start" />
        <StackLayout HeightRequest="100" VerticalOptions="Start" HorizontalOptions="FillAndExpand" Spacing="20" BackgroundColor="Maroon">
          <Label Text="User Name" FontSize="28" HorizontalOptions="Center" VerticalOptions="Center" FontAttributes="Bold" />
          <Entry Text="Bio + Hashtags" TextColor="White" BackgroundColor="Maroon" HorizontalOptions="FillAndExpand" VerticalOptions="CenterAndExpand" />
        </StackLayout>
        <StackLayout Orientation="Horizontal" HeightRequest="50" BackgroundColor="White" Padding="5">
          <StackLayout Spacing="0" BackgroundColor="White" Orientation="Horizontal" HorizontalOptions="Start">
            <BoxView BackgroundColor="Black" WidthRequest="40" HeightRequest="40"  HorizontalOptions="StartAndExpand" VerticalOptions="Center" />
            <Label FontSize="14" TextColor="Black" Text="Accent Color" HorizontalOptions="StartAndExpand" VerticalOptions="Center" />
          </StackLayout>
          <StackLayout Spacing="0" BackgroundColor="White" Orientation="Horizontal" HorizontalOptions="EndAndExpand">
            <BoxView BackgroundColor="Maroon" WidthRequest="40" HeightRequest="40" HorizontalOptions="Start" VerticalOptions="Center" />
            <Label FontSize="14" TextColor="Black" Text="Primary Color" HorizontalOptions="StartAndExpand" VerticalOptions="Center" />
          </StackLayout>
        </StackLayout>
        <StackLayout Orientation="Horizontal">
          <Label FontSize="14" Text="Age:" TextColor="White" HorizontalOptions="Start" VerticalOptions="Center" WidthRequest="100" />
          <Entry HorizontalOptions="FillAndExpand" Text="35" TextColor="White" BackgroundColor="Maroon" />
        </StackLayout>
        <StackLayout Orientation="Horizontal">
          <Label FontSize="14" Text="Interests:" TextColor="White" HorizontalOptions="Start" VerticalOptions="Center" WidthRequest="100" />
          <Entry HorizontalOptions="FillAndExpand" Text="Xamarin.Forms" TextColor="White" BackgroundColor="Maroon" />
        </StackLayout>
        <StackLayout Orientation="Horizontal">
          <Label FontSize="14" Text="Ask me about:" TextColor="White" HorizontalOptions="Start" VerticalOptions="Center" WidthRequest="100" />
          <Entry HorizontalOptions="FillAndExpand" Text="Xamarin, C#, .NET, Mono..." TextColor="White" BackgroundColor="Maroon" />
        </StackLayout>
      </StackLayout>
    </ScrollView>
	</ContentPage.Content>
</ContentPage>

I'm using these startup renderers:

public class Startup : IStartup
	{
		public void Configure(IAppHostBuilder appBuilder)
		{
			appBuilder
				.UseFormsCompatibility(false)
				#if __ANDROID__
				.ConfigureMauiHandlers(handlers => {
					handlers.AddCompatibilityRenderer(typeof(Microsoft.Maui.Controls.BoxView), 
					typeof(Microsoft.Maui.Controls.Compatibility.Platform.Android.BoxRenderer));
					handlers.AddCompatibilityRenderer(typeof(Microsoft.Maui.Controls.Frame), 
					typeof(Microsoft.Maui.Controls.Compatibility.Platform.Android.FastRenderers.FrameRenderer));	
				})
				#endif
				#if __IOS__
				.ConfigureMauiHandlers(handlers => {
					handlers.AddCompatibilityRenderer(typeof(Microsoft.Maui.Controls.BoxView), 
					typeof(Microsoft.Maui.Controls.Compatibility.Platform.iOS.BoxRenderer));
					handlers.AddCompatibilityRenderer(typeof(Microsoft.Maui.Controls.Frame), 
					typeof(Microsoft.Maui.Controls.Compatibility.Platform.iOS.FrameRenderer));
					handlers.AddCompatibilityRenderer(typeof(Microsoft.Maui.Controls.ScrollView), 
					typeof(Microsoft.Maui.Controls.Compatibility.Platform.iOS.ScrollViewRenderer));
				})
				#endif
				.UseMauiApp<App>();
		}
	}

Error:

System.ArgumentException: NaN is not a valid value for width
   at Microsoft.Maui.Size..ctor(Double width, Double height)
   at Microsoft.Maui.Controls.VisualElement.GetSizeRequest(Double widthConstraint, Double heightConstraint)
   at Microsoft.Maui.Controls.VisualElement.Measure(Double widthConstraint, Double heightConstraint, MeasureFlags flags)
   at Microsoft.Maui.Controls.StackLayout.CompressHorizontalLayout(LayoutInformation layout, Double widthConstraint, Double heightConstraint)
   at Microsoft.Maui.Controls.StackLayout.CompressNaiveLayout(LayoutInformation layout, StackOrientation orientation, Double widthConstraint, Double heightConstraint)
   at Microsoft.Maui.Controls.StackLayout.CalculateLayout(LayoutInformation layout, Double x, Double y, Double widthConstraint, Double heightConstraint, Boolean processExpanders)
   at Microsoft.Maui.Controls.StackLayout.OnSizeRequest(Double widthConstraint, Double heightConstraint)
   at Microsoft.Maui.Controls.VisualElement.OnMeasure(Double widthConstraint, Double heightConstraint)
   at Microsoft.Maui.Controls.VisualElement.GetSizeRequest(Double widthConstraint, Double heightConstraint)
   at Microsoft.Maui.Controls.Layout.GetSizeRequest(Double widthConstraint, Double heightConstraint)
   at Microsoft.Maui.Controls.VisualElement.Measure(Double widthConstraint, Double heightConstraint, MeasureFlags flags)
   at Microsoft.Maui.Controls.StackLayout.CalculateNaiveLayout(LayoutInformation layout, StackOrientation orientation, Double x, Double y, Double widthConstraint, Double heightConstraint)
   at Microsoft.Maui.Controls.StackLayout.CalculateLayout(LayoutInformation layout, Double x, Double y, Double widthConstraint, Double heightConstraint, Boolean processExpanders)
   at Microsoft.Maui.Controls.StackLayout.OnSizeRequest(Double widthConstraint, Double heightConstraint)
   at Microsoft.Maui.Controls.VisualElement.OnMeasure(Double widthConstraint, Double heightConstraint)
   at Microsoft.Maui.Controls.VisualElement.GetSizeRequest(Double widthConstraint, Double heightConstraint)
   at Microsoft.Maui.Controls.Layout.GetSizeRequest(Double widthConstraint, Double heightConstraint)
   at Microsoft.Maui.Controls.VisualElement.Measure(Double widthConstraint, Double heightConstraint, MeasureFlags flags)
   at Microsoft.Maui.Controls.ScrollView.LayoutChildren(Double x, Double y, Double width, Double height)
   at Microsoft.Maui.Controls.Layout.UpdateChildrenLayout()
   at Microsoft.Maui.Controls.Layout.OnSizeAllocated(Double width, Double height)
   at Microsoft.Maui.Controls.VisualElement.SizeAllocated(Double width, Double height)
   at Microsoft.Maui.Controls.VisualElement.SetSize(Double width, Double height)
   at Microsoft.Maui.Controls.VisualElement.set_Bounds(Rectangle value)
   at Microsoft.Maui.Controls.VisualElement.Layout(Rectangle bounds)
   at Microsoft.Maui.Controls.Layout.LayoutChildIntoBoundingRegion(VisualElement child, Rectangle region)
   at Microsoft.Maui.Controls.Page.LayoutChildren(Double x, Double y, Double width, Double height)
   at Microsoft.Maui.Controls.Page.UpdateChildrenLayout()
   at Microsoft.Maui.Controls.Page.OnSizeAllocated(Double width, Double height)
   at Microsoft.Maui.Controls.VisualElement.SizeAllocated(Double width, Double height)
   at Microsoft.Maui.Controls.VisualElement.SetSize(Double width, Double height)
   at Microsoft.Maui.Controls.VisualElement.set_Bounds(Rectangle value)
   at Microsoft.Maui.Controls.VisualElement.Layout(Rectangle bounds)
   at Microsoft.Maui.Controls.VisualElement.Arrange(Rectangle bounds)
   at Microsoft.Maui.Controls.ContentPage.ArrangeOverride(Rectangle bounds)
   at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IFrameworkElement.Arrange(Rectangle bounds)
   at Microsoft.Maui.LayoutView.LayoutSubviews()

Steps to Reproduce

Run the app with the BusinessTumblePage.xaml

Basic Information

  • Version with issue: Preview 3
  • Platform Target Frameworks:
    • iOS: 14.4

Reproduction Link

Archive.zip

@davidortinau davidortinau added the t/bug Something isn't working label Apr 16, 2021
@hartez hartez self-assigned this Apr 19, 2021
hartez added a commit that referenced this issue May 7, 2021
@hartez hartez added this to In Progress in Preview 4 May 10, 2021
@hartez hartez moved this from In Progress to Done in Preview 4 May 10, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Feb 19, 2022
@samhouts samhouts added the fixed-in-6.0.100-preview.5 Look for this fix in 6.0.100-preview.5! label Feb 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
fixed-in-6.0.100-preview.5 Look for this fix in 6.0.100-preview.5! t/bug Something isn't working
Projects
No open projects
Development

No branches or pull requests

3 participants