maui icon indicating copy to clipboard operation
maui copied to clipboard

[regression/8.0.0-preview.3.8149] [android] Paths do not render correctly (width/height not being properly calculated?)

Open jonathanpeppers opened this issue 2 years ago • 11 comments

Description

I'm working on: https://github.com/dotnet/maui/issues/9485

main stable
image image

The "Play Button" disappeared, it is something like:

<Border
    Style="{StaticResource PlayBorderStyle}">
    <Border.StrokeShape>
        <Ellipse />
    </Border.StrokeShape>
    <Border.Shadow>
        <Shadow 
            Opacity="0.5"
            Offset="4, 4"/>
    </Border.Shadow>
    <Path
        Data="M0,0L15.825011,8.0009766 31.650999,15.997986 15.825011,23.998993 0,32 0,15.997986z"
        Style="{StaticResource PlayIconStyle}"/>
</Border>

Steps to Reproduce

Run this app w/ dotnet/maui/main: https://github.com/jsuarezruiz/netmaui-surfing-app-challenge

Link to public reproduction project repository

https://github.com/jsuarezruiz/netmaui-surfing-app-challenge

Version with bug

8.0 previews

Last version that worked well

7.0 (current)

Affected platforms

Android

Affected platform versions

API 33

Did you find any workaround?

No

Relevant log output

> dotnet workload list

Installed Workload Id      Manifest Version       Installation Source
---------------------------------------------------------------------
maui-windows               7.0.59/7.0.100         VS 17.5.33516.290
maui-maccatalyst           7.0.59/7.0.100         VS 17.5.33516.290
maccatalyst                16.2.1024/7.0.100      VS 17.5.33516.290
maui-ios                   7.0.59/7.0.100         VS 17.5.33516.290
ios                        16.2.1024/7.0.100      VS 17.5.33516.290
maui-android               7.0.59/7.0.100         VS 17.5.33516.290
android                    33.0.26/7.0.100        VS 17.5.33516.290

jonathanpeppers avatar Mar 28 '23 15:03 jonathanpeppers

/cc @jsuarezruiz maybe something needs to change in this sample to work w/ main?

jonathanpeppers avatar Mar 28 '23 15:03 jonathanpeppers

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.

ghost avatar Mar 28 '23 18:03 ghost

/cc @jsuarezruiz maybe something needs to change in this sample to work w/ main?

The only recent change affecting Border is this https://github.com/dotnet/maui/pull/10964, but it hasn't been merged yet. I've been checking and:

  • The Border sets its content correctly.
  • A Path is created, the Mapper invokes the methods to map the Shape.
  • In the ShapeDrawable class, the Draw method is invoked and it is drawn.

But, the Path was not visible, it was being drawn but it was not visible. Why?. After reviewing the visual tree in detail I realized that the Path is drawn out of position and since Border clips the outline, it is not visible.

Removing the vertical and horizontal alignment options: image

I have to review the changes related with Layout from stable to main. Maybe @hartez could help us here.

jsuarezruiz avatar Mar 29 '23 08:03 jsuarezruiz

Verified this issue with Visual Studio Enterprise 17.7.0 Preview 3.0(net8). Can repro on Android platform with sample project. /netmaui-surfing-app-challenge

jinxinjuan avatar Jul 24 '23 09:07 jinxinjuan

I wonder if this is the same issue as https://github.com/dotnet/maui/issues/17111

jstedfast avatar Aug 31 '23 16:08 jstedfast

I was able to reproduce this using net8.0 (built from main) on android.

The clipping around the avatar images also seems wrong.

Oddly, the Microsoft.Maui.Samples app that does the same thing does not have these issues.

jstedfast avatar Sep 02 '23 11:09 jstedfast

This may be a bug in Path??

Using this as my Maui.Controls.Samples.Sandbox MainPage.xaml

<ContentPage
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="Maui.Controls.Sample.MainPage"
    xmlns:local="clr-namespace:Maui.Controls.Sample">
    <Grid ColumnDefinitions="Auto, Auto" RowDefinitions="Auto" VerticalOptions="Center" HorizontalOptions="Center" Background="Pink">
        <Border Grid.Row="0" Grid.Column="0" Background="LightBlue" StrokeThickness="0" HeightRequest="44" WidthRequest="44">
            <Border.StrokeShape>
                <Ellipse />
            </Border.StrokeShape>
            <Border.Shadow>
                <Shadow Opacity="0.5" Offset="4, 4"/>
            </Border.Shadow>
            <Path Fill="Black" HorizontalOptions="Center" VerticalOptions="Center" Scale="0.5" Margin="6"
                 Data="M0,0L15.825011,8.0009766 31.650999,15.997986 15.825011,23.998993 0,32 0,15.997986z"/>
        </Border>
        <Path Grid.Row="0" Grid.Column="1" Fill="Black" HorizontalOptions="Center" VerticalOptions="Center" Scale="0.5" Margin="6"
            Data="M0,0L15.825011,8.0009766 31.650999,15.997986 15.825011,23.998993 0,32 0,15.997986z"/>
    </Grid>
</ContentPage>

It renders like this:

Screenshot 2023-09-22 163005

jstedfast avatar Sep 22 '23 20:09 jstedfast

If I specify a WidthRequest and HeightRequest, things work:

<ContentPage
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="Maui.Controls.Sample.MainPage"
    xmlns:local="clr-namespace:Maui.Controls.Sample">
    <Grid ColumnDefinitions="Auto, Auto" RowDefinitions="Auto" VerticalOptions="Center" HorizontalOptions="Center" Background="Pink">
        <Border Grid.Row="0" Grid.Column="0" Background="LightBlue" StrokeThickness="0" HeightRequest="44" WidthRequest="44">
            <Border.StrokeShape>
                <Ellipse />
            </Border.StrokeShape>
            <Border.Shadow>
                <Shadow Opacity="0.5" Offset="4, 4"/>
            </Border.Shadow>
            <Path Fill="Black" HorizontalOptions="Center" VerticalOptions="Center" Scale="0.5" Margin="6" WidthRequest="31.651" HeightRequest="32"
                 Data="M0,0L15.825011,8.0009766 31.650999,15.997986 15.825011,23.998993 0,32 0,15.997986z"/>
        </Border>
        <Path Grid.Row="0" Grid.Column="1" Background="LightGreen" Fill="Black" HorizontalOptions="Center" VerticalOptions="Center" WidthRequest="31.651" HeightRequest="32" Scale="0.5" Margin="6"
            Data="M0,0L15.825011,8.0009766 31.650999,15.997986 15.825011,23.998993 0,32 0,15.997986z"/>
    </Grid>
</ContentPage>

Screenshot 2023-09-22 164525

jstedfast avatar Sep 22 '23 20:09 jstedfast

They also work if I remove the Margin="6" from the Path element.

jstedfast avatar Sep 28 '23 20:09 jstedfast

The above PR improves things by at least calculating the correct size for the Paths.

Unfortunately, things still don't render in the surfer app (but do in the test case above) unless I unset the Margin.

This goes back to what @jsuarezruiz was saying regarding the path being drawn out of position somehow.

jstedfast avatar Sep 28 '23 20:09 jstedfast

Okay, so I think that the Scale must be getting applied after Margins and Vertical/HorizontalOptions are applied, which is causing the Path to be effectively rendered outside the clip path for the containing ContentViewGroup.

I have no idea how to proceed.

jstedfast avatar Sep 29 '23 20:09 jstedfast