Giter Club home page Giter Club logo

Comments (13)

tranb3r avatar tranb3r commented on September 27, 2024 1

I'm also getting this warning from time to time:
The RealParent on Microsoft.Maui.Controls.Shapes.RoundRectangle has been Garbage Collected. This should never happen...

And also:
The RealParent on File: xxxx has been Garbage Collected. This should never happen...

MAUI 8.0.60 SR6

from maui.

github-actions avatar github-actions commented on September 27, 2024

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

from maui.

PureWeen avatar PureWeen commented on September 27, 2024

@snufffgit

Does your app also throw this exception in sr6 8.0.40?

Do you have a repro by chance?

If it's hard to repro can you paste your xaml that uses RoundRectangle

from maui.

snufffgit avatar snufffgit commented on September 27, 2024

from maui.

softlion avatar softlion commented on September 27, 2024

repro can you paste your xaml that uses RoundRectangle

I'm using sr6, and this is reported in Sentry multiple times for multiple UI controls, since I switched to sr6.

I have multiple logs. I'm posting one:

Occurred in non-app: void Logger.<Log>g__LoggerLog|14_0<FormattedLogValues>(?)+LoggerLog(LogLevel, EventId, ILogger, Exception, Func<FormattedLogValues, Exception, string>, ref List<Exception>, in FormattedLogValues)

Hide 12 more frames

void Logger.Log<FormattedLogValues>(LogLevel, EventId, FormattedLogValues, Exception, Func<FormattedLogValues, Exception, string>)

void Logger<Element>.Microsoft.Extensions.Logging.ILogger.Log<FormattedLogValues>(LogLevel, EventId, FormattedLogValues, Exception, Func<FormattedLogValues, Exception, string>)

void LoggerExtensions.Log(ILogger, LogLevel, EventId, Exception, string, params object[]) x 2

void LoggerExtensions.LogWarning(ILogger, string, params object[])

Element Element.get_RealParent()

void Element.SetParent(Element value)

void ImageElement.ImageSourceChanged(BindableObject bindable, ImageSource newSource)

void ImageElement.OnImageSourceChanged(BindableObject bindable, object oldValue, object newValue)

void BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, object value, bool currentlyApplying, SetValueFlags attributes, SetterSpecificity specificity, bool silent)

void BindableObject.SetValueCore(BindableProperty property, object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes, SetterSpecificity specificity)

void BindableObject.SetValue(BindableProperty property, object value)

void Image.set_Source(ImageSource value)

object <InitializeComponent>_anonXamlCDataTemplate_5.LoadDataTemplate()
In App

Assembly:
Wz
Version:
2.0.0.0
Called from: object ElementTemplate.CreateContent()

Show 24 more frames

void StateContainerController.SwitchToState(string state)
In App

void StateContainer.ChangeState(BindableObject bindable, string state)
In App

void StateContainer.OnCurrentStateChanging(BindableObject bindable, object oldValue, object newValue)
In App

Called from: void BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, object value, bool currentlyApplying, SetValueFlags attributes, SetterSpecificity specificity, bool silent)

Show 7 more frames

void BaseViewModel.OnPropertyChanged(PropertyChangedEventArgs eventArgs)
In App

void BaseViewModel.set_CurrentState(LayoutState value)
In App

async Task HomeViewModel.SetSelectedTabIndex(int tabIndex)
In App

Called from: void AsyncMethodBuilderCore.Start<<SetSelectedTabIndex>d__79>(ref <SetSelectedTabIndex>d__79)

Task HomeViewModel.SetSelectedTabIndex(int tabIndex)
In App

void HomeTabsPhoneView.HomePhoneView_OnCurrentPageChanged(object sender, EventArgs e)
In App

Called from: void MultiPage<Page>.OnCurrentPageChanged()

Show 6 more frames

void Program.Main(string[] args)

from maui.

softlion avatar softlion commented on September 27, 2024

image

from maui.

softlion avatar softlion commented on September 27, 2024

Related #23139

from maui.

softlion avatar softlion commented on September 27, 2024

I really don’t remember to see that event on the previous version of Microsoft.Maui.Controls, and I’m aware of the application log.

I confirm that it is only since SR6 that does happen.

from maui.

PureWeen avatar PureWeen commented on September 27, 2024

@snufffgit do you have any code examples you can include here where you are using RoundRectangle?

from maui.

softlion avatar softlion commented on September 27, 2024

@snufffgit do you have any code examples you can include here where you are using RoundRectangle?

I have examples of this issue report in sentry where the UI control involved change everytime.

I would conclude that it is not related to the UI control used.

from maui.

JoeVoo avatar JoeVoo commented on September 27, 2024

Had the same debug massage after update to maui 8.0.61 on Windows, combined with bad ui performance. Back to 8.0.40 - messages gone and performance is normal. Only part where RoundRectangle is used, but lots of borders are loaded in Collectionviews and Flexlayouts:
<Style TargetType="Border" x:Key="BaseBorderStyle"> <Setter Property="Stroke" Value="{DynamicResource StrokeColor}" /> <Setter Property="StrokeShape" Value ="RoundRectangle 5,5,5,5"/>

from maui.

mmiller-d8 avatar mmiller-d8 commented on September 27, 2024

Okay, so my first question is why neither I nor the AI that looks for possible duplicates could find this one in a search. But anyways...

In my case, I'm getting the error for some images as well as for RoundRectangle. In the case of the images, I'm using a derived class that applies a behavior to tint the images. I can't imagine that would cause this, but who knows?

Here is the XAML for the image (one thing I do notice immediately is that the target type for IconStyleBase is Image, not TintedImage):


<Style x:Key="IconStyleBase" TargetType="Image">
    <Setter Property="HeightRequest" Value="20" />
    <Setter Property="WidthRequest" Value="20" />
    <Setter Property="WidthRequest" Value="25" />
    <Setter Property="HeightRequest" Value="25" />
    <Setter Property="Margin" Value="0,0,5,0" />
</Style>

<Style x:Key="VisibleIconStyle" TargetType="controls:TintedImage" BasedOn="{StaticResource IconStyleBase}">
    <Setter Property="Source" Value="icon_visible.png" />
    <Setter Property="TintColor" Value="{AppThemeBinding Dark={StaticResource DarkThemeText}, Light={StaticResource LightThemeText}}" />
</Style>

<HorizontalStackLayout Grid.Row="1" Style="{StaticResource PropertyVisibilityLayoutStyle}">
    <controls:TintedImage Style="{StaticResource VisibleIconStyle}" />
    <Label Text="{x:Static resx:UserSetup.sphereSelection_VisibilityMessage}" />
</HorizontalStackLayout>

Here is the code for the TintImage control:

public class TintedImage : Image 
{

    public static readonly BindableProperty TintColorProperty = BindableProperty.Create(nameof(TintColor), typeof(Color), typeof(TintedImage), null);
    public Color? TintColor 
    {
        get => (Color?)GetValue(TintColorProperty);
        set => SetValue(TintColorProperty, value);
    }

    protected override void OnPropertyChanged([CallerMemberName] string? propertyName = null)
    {
        base.OnPropertyChanged(propertyName);

        if (propertyName == nameof(TintColor))
        {
            var behavior = Behaviors.FirstOrDefault(b => b is IconTintColorBehavior);

            if (TintColor != null) 
            {
                if (behavior == null) 
                {
                    behavior = new IconTintColorBehavior
                    {
                        TintColor = TintColor
                    };

                    this.Behaviors.Add(behavior);
                }
                else 
                    ((IconTintColorBehavior)behavior).TintColor = TintColor;
            }

            if (TintColor == null && behavior != null)
                this.Behaviors.Remove(behavior);
        }
    }

}

Here is one example of the RoundRectangle issue. Both issues seem to be coming from a ContentView. In one of those, the XAML is a control template. In the other it is not. In both cases, the StrokeShape property is bound to a bindable property on the ContentView.

<Border
        x:DataType="local:PropertyCard"
        BindingContext="{x:Reference this}"
        Stroke="{Binding Stroke}"
        StrokeThickness="{Binding StrokeThickness}"
        StrokeShape="{Binding StrokeShape}"
        BackgroundColor="{Binding CardBackgroundColor}"
        Padding="{Binding CardPadding}">

        <Grid 
            x:Name="mainContainer"
            Grid.RowDefinitions="Auto,*">

            <Label 
                Grid.Row="0"
                Text="{Binding HeaderText}"
                FontSize="{Binding HeaderFontSize}"
                TextColor="{Binding HeaderTextColor}" 
                FontFamily="{Binding HeaderFontFamily}"
                Margin="0,0,0,5" />

            <Grid x:Name="itemContainer" Grid.Row="1"></Grid>
        </Grid>
</Border>

Finally, here is the Style that is applying RoundRectangle to the ContentView:

<Style TargetType="controls:PropertyCard">
        <Setter Property="CardBackgroundColor" Value="{AppThemeBinding Dark={StaticResource DarkThemeCardBackground}, Light={StaticResource LightThemeCardBackground}}" />
        <Setter Property="CardPadding" Value="15,15,15,7" />
        <Setter Property="Stroke" Value="{AppThemeBinding Dark={StaticResource DarkThemeCardBorder}, Light={StaticResource LightThemeCardBorder}}" />
        **<Setter Property="StrokeShape" Value="RoundRectangle 12" />**
        <Setter Property="StrokeThickness" Value="1" />
        <Setter Property="HeaderFontSize" Value="{x:Static root:FontSizes.LargeText}" />
        <Setter Property="HeaderFontFamily" Value="{x:Static root:FontNames.DefaultBold}" />
        <Setter Property="HeaderTextColor" Value="{AppThemeBinding Light={StaticResource LightThemeHeaderText}, Dark={StaticResource DarkThemeHeaderText}}" />
        <Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource LightThemeCardText}, Dark={StaticResource DarkThemeCardText}}" />
        <Setter Property="TextFontSize" Value="{x:Static root:FontSizes.DefaultText}" />
        <Setter Property="SubtextColor" Value="{AppThemeBinding Light={StaticResource LightThemeCardText}, Dark={StaticResource DarkThemeCardText}}" />
        <Setter Property="SubtextFontSize" Value="{x:Static root:FontSizes.TinyText}" />
        <Setter Property="PromptTextColor" Value='{AppThemeBinding Light={StaticResource LightThemeAccent}, Dark={StaticResource DarkThemeAccent}}' />
        <Setter Property="NavigationArrow" Value="arrow_forward.png" />
        <Setter Property="LockIcon" Value="icon_padlock.png" />
        <Setter Property="ColumnSpacing" Value="10" />
</Style>

As an aside, I was looking through the Sentry logs and there are some images where it happens pretty much every time that page loads. There is another case where I have a custom control that is on virtually every setup and settings page in my app - and there are a lot - and it only happened once for that control and it has happened a couple dozen times for the other images it's affecting.

Also, I should point out that I'm currently in development, so I'm the only user. That's why the numbers are so low.

from maui.

softlion avatar softlion commented on September 27, 2024

Ah that explains my issues with custom image sources that i am using as they are applied through a behavior too.

This bug is being cornered.

from maui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.