dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.26k stars 1.76k forks source link

FontImageSource Glyph becomes invisible intermittently on Android #25783

Open rezamohamed opened 1 week ago

rezamohamed commented 1 week ago

Description

I'm setting an icon for a button as follows,

<FontImageSource FontFamily="FontIcons" Glyph="{StaticResource Pen}" />

and on Android only, intermittently the icon will not render when I navigate around my app (AppShell). It is always on the same page, I have tried adding the Glyph in the code behind in OnAppearing, but the issue still persists. Moving the button to different parts of the View code shifts the issue to a different Page altogether.

This seems to be a recurring problem since I found similar issues in prior versions that have an update that this is fixed but it seems to be still occurring. eg. https://github.com/dotnet/maui/issues/14587

I don't have this issue on iOS.

Here is a video of the issue, the video starts off with the page rendering the Pen icon fine, and then after a few navigations the button becomes invisible for the rest of the time: https://streamable.com/07uz8k

I've tried setting that as a property in the ViewModel, Static, directly encoding the hex code, but the issue persists.

[ObservableProperty]
    private string iconGlyph = "\u004C";

<FontImageSource FontFamily="FontIcons" Glyph="{Binding IconGlyph}" />

Steps to Reproduce

Add a button with a FontImageSource AppShell with FlyoutItems - not sure if this matters, but its how I can reproduce

Link to public reproduction project repository

No response

Version with bug

8.0.93 SR9.3

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Maui 8.0.93, Android API 34

Did you find any workaround?

Only for ContentPages, if I override OnAppearing and add the Glyph it works. However, I don't have a solution for ContentView, OnParentSet doesn't work.

protected override void OnAppearing()
{
    base.OnAppearing();
    OpenDrawerButton.Icon = new FontImageSource
    {
        FontFamily = "FontIcons",
        Glyph = (string)Application.Current.Resources["Pen"]
    };
}

Workaround 2: I replaced the FontImageSource with just a SVG image from Resources and it works. However, this isn't ideal, so its still possibly a bug.

Relevant log output

mattleibow commented 1 week ago

The link seems to fail and reported as unsafe.

mattleibow commented 1 week ago

Duplicate of https://github.com/dotnet/maui/issues/14587