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

[regression/7.0.81] Grid can't use star and auto together in version 7.0.81 #14520

Closed
tom-b-iodigital opened this issue Apr 11, 2023 · 24 comments
Labels
area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter i/regression This issue described a confirmed regression on a currently supported version layout-grid p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint platform/android 🤖 platform/iOS 🍎 s/duplicate 2️⃣ This issue or pull request already exists t/bug Something isn't working

Comments

@tom-b-iodigital
Copy link

tom-b-iodigital commented Apr 11, 2023

Discussed in #14519

Description

When you make a grid with a column(row)definition that is set to auto and another one that is set to *, and the grid is a child of a stacklayout the grid measurement calculations are wrong

Steps to Reproduce

  1. create a new MAUI project following the default template
  2. Replace the label with
<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="auto"></ColumnDefinition>
        <ColumnDefinition Width="*"></ColumnDefinition>
    </Grid.ColumnDefinitions>

    <BoxView Color="Red" WidthRequest="20"></BoxView>
    
    <Label
        Grid.Column="1"
        Text="Welcome to .NET Multi-platform App UI"
        SemanticProperties.HeadingLevel="Level2"
        SemanticProperties.Description="Welcome to dot net Multi platform App U I"
        FontSize="18"
        HorizontalOptions="Center" />
</Grid>
  1. run the app and notice the label is not being shown at all
  2. change "auto" to 20 and run again, the label and boxview are shown correctly

These steps seems simple and clear enough, so I didn't provide a repro project yet. If needed I can upload one later

Link to public reproduction project repository

https://github.com/tom-b-iodigital/maui-gridbug

Version with bug

7.0.81

Last version that worked well

7.0.59

Affected platforms

iOS, Android, I was not able test on other platforms

Affected platform versions

All versions

Did you find any workaround?

Setting the column defined with auto to a fixed width fixes the problem, however this is not always possible in complex layouts

Relevant log output

No response

@tom-b-iodigital tom-b-iodigital added the t/bug Something isn't working label Apr 11, 2023
@espenrl
Copy link
Contributor

espenrl commented Apr 11, 2023

I can confirm the same happens with ColumnDefinitions="*,Auto" on Windows. The Auto column is not visible. Also the entire Grid is cut off height wise.

@tom-b-iodigital
Copy link
Author

After some more testing it really seems like the changes to grid calculations should be reverted, all the heights and widths are off.

On a somewhat related note: does anybody know how to rollback the workloads to the previous version of Maui 🙄

@tom-b-iodigital
Copy link
Author

Update: this issue only occurs when the grid is a child of a stacklayout.

This seems to have been already known and tested

which makes it even stranger that this slipped through in an official release

@espenrl
Copy link
Contributor

espenrl commented Apr 11, 2023

It is actually the initial calculations that are wrong. When resizing the window (not applicable for iPhone/Android) everything is recalculated roughly OK. I say rougly as my uniform margin Grid.Margin="15" is not uniform at all.

@espenrl
Copy link
Contributor

espenrl commented Apr 11, 2023

On a somewhat related note: does anybody know how to rollback the workloads to the previous version of Maui 🙄

Visual Studio Installer has rollback to previous version.

@tom-b-iodigital
Copy link
Author

tom-b-iodigital commented Apr 11, 2023

On a somewhat related note: does anybody know how to rollback the workloads to the previous version of Maui 🙄

Visual Studio Installer has rollback to previous version.

yes, and it rolled back visual studio to 17.5.3 but left the workloads at 7.0.81

@espenrl
Copy link
Contributor

espenrl commented Apr 11, 2023

On a somewhat related note: does anybody know how to rollback the workloads to the previous version of Maui 🙄

Visual Studio Installer has rollback to previous version.

yes, and it rolled back visual studio to 17.5.3 but left the workloads at 7.0.81

I got the workload back to 7.0.59 after downgrading both stable and preview VS. Although there seems to be other ways

#12998 (comment)

@drasticactions drasticactions added the s/needs-repro Attach a solution or code which reproduces the issue label Apr 12, 2023
@ghost
Copy link

ghost commented Apr 12, 2023

Hi @tom-b-iodigital. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@drasticactions
Copy link
Contributor

The repros projects are helpful so we can all have a shared understanding of the issue, as you see it, so if we try to fix it we have a baseline to check against. Even if it is an "It's so simple to take the template and replace it with X" type of issue, it makes it clear for anyone wanting to help to just check out your example and run it to see for themselves, and for you to verify that the issue is fixed against a clear example you've created.

@jsuarezruiz jsuarezruiz added area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter layout-grid labels Apr 12, 2023
@tom-b-iodigital
Copy link
Author

Update with a repro project https://github.com/tom-b-iodigital/maui-gridbug

@ghost ghost added s/needs-attention Issue has more information and needs another look and removed s/needs-repro Attach a solution or code which reproduces the issue labels Apr 12, 2023
@berhir
Copy link

berhir commented Apr 12, 2023

We are also facing grid layout issues after updating to the latest MAUI version.
At least some are related to "Auto, *", even though we don't use StackLayout.
I was not able to extract it to a simple repro app yet.
For now, we are also rolling back to the previous version.

@samhouts samhouts added the i/regression This issue described a confirmed regression on a currently supported version label Apr 12, 2023
@joseluisct
Copy link

joseluisct commented Apr 12, 2023

We are facing the same issue, downgrading VS but the project is still on 7.0.81
I have put MauiVersion in csproj but nothing changes
<MauiVersion>7.0.59</MauiVersion>
I can't find a way to go back to workload 7.0.59
All my app entries, datepickers... are not showing right. Please help

@edoust
Copy link

edoust commented Apr 12, 2023

@joseluisct Placing this property should work, at least it does for me... I didn't have to downgrade Visual Studio for it... I also found this command line, but it does not seem to download the right version for me:
dotnet workload update --from-rollback-file https://maui.blob.core.windows.net/metadata/rollbacks/7.0.59.json

@samhouts samhouts added the p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint label Apr 12, 2023
@joseluisct
Copy link

It is working again, with the property MauiVersion, I was still seeing the UI wrong even after rebuild, but after close VS, delete bin/obj and rebuild two times, It is now with 7.0.59. Thank you

@jsuarezruiz jsuarezruiz added this to the Backlog milestone Apr 12, 2023
@ghost
Copy link

ghost commented Apr 12, 2023

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

@jsuarezruiz jsuarezruiz removed the s/needs-attention Issue has more information and needs another look label Apr 12, 2023
@danielftz
Copy link

It is working again, with the property MauiVersion, I was still seeing the UI wrong even after rebuild, but after close VS, delete bin/obj and rebuild two times, It is now with 7.0.59. Thank you

After using MauiVersion in the project file, and deleting bin/obj and rebuilding several times , etc. When run
dotnet workload list in the project directory, I still see

Installed Workload Id      Manifest Version       Installation Source
---------------------------------------------------------------------
maui-maccatalyst           7.0.81/7.0.100         SDK 7.0.200        
maui-ios                   7.0.81/7.0.100         SDK 7.0.200        
maui-android               7.0.81/7.0.100         SDK 7.0.200        
maccatalyst                16.2.2054/7.0.100      SDK 7.0.200     

Could you please tell me what other steps if any that you did?

@joseluisct
Copy link

joseluisct commented Apr 15, 2023

After using MauiVersion in the project file, and deleting bin/obj and rebuilding several times , etc. When run dotnet workload list in the project directory, I still see

Installed Workload Id      Manifest Version       Installation Source
---------------------------------------------------------------------
maui-maccatalyst           7.0.81/7.0.100         SDK 7.0.200        
maui-ios                   7.0.81/7.0.100         SDK 7.0.200        
maui-android               7.0.81/7.0.100         SDK 7.0.200        
maccatalyst                16.2.2054/7.0.100      SDK 7.0.200     

Could you please tell me what other steps if any that you did?

When I run dotnet workload list I also still see 7.0.81

I downgraded VS, also unistalled the app from emulator, run dotnet workload restore and right click solution file in VS and restore Nuget Packages.
I am not sure if any of this steps made it running with the old version, I hope it's working again for you.

@Sebastian1989101
Copy link

+1 this... [M]ulti-Platform [A]pp [U]ser [I]ssues continues to grow

@hartez
Copy link
Contributor

hartez commented Apr 17, 2023

This is a duplicate of #13993. It's been fixed in .NET 8 (#13999) and the fix has been backported to .NET 7 (#14165).

Unfortunately the SR release was already in motion by the time we backported the fix, and the process that should have updated the release did not function as intended. We're looking into that. In the meantime, this will be fixed in the next release.

@hartez hartez closed this as completed Apr 17, 2023
@samhouts samhouts changed the title Grid can't use star and auto together in version 7.0.81 [regression/7.0.81] Grid can't use star and auto together in version 7.0.81 Apr 17, 2023
@samhouts samhouts modified the milestones: Backlog, .NET 7 + Servicing Apr 17, 2023
@kofanov
Copy link

kofanov commented Apr 20, 2023

I spent a lot of time trying to figure out why, after upgrading to 7.0.81, the entire layout of my application floated in various places. Fortunately, I have experimentally established that the problem is with the Grid (separately and inside the CollectionView). Previously aligned elements floated, and the height of the elements in the CollectionView was calculated incorrectly. Since my application uses Grid both for tabular layout and for simulating layers, I came up with the following temporary solution until an update is released.

Create IValueConverter

internal class Hack_GridRowDefinitionsConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        if (value == null || value is not ColumnDefinitionCollection col)
            return null;

        var row = new RowDefinitionCollection();

        if (col.Any())
            row.Add(new RowDefinition(new GridLength(0, GridUnitType.Auto)));

        return row;
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

Define global Grid style

<converters:Hack_GridRowDefinitionsConverter x:Key="Hack_GridRowDefinitionsConverter" />
    <Style TargetType="Grid" ApplyToDerivedTypes="True">
        <Setter Property="RowDefinitions" Value="{Binding ColumnDefinitions, Source={RelativeSource Self}, Converter={StaticResource Hack_GridRowDefinitionsConverter}}" />
    </Style>

This made it possible to set the RowDefinitions="Auto" parameter for all Grids in the application where ColumnDefinitions (i.e. table layout) are defined and ignore all Grids that are used to simulate layers.

The RowDefinitions="Auto" parameter in my case fixes problems with calculating the height of blocks.
For lack of time, I have tested it so far only in Android. Please let me know if you can test it in iOS.

@pikausp
Copy link

pikausp commented Apr 28, 2023

This is a duplicate of #13993. It's been fixed in .NET 8 (#13999) and the fix has been backported to .NET 7 (#14165).

Unfortunately the SR release was already in motion by the time we backported the fix, and the process that should have updated the release did not function as intended. We're looking into that. In the meantime, this will be fixed in the next release.

Is there a timeframe for the next SR?

@FM1973
Copy link

FM1973 commented May 2, 2023

While the next SR is not available:
I downgraded to version 7.0.59 by using <MauiVersion>7.0.59</MauiVersion> in the project file.
This - as far as I can tell now - does not only work for local debug versions, but also for a release build I published to the google play console. I didn´t test IOS yet, but I hope that this will work too. I´m looking forward to the nuget solution @mattleibow was talking about. Hopefully the version desaster will then be a nightmare of the past...

@giuseppenovielli
Copy link

I hope for NuGet package, so it can release fastest this hot bug.
Maui architecture is a lot of bigger and complex so can't wait long time for hot bugs fix!

@samhouts
Copy link
Member

samhouts commented May 3, 2023

Duplicate of #13993

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter i/regression This issue described a confirmed regression on a currently supported version layout-grid p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint platform/android 🤖 platform/iOS 🍎 s/duplicate 2️⃣ This issue or pull request already exists t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests