Skip to content

Shadows disappearing permanently in Android and Windows after Label opacity is at any time set to "0" #29764

@jonmdev

Description

@jonmdev

Description

Bug Behavior:

Shadows on Labels disappear after the Label is set to 0 opacity and do not return.

Affected Platforms:

Windows for ~2 years. Now Android too (regression). Did not test iOS.

Details

I reported almost two years ago this bug in Windows: #17916

This issue has not received any attention since, although it was verified by staff, from my minimal reproduction project.

The problem persists but now has also spread to Android. Previously this was not a problem in Android, only Windows. Now I see this problem in my Android builds as well. I am not sure how long it has been there but it certainly wasn't a problem from the beginning.

@albyrock87 and @jsuarezruiz I know you did a lot to optimize shadows, and I am grateful for that. Any thoughts?

Here is a new Bug Project reproducing the issue in certainly at least both Windows and Android (iOS not tested): https://github.com/jonmdev/ShadowVisibilityBug

REPRODUCTION CODE

My project reproduces the bug in a blank Maui default project, with the following added to App.xaml.cs:

public class MyMainPage : ContentPage {
    public MyMainPage() {
        
        // Basic page build 
        AbsoluteLayout abs = new();
        Content = abs;

        AbsoluteLayout tweenAbs = new();
        abs.Add(tweenAbs);

        Label label = new();
        label.Text = "HELLO";
        label.FontSize = 80;
        label.Shadow = new() { Brush = Colors.DarkRed, Radius = 10, Offset = new Point(0, 4) };
        tweenAbs.Add(label);

        //========================
        // BUG INSTRUCTIONS
        //========================
        // 1) Set veToTween = label
        // 2) Set toggleVisibility = false (don't toggle visibility)
        // 3) See no shadow on Android or Windows as the label tweens in
        // 4) Set toggleVisibility = true to recover shadow on Android, but not Windows
        //========================

        // Create Timer
        var timer = Application.Current.Dispatcher.CreateTimer();
        double deltaTime = 1 / 60.0;
        double fadeDuration = 5;
        VisualElement veToTween = label;
        veToTween.Opacity = 0;
        
        // TOGGLE "IS VISIBLE" TRICK
        bool toggleVisibility = false; // "true" recovers the android shadow, but still not windows
        if (toggleVisibility) { veToTween.IsVisible = false; }
        
        // Timer Animation Tick
        timer.Tick += delegate (object s, EventArgs e) {

            // toggling the "IsVisible" seems to recover the android shadow but not the Windows one
            if (toggleVisibility) {
                veToTween.IsVisible = true; 
            }

            // tween up the opacity until it hits 1
            if (veToTween.Opacity < 1) {
                veToTween.Opacity += deltaTime / fadeDuration;
            }
            if (veToTween.Opacity > 1) {
                veToTween.Opacity = 1;
            }
        };
        timer.Interval = TimeSpan.FromSeconds(deltaTime);
        timer.Start();

    }
}

You can see this is just a simple animation on a Label that has a shadow to tween opacity 0 to 1.

In both cases (Android and Windows), there is no shadow visible on the Label. Previously this was known in Windows, but as noted it is now new in Android.

Interestingly, in Android, we can recover the shadow by setting toggleVisibility = true in my code. This switches Label visibility off and then on. I don't know what this signifies or why this helps. I was just trying to find any way to make it work.

Steps to Reproduce

  1. Open my project
  2. See all code is in App.xaml.cs
  3. Run the project, it will tween in a label that should have a shadow on it.
  4. There will be no shadow on Android or Windows visible though.

Link to public reproduction project repository

https://github.com/jonmdev/ShadowVisibilityBug

Version with bug

9.0.14 SR1.4

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

Unknown/Other

Affected platforms

Windows, Android

Affected platform versions

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-controls-labelLabel, Spanarea-drawingShapes, Borders, Shadows, Graphics, BoxView, custom drawingpartner/syncfusionIssues / PR's with Syncfusion collaborationplatform/androidplatform/windowss/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions