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

Microsoft.Maui.Controls.Shapes.RoundRectangle has been Garbage Collected #25716

Open
brotherMobileDev opened this issue Nov 6, 2024 · 4 comments
Labels
s/needs-attention Issue has more information and needs another look t/bug Something isn't working

Comments

@brotherMobileDev
Copy link

Description

Description

The RealParent on Microsoft.Maui.Controls.Shapes.RoundRectangle has been Garbage Collected

Environment

Hardware

Macbook Air M2 2023
Memory 16GB
OS: Sonoma 14.7.1

Software

Visual Studio Community 2022 for Mac
Version 17.6.14 (build 413)
Installation UUID: 34b0d8e4-203f-4d47-898c-ac740627ec5dj

iPhone 7
iOS 15.8.1

Runtime
.NET 7.0.3 (64-bit)
Architecture: Arm64
Microsoft.macOS.Sdk 13.1.1007; git-rev-head:8afca776a0a96613dfb7200e0917bb57f9ed5583; git-branch:release/7.0.1xx-xcode14.2

Roslyn (Language Service)
4.6.0-3.23180.6+99e956e42697a6dd886d1e12478ea2b27cceacfa

NuGet
Version: 6.4.0.117

.NET SDK (Arm64)
SDK: /usr/local/share/dotnet/sdk/8.0.301/Sdks
SDK Versions:
8.0.301
8.0.100-rc.2.23502.2
7.0.317
7.0.316
7.0.315
7.0.314
7.0.313
7.0.312
7.0.311
7.0.310
7.0.309
7.0.308
6.0.425
6.0.424
6.0.422
6.0.421
6.0.420
6.0.419
6.0.418
6.0.417
6.0.416
6.0.415
6.0.414
MSBuild SDKs: /Applications/Visual Studio.app/Contents/MonoBundle/MSBuild/Current/bin/Sdks

.NET Runtime (Arm64)
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
8.0.6
8.0.0-rc.2.23479.6
7.0.20
7.0.19
7.0.18
7.0.17
7.0.16
7.0.15
7.0.14
7.0.13
7.0.12
7.0.11
6.0.33
6.0.32
6.0.30
6.0.29
6.0.28
6.0.27
6.0.26
6.0.25
6.0.24
6.0.23
6.0.22

Xamarin.Profiler
Version: 1.8.0.49
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

Updater
Version: 11

Apple Developer Tools
Xcode: 15.4 22622
Build: 15F31d

Xamarin.Mac
Not Installed

Xamarin.iOS
Version: 16.4.0.23 Visual Studio Community
Hash: 9defd91b3
Branch: xcode14.3
Build date: 2023-10-23 16:15:00-0400

Xamarin Designer
Version: 17.6.3.9
Hash: 2648399ae8
Branch: remotes/origin/d17-6
Build date: 2024-08-07 17:47:20 UTC

Xamarin.Android
Version: 13.2.2.0 (Visual Studio Community)
Commit: xamarin-android/d17-5/45b0e14
Android SDK: /Users/jack/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
8.0 (API level 26)
12.0 (API level 31)
10.0 (API level 29)
13.0 (API level 33)

SDK Command-line Tools Version: 7.0
SDK Platform Tools Version: 35.0.1
SDK Build Tools Version: 34.0.0

Build Information:
Mono: d9a6e87
Java.Interop: xamarin/java.interop/d17-5@149d70fe
SQLite: xamarin/sqlite@68c69d8
Xamarin.Android Tools: xamarin/xamarin-android-tools/d17-5@ca1552d

Microsoft Build of OpenJDK
Java SDK: /Library/Java/JavaVirtualMachines/microsoft-11.jdk
11.0.16.1
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Eclipse Temurin JDK
Java SDK: /Library/Java/JavaVirtualMachines/temurin-8.jdk
1.8.0.302
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Android SDK Manager
Version: 17.6.0.50
Hash: a715dca
Branch: HEAD
Build date: 2024-08-07 17:47:27 UTC

Android Device Manager
Version: 0.0.0.1309
Hash: 06e3e77
Branch: HEAD
Build date: 2024-08-07 17:47:27 UTC

Build Information
Release ID: 1706140413
Git revision: 29d5da805da9895dd02785823633e3bcfabdd769
Build date: 2024-08-07 17:45:52+00
Build branch: release-17.6
Build lane: release-17.6

Operating System
Mac OS X 14.7.1
Darwin 23.6.0 Darwin Kernel Version 23.6.0
Thu Sep 12 23:36:55 PDT 2024
root:xnu-10063.141.1.701.1~1/RELEASE_ARM64_T8112 arm64

Steps to Reproduce

Note: This issue didn't occur on Android.

Reproduction

First and foremost, I am unable to reliably reproduce the error. The garbage collector is an elusive beast.

  1. Using a Shell
  2. Select Middle tab at bottom of screen
  3. Press button
<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="2*"/>
    </Grid.ColumnDefinitions>
    <Grid.GestureRecognizers>
        <TapGestureRecognizer Command="{Binding GoToSampleLabels}"/> <!--  Here is the tap -->
    </Grid.GestureRecognizers>
    <Label Text="Sample Labels" TextColor="{StaticResource Text}"
         FontSize="Medium" Grid.Column="0" Grid.Row="0" VerticalTextAlignment="Center" />
    <Frame Grid.Column="1" Grid.Row="0" Grid.RowSpan="2" WidthRequest="50" HeightRequest="50" HorizontalOptions="End" VerticalOptions="Center" >
        <Image Source="right_arrow_blue.png" Scale="2"/>
    </Frame>
</Grid>
  1. Select Item on screen
<CollectionView.ItemTemplate>
     <DataTemplate x:DataType="{x:Type x:String}">
            <Image Source="{Binding .}" 
                        HorizontalOptions="Center"
                        VerticalOptions="Center"
                        Aspect="AspectFit">
                <Image.GestureRecognizers>
                    <TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped"/> <!--  Here is the tap -->
                </Image.GestureRecognizers>
            </Image>
     </DataTemplate>
</CollectionView.ItemTemplate>

Here is where the bug is reported in the console

Xaml from Step 3

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="UtilitiesApp.View.ChooseLocation"
             xmlns:viewModel="clr-namespace:UtilitiesApp.ViewModel"
             x:DataType="viewModel:ChooseLocationViewModel"
             FlowDirection="LeftToRight"
             BackgroundColor="{StaticResource Background}"
             Title="Choose File">
    <VerticalStackLayout Padding="16" VerticalOptions="Center" Spacing="60" TranslationY="-60">
        <Label 
            Text="Please select where the file you would like to print is located."
            TextColor="{StaticResource Text}"
            LineBreakMode="WordWrap"
            HorizontalTextAlignment="Center"
            VerticalOptions="Start"
            HorizontalOptions="Center"
            FontSize="Medium"/>
       
        <VerticalStackLayout VerticalOptions="Center">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="2*"/>
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid.GestureRecognizers>
                    <TapGestureRecognizer Command="{Binding GoToRecentLabels}"/>
                </Grid.GestureRecognizers>
                    <Label Text="Recent Labels" TextColor="{StaticResource Text}"
                            FontSize="Medium" Grid.Column="0" Grid.Row="0" VerticalTextAlignment="Center" />
                    <Frame Grid.Column="1" Grid.Row="0" Grid.RowSpan="2" WidthRequest="50" HeightRequest="50" HorizontalOptions="End" VerticalOptions="Center" >
                        <Image Source="right_arrow_blue.png" Scale="2"/>
                    </Frame>
            </Grid>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="2*"/>
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid.GestureRecognizers>
                    <TapGestureRecognizer Command="{Binding GoToSampleLabels}"/>
                </Grid.GestureRecognizers>
                    <Label Text="Sample Labels" TextColor="{StaticResource Text}"
                            FontSize="Medium" Grid.Column="0" Grid.Row="0" VerticalTextAlignment="Center" />
                    <Frame Grid.Column="1" Grid.Row="0" Grid.RowSpan="2" WidthRequest="50" HeightRequest="50" HorizontalOptions="End" VerticalOptions="Center" >
                        <Image Source="right_arrow_blue.png" Scale="2"/>
                    </Frame>
            </Grid>

            <BoxView HeightRequest="2" Color="{StaticResource Primary}" Grid.Row="3" Grid.ColumnSpan="2"  />

            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="2*"/>
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid.GestureRecognizers>
                    <TapGestureRecognizer Command="{Binding GoToLocalFiles}"/>
                </Grid.GestureRecognizers>
                    <Label Text="Files From Your Device" TextColor="{StaticResource Text}"
                            FontSize="Medium" Grid.Column="0" Grid.Row="0" VerticalTextAlignment="Center" />
                    <Frame Grid.Column="1" Grid.Row="0" Grid.RowSpan="2" WidthRequest="50" HeightRequest="50" HorizontalOptions="End" VerticalOptions="Center" >
                        <Image Source="right_arrow_blue.png" Scale="2"/>
                    </Frame>
            </Grid>

            <!--<Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="2*"/>
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid.GestureRecognizers>
                    <TapGestureRecognizer Command="{Binding GoToWeb}"/>
                </Grid.GestureRecognizers>
                    <Label Text="Files From The Web" TextColor="{StaticResource Text}"
                            FontSize="Medium" Grid.Column="0" Grid.Row="0" VerticalTextAlignment="Center" />
                    <Frame Grid.Column="1" Grid.Row="0" Grid.RowSpan="2" WidthRequest="50" HeightRequest="50" HorizontalOptions="End" VerticalOptions="Center" >
                        <Image Source="right_arrow_blue.png" Scale="2"/>
                    </Frame>
            </Grid>-->
        </VerticalStackLayout>
    </VerticalStackLayout>
</ContentPage>

Xaml from Setup 4

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="UtilitiesApp.View.SampleLabels"
             xmlns:viewmodel="clr-namespace:UtilitiesApp.ViewModel"
             x:DataType="viewmodel:SampleLabelsViewModel"
             BackgroundColor="{StaticResource Background}"
             Title="Sample Labels">
    <ScrollView Padding="4">
        <CollectionView x:Name="CV_Images" ItemsSource="{Binding Images}">
            <CollectionView.ItemsLayout>
                <LinearItemsLayout
                    Orientation="Vertical"
                    ItemSpacing="8"/>
            </CollectionView.ItemsLayout>
            <CollectionView.ItemTemplate>
                <DataTemplate x:DataType="{x:Type x:String}">
                        <Image Source="{Binding .}" 
                                    HorizontalOptions="Center"
                                    VerticalOptions="Center"
                                    Aspect="AspectFit">
                            <Image.GestureRecognizers>
                                <TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped"/>
                            </Image.GestureRecognizers>
                        </Image>
                </DataTemplate>
            </CollectionView.ItemTemplate>

        </CollectionView>
    </ScrollView>
</ContentPage>

Xaml for the view being loaded from Step 4 TapGestureRecognizer

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="UtilitiesApp.Templates.RJ42_4x3"
             xmlns:zxing="clr-namespace:ZXing.Net.Maui.Controls;assembly=ZXing.Net.MAUI.Controls"
             Title="RJ42 4x3"
             BackgroundColor="{StaticResource Background}">
    <ScrollView>
        <VerticalStackLayout
            Spacing="25"
            Padding="16,32,16,0"
            VerticalOptions="Start">
            <Label Text="Tap the fields in the label below or the file name to edit each."
                   HorizontalTextAlignment="Center"
                   Margin="0,0,0,50"
                   FontSize="Title"
                   VerticalOptions="Start"/>
            <VerticalStackLayout VerticalOptions="Center">
            <Frame x:Name="CaptureArea"
                   BackgroundColor="White" BorderColor="Black"
                   HorizontalOptions="FillAndExpand" VerticalOptions="Center"
                   Padding="4"
                   HeightRequest="262.5"
                   WidthRequest="350">

                <Grid Padding="0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="3*"/>
                        <RowDefinition Height="3*"/>
                    </Grid.RowDefinitions>
               
                
                    <Label Text="Customer Name:"
                           Grid.Row="0" Grid.RowSpan="2" Grid.Column="0" Grid.ColumnSpan="2"
                           FontSize="14" FontAttributes="Bold"
                           TextColor="Black"
                           VerticalOptions="Center" />
                    <Entry x:Name="CustomerName" Text="John Smith"
                           Grid.Row="0" Grid.RowSpan="2" Grid.Column="3" Grid.ColumnSpan="4"
                           FontSize="30" FontAttributes="Bold"
                           TextColor="Black"
                           Margin="-10"
                           Completed="Entry_Completed"
                           />

                    <Label Text="Promised Date and Time:"
                           Grid.Row="2" Grid.RowSpan="2" Grid.Column="0" Grid.ColumnSpan="4"
                           FontSize="14" FontAttributes="Bold"
                           TextColor="Black" VerticalTextAlignment="Center"
                           VerticalOptions="Center" />
                    <Frame Grid.Row="2" Grid.RowSpan="2" Grid.Column="3" Grid.ColumnSpan="3"
                           CornerRadius="0" Padding="0"
                           VerticalOptions="Center">
                        <Entry x:Name="TopRightTopLabel" Text="4/17/24 7:30PM"
                               FontSize="22" FontAttributes="Bold"
                               TextColor="Black" VerticalTextAlignment="Center"
                               Margin="-10"
                               Completed="Entry_Completed"
                               /> 
                    </Frame>
                    <Frame Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" BorderColor="Black" CornerRadius="0" Padding="0">
                        <VerticalStackLayout Padding="0" Spacing="0">
                            <Entry x:Name="LeftSquareTop" Text="LOC"
                                   FontAttributes="Bold" TextColor="Black"
                                   FontSize="20"
                                   HorizontalTextAlignment="Center" VerticalTextAlignment="Center"
                                   Margin="0,-10,0,-15"
                                   Completed="Entry_Completed"
                                   />
                            <Entry x:Name="LeftSquareMiddle" Text="A1"
                                   FontAttributes="Bold" TextColor="Black"
                                   FontSize="20" 
                                   HorizontalTextAlignment="Center" VerticalTextAlignment="Center"
                                   Margin="0,-10,0,-15"
                                   Completed="Entry_Completed"
                                   />
                            <Entry x:Name="LeftSquareBottom" Text="1 of 1"
                                   FontAttributes="Bold" TextColor="Black"
                                   FontSize="20" 
                                   HorizontalTextAlignment="Center" VerticalTextAlignment="Center"
                                   Margin="-10"
                                   Completed="Entry_Completed"
                                   />
                        </VerticalStackLayout>
                    </Frame>
                    <Frame Grid.Row="4" Grid.Column="2" Grid.ColumnSpan="4" BorderColor="Black" CornerRadius="0" Padding="0">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <Label x:Name="RightSquareOrder" Text="ORDER:"
                                   Grid.Row="0" Grid.Column="0"
                                   FontSize="20" FontAttributes="Bold" TextColor="Black"
                                   HorizontalTextAlignment="Center" VerticalTextAlignment="Center"
                                   />
                            <Label x:Name="RightSquarePickedBy" Text="Picked By:"
                                   Grid.Row="1" Grid.Column="0"
                                   FontSize="20" FontAttributes="Bold" TextColor="Black"
                                   HorizontalTextAlignment="Center" VerticalTextAlignment="Center"
                                   />
                            <Frame BorderColor="Transparent" CornerRadius="0"
                                   Grid.Row="0" Grid.Column="1"
                                   Padding="0" VerticalOptions="Center"
                                   Unfocused="RightSquareOrderNumber_Unfocused"
                                   >
                                <Entry x:Name="BarcodeEntry" Text="1378197"                               
                                       FontSize="20" FontAttributes="Bold" TextColor="Black"
                                       HorizontalTextAlignment="Center"
                                       Margin="-10"
                                       Completed="Entry_Completed"
                                       />
                            </Frame>
                            <Frame BorderColor="Transparent" CornerRadius="0" 
                                   Grid.Row="1" Grid.Column="1"
                                   Padding="0" VerticalOptions="Center"
                                   >
                                <Entry x:Name="RightSquarePickedByName" Text="MATTM"   
                                       FontSize="20" FontAttributes="Bold" TextColor="Black"
                                       HorizontalTextAlignment="Center"
                                       Margin="-10"
                                       Completed="Entry_Completed"
                                       />
                            </Frame>
                        </Grid>
                    </Frame>
                    <zxing:BarcodeGeneratorView x:Name="ZXingBarcode"
                                                Format="QrCode"
                                                Value="1378197"
                                                Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="2"   
                                                />
                    <Image x:Name="BrotherImage" Source="brothertemplateimage.png"
                           Grid.Row="5" Grid.Column="4" Grid.ColumnSpan="2"
                           /> 
                </Grid>
            </Frame>
            <VerticalStackLayout Spacing="20" HorizontalOptions="Center">
                <Border Stroke="Transparent">
                    <HorizontalStackLayout Spacing="20">
                        <Label Text="Label Size:" FontSize="Large" VerticalTextAlignment="Center" VerticalOptions="Center"/>
                        <Label Text="4 x 2 inches" VerticalTextAlignment="Center" FontSize="Medium"/>
                    </HorizontalStackLayout>
                </Border>
                <Border Stroke="Transparent">
                    <HorizontalStackLayout Spacing="20">
                        <Label Text="Filename:" FontSize="Large" VerticalOptions="Center" VerticalTextAlignment="Center"/>
                        <Entry x:Name="FileNameEntry" Text="SavedLabel_HH:MM:SS.png" Placeholder="Filename goes here" VerticalTextAlignment="Center"
                               Completed="Entry_Completed"/>
                    </HorizontalStackLayout>
                </Border>
            </VerticalStackLayout>

            <Button x:Name="SaveButton" Text="Save" Clicked="SaveButton_Clicked" Padding="16" FontSize="Large" FontAttributes="Bold" />
            </VerticalStackLayout>
        </VerticalStackLayout>
    </ScrollView>
</ContentPage>

``

### Link to public reproduction project repository

_No response_

### Version with bug

8.0.40 SR5

### Is this a regression from previous behavior?

Not sure, did not test other versions

### Last version that worked well

Unknown/Other

### Affected platforms

iOS

### Affected platform versions

iOS 15.8.1

### Did you find any workaround?

_No response_

### Relevant log output

_No response_
@brotherMobileDev brotherMobileDev added the t/bug Something isn't working label Nov 6, 2024
@mattleibow
Copy link
Member

Are you able to repro in a new template app? Do you have a repro sample that we can download? This is quite a lot of files to do and we might still miss what you are doing.

@mattleibow mattleibow added the s/needs-info Issue needs more info from the author label Nov 12, 2024
@mattleibow
Copy link
Member

@PureWeen this is probable related to the collection work we added, but does this issue look familiar.

@brotherMobileDev
Copy link
Author

Hey @mattleibow.

Thanks for your response.

Unfortunately, I am unable to provide a public repo. However, there is a chance that I could zip up my project and attach it here. Would that be acceptable? I'll wait for a response on that before I ask about that.

I will try to create a new project that I will try to reproduce the issue.
I've found this particular issue difficult to reproduce reliably.
Sometimes it happens, and most times it doesn't.

I was able to get the issue to show up just now, but have been unable to get it to show up again. I'll keep trying as the week goes on.

The thing that confuses me, is that in the samples I provided above, and past cases, I have been using Frame. The error message mentions RoundRectangle.
I wasn't using RoundRectangle in those cases.
With a recent migration from Frame to Border in anticipation of the deprecation of Frame with .NET 9, I am now using RoundRectangle. But in the case I provided above, I was not. So I'm also a little confused how that could have shown up in a page in which I wasn't using the RoundRectangle property.

@dotnet-policy-service dotnet-policy-service bot added s/needs-attention Issue has more information and needs another look and removed s/needs-info Issue needs more info from the author labels Nov 13, 2024
@Zhanglirong-Winnie
Copy link

Hi, @brotherMobileDev
Maybe we need you to zip the project and attach it here, We can better repro your problem and look forward to your reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s/needs-attention Issue has more information and needs another look t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants