Bug 33086 - Bug in Layout system when a grid is inside another grid
Summary: Bug in Layout system when a grid is inside another grid
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.4.4
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-08-14 03:38 UTC by softlion
Modified: 2016-03-18 22:24 UTC (History)
5 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Sample Project (318.59 KB, application/octet-stream)
2015-08-19 02:04 UTC, Arpit Jha
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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.

Related Links:
Status:
RESOLVED FIXED

Description softlion 2015-08-14 03:38:55 UTC
TESTED ON ANDROID 4.4

When a first Grid is set to Fill/Fill, 
when inside this grid another Grid is set to Fill/Start,
then any self-sizing view (like an Image) inside the second Grid receives bad values in OnSizeRequest.
This does not happen if the second grid is removed.

Repro: i use an Image with a Source set to a big JPG (its width is larger than 1024px) and Aspect set to Fit.

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:xamForms="clr-namespace:XamSvg.XamForms;assembly=XamSvg.XamForms"
             x:Class="XamSvg.Demo.Page2">

  <!-- Bug test -->
  <Grid HorizontalOptions="Fill" VerticalOptions="Fill" RowSpacing="0">
    <Grid.RowDefinitions>
      <RowDefinition Height="Auto"/>
      <RowDefinition Height="*"/>
      <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>

    <Grid HorizontalOptions="Fill" VerticalOptions="Start" BackgroundColor="Blue">
       <Image HorizontalOptions="Fill" VerticalOptions="Start" Source="test.jpg" Aspect="AspectFit"  />
    </Grid>

    <BoxView Grid.Row="1" Color="Yellow" HeightRequest="50" HorizontalOptions="Fill" />
    <BoxView Grid.Row="2" Color="Red" HeightRequest="25" HorizontalOptions="Fill" />
  </Grid>

</ContentPage>



If you replace
    <Grid HorizontalOptions="Fill" VerticalOptions="Start" BackgroundColor="Blue">
       <Image HorizontalOptions="Fill" VerticalOptions="Start" Source="test.jpg" Aspect="AspectFit"  />
    </Grid>

with
       <Image HorizontalOptions="Fill" VerticalOptions="Start" Source="test.jpg" Aspect="AspectFit"  />

It works as expected.


The cause is the values received in OnSizeRequest during the layout phase.
Using XamSvg <xamForms:SvgImage Svg="res:images.DisqueGris" HorizontalOptions="Fill" VerticalOptions="Start" /> OnSizeRequest receives:

I/mono-stdout(14605): Svg size requested for 'res:images.DisqueGris'. visible=200x200 constraint=+Infinix+Infini, alignment=FillxStart
I/mono-stdout(14605): isWidthForced: False, isHeighForced: False
I/mono-stdout(14605): OnSizeRequest for res:images.DisqueGris returned 200x200
I/mono-stdout(14605): Svg size requested for 'res:images.DisqueGris'. visible=200x200 constraint=200x+Infini, alignment=FillxStart
I/mono-stdout(14605): OnSizeRequest for res:images.DisqueGris returned 200x200
I/mono-stdout(14605): Svg size requested for 'res:images.DisqueGris'. visible=200x200 constraint=+Infinix+Infini, alignment=FillxStart
I/mono-stdout(14605): isWidthForced: False, isHeighForced: False
I/mono-stdout(14605): OnSizeRequest for res:images.DisqueGris returned 200x200
I/mono-stdout(14605): Svg size requested for 'res:images.DisqueGris'. visible=200x200 constraint=200x+Infini, alignment=FillxStart
I/mono-stdout(14605): isWidthForced: True, isHeighForced: False
I/mono-stdout(14605): OnSizeRequest for res:images.DisqueGris returned 200x200
I/mono-stdout(14605): Svg size requested for 'res:images.DisqueGris'. visible=200x200 constraint=360x200, alignment=FillxStart
I/mono-stdout(14605): isWidthForced: True, isHeighForced: True
I/mono-stdout(14605): OnSizeRequest for res:images.DisqueGris returned 200x200
I/mono-stdout(14605): OnSizeAllocated to 360 x 200

Result should be 360x360 as the svg is rectangular, horizontaloption is fill, and svg respects the aspect ratio.



If the second grid is removed OnSizeRequest correctly receives:

I/mono-stdout(14814): Svg size requested for 'res:images.DisqueGris'. visible=200x200 constraint=360x567, alignment=FillxStart
I/mono-stdout(14814): isWidthForced: True, isHeighForced: True
I/mono-stdout(14814): OnSizeRequest for res:images.DisqueGris returned 360x360
I/mono-stdout(14814): Svg size requested for 'res:images.DisqueGris'. visible=200x200 constraint=360x360, alignment=FillxStart
I/mono-stdout(14814): isWidthForced: True, isHeighForced: True
I/mono-stdout(14814): OnSizeRequest for res:images.DisqueGris returned 360x360
I/mono-stdout(14814): Svg size requested for 'res:images.DisqueGris'. visible=200x200 constraint=360x360, alignment=FillxStart
I/mono-stdout(14814): isWidthForced: True, isHeighForced: True
I/mono-stdout(14814): OnSizeRequest for res:images.DisqueGris returned 360x360
I/mono-stdout(14814): OnSizeAllocated to 360 x 360
Comment 1 Arpit Jha 2015-08-19 02:04:16 UTC
Created attachment 12566 [details]
Sample Project

I have checked this issue and able to reproduce this issue with the help of bug description.

Steps that I have followed to reproduce :
1.Create a xamarin.Forms application.
2.Add a xaml class.
3.Implement above code in Page1.xaml.
4.Call Page1.xaml in App.cs.

Screencast: http://www.screencast.com/t/PnGx4tz6j9

Environment Info:
Xamarin.Forms version:1.4.0.0
Xamarin.Forms version: 3.11.836
Microsoft Visual Studio Professional 2013
Version 12.0.40629.00 Update 5
Microsoft .NET Framework
Version 4.5.51641

Installed Version: Professional

Xamarin   3.11.836.0 (ed5c750)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   5.1.5.3 (f98871a95a479f6d71b3067b7e5834d41fcb2118)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.Forms Intellisense   1.0
Provides intellisense for Xamarin.Forms in the XML editor.

Xamarin.iOS   8.10.4.0 (6db87c53c073f4af2f5247fb738a27ea08c094fd)
Visual Studio extension to enable development for Xamarin.iOS.

Xamarin.iOS Unified Migration   1.0
Automated migration for Xamarin iOS Classic projects to Unified

Xamarin.TestCloud.Integration   1.0
Early preview of Xamarin Test Cloud integration
Comment 2 Samantha Houts [MSFT] 2016-03-18 22:24:20 UTC
Thank you for taking the time to submit this report. After reviewing the description of this bug, we no longer believe it affects the current version of Xamarin.Forms. If you are still experiencing the issue after updating your packages, please reopen this report with an attached reproduction.
 
For your convenience, we have created some reproduction best practices viewable here: https://gist.github.com/jassmith/92405c300e54a01dcc6d

Warm regards,
Xamarin Forms Team