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

MAUI is not correctly drawing or updating shadows causing bizarre outcomes in numerous situations in Windows (simple repro project included) #17996

Closed
jonmdev opened this issue Oct 13, 2023 · 3 comments
Labels
area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing platform/windows 🪟 s/triaged Issue has been reviewed t/bug Something isn't working

Comments

@jonmdev
Copy link

jonmdev commented Oct 13, 2023

Description

If you make a RoundRectangle Border and then apply a Shadow to it, it will draw the Shadow as a square even if you have it set to draw a RoundRectangle shape.

For example, here is a simple configuration in Android rendering the shadow shape correctly:

windows shadow mask 2

Here is the same configuration in Windows:

windows shadow mask 1

It is drawing an abnormal square shadow which is obviously not the intended design.

I think this is more an issue of it not drawing correctly on the update of the Border shape. Ie. It is not refreshing the Shadow. I have seen it draw Shadows properly on rounded Borders in WIndows under other circumstances.

Severity of Issue
There are many bizarre behaviors being exhibited by Windows shadows in MAUI. I have another situation where my entire screen is covered by a shadow from a small element at the top. It is stretching them bizarrely. Sometimes they are in the wrong place on screen. Or the wrong shape as here.

I presume this is all the same bug, where I presume it is just not updating the shadow when it ought to. So I am only providing one repro. If needed, I can provide numerous others.

Windows shadows are mostly unusable at this point.

Steps to Reproduce

  1. Create new MAUI project called "Windows Shadow Mask Bug"
  2. Copy and paste the following code to replace App.xaml.cs and play project:
using Microsoft.Maui.Controls.Shapes;

namespace Windows_Shadow_Mask_Bug {
    public partial class App : Application {
        public App() {
            InitializeComponent();

            ContentPage mainPage = new();
            mainPage.BackgroundColor = Colors.CornflowerBlue;
            this.MainPage = mainPage;

            VerticalStackLayout vert = new();
            mainPage.Content = vert;

            Border border = new();
            border.Stroke = Colors.White;
            border.StrokeThickness = 5;
            border.Shadow = new Shadow() { Offset = new Point(0, 6), Radius = 5 };
            vert.Add(border);

            AbsoluteLayout abs = new();
            border.Content = abs;

            Image image = new();
            abs.Add(image);
            image.Source = ImageSource.FromUri(new Uri("https://www.readersdigest.ca/wp-content/uploads/2019/11/cat-10-e1573844975155.jpg"));
            image.Aspect = Aspect.AspectFill;

            //resize function
            mainPage.SizeChanged += delegate {
                if (mainPage.Width > 0) {
                    int width = (int)mainPage.Width;
                    border.WidthRequest = border.HeightRequest = width * 0.5;
                    image.WidthRequest = image.HeightRequest = width * 0.5;
                    border.StrokeShape = new RoundRectangle() { CornerRadius = width * 0.25 };
                }
            };
        }
    }
}

Link to public reproduction project repository

https://github.com/jonmdev/Windows-Shadow-Mask-Bug

Version with bug

7.0.96

Is this a regression from previous behavior?

No, this is something new

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

Windows 10

Did you find any workaround?

No response

Relevant log output

No response

@jonmdev jonmdev added the t/bug Something isn't working label Oct 13, 2023
@jonmdev jonmdev changed the title MAUI does not draw correct shadow for RoundRectangle Border in Windows (simple repro project included) MAUI does not draw correct shadow for RoundRectangle Border when shape is set in Windows (simple repro project included) Oct 13, 2023
@jonmdev jonmdev changed the title MAUI does not draw correct shadow for RoundRectangle Border when shape is set in Windows (simple repro project included) MAUI is not correctly drawing or updating shadows causing bizarre outcomes in numerous situations in Windows (simple repro project included) Oct 15, 2023
@jsuarezruiz jsuarezruiz added platform/windows 🪟 area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing labels Oct 16, 2023
@XamlTest
Copy link
Collaborator

Verified this on Visual Studio Enterprise 17.8.0 Preview 3.0(8.0.0-rc.2.9373). This issue does not repro on Windows 11, Android 13.0-API33 and iOS 16.4 with below Project:
Windows Shadow Mask Bug.zip

Windows:
image

@XamlTest XamlTest added s/triaged Issue has been reviewed s/try-latest-version Please try to reproduce the potential issue on the latest public version labels Oct 17, 2023
@ghost
Copy link

ghost commented Oct 17, 2023

Hi @jonmdev. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.

You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.

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.

@jonmdev
Copy link
Author

jonmdev commented Oct 20, 2023

Closed as made new thread with current repro code.

@jonmdev jonmdev closed this as completed Oct 20, 2023
@ghost ghost removed the s/try-latest-version Please try to reproduce the potential issue on the latest public version label Oct 20, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Nov 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing platform/windows 🪟 s/triaged Issue has been reviewed t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants