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.21k stars 1.74k forks source link

Memory Leaking and buggy Editor #23838

Closed TheFrieber closed 1 month ago

TheFrieber commented 3 months ago

Description

I can't exactly reproduce this since i don't know what exactly is causing this. But im sure it's the Editor, because it's also bugging somehow + because the most ram is used by .NET MAUI UI functions: (Debugged with JetBrains dotMemory, VS2022 only showed the heap i think, whatever it didn't show the unmanaged Memory) image

Steps to Reproduce

Also the Bug with the Editor, when writing much text, it gets invisible: Without any changes but currently in Edit Mode: image

Then Spam a char until it hits the next line: One char behind: image After: image

Write until the end of the Next line(Until it can't anymore, it'll stop there): image

Now exit edit mode(If mleak doesn't occour, repeat above steps again WITHOUT CLEARING THE TEXT, add to it instead): image Look how the Ram usage goes Rocket.

Code:

[....]                    
                    <Frame Margin="5"
                       Padding="10"
                       BorderColor="Transparent"
                       CornerRadius="15"
                       HorizontalOptions="FillAndExpand"
                       BackgroundColor="{Binding IsUser, Converter={StaticResource BoolToColorConverter}}">
                        <StackLayout>
                            <Label IsVisible="{Binding IsEditing, Converter={StaticResource InverseBoolConverter}}">
                                <Label.FormattedText>
                                    <FormattedString>
                                        <Span Text="{Binding Title}"
                                              Style="{Binding IsUser, Converter={StaticResource UserTitleStyleConverter}}"/>

                                        <Span Text="{Binding Text}"
                                              TextColor="Black"/>
                                    </FormattedString>
                                </Label.FormattedText>
                            </Label>
                            <Editor IsVisible="{Binding IsEditing}"
                               Text="{Binding Text, Mode=TwoWay}"
                               Placeholder="Message"
                               TextColor="OrangeRed"
                               BackgroundColor="LightBlue"
                               Margin="0,0,0,5"/>
                        </StackLayout>
                    </Frame>
[....]

Simple Model, arrows pointing to the vars the Editor/Upcoming code uses: image

In the ViewModel:

        private bool _isEditing;

        public bool IsEditing
        {
            get => _isEditing;
            set
            {
                if (_isEditing != value)
                {
                    _isEditing = value;
                    OnPropertyChanged();
                }
            }
        }

        public ICommand ToggleEditCommand => new RelayCommand(ToggleEditMode);

And the Simple Event:

        public async void ToggleEditMode()
        {
            IsEditing = !IsEditing;

            if (IsEditing)
            {
                foreach (var message in Messages)
                {
                    message.IsEditing = true;
                }
            }
            else
            {
                foreach (var message in Messages)
                {
                    message.IsEditing = false;
                }
            }
        }

Link to public reproduction project repository

No response

Version with bug

9.0.0-preview.6.24327.7

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

github-actions[bot] commented 3 months ago

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!

Open similar issues:

Closed similar issues:

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

ninachen03 commented 1 month ago

Could you provide us with a sample project so we can investigate it further? Looking forward to your reply!

TheFrieber commented 1 month ago

Could you provide us with a sample project so we can investigate it further? Looking forward to your reply!

Hello, thank you for the response. Unfortunately, I already implemented a different way of handling edits in the meantime and therefore I am unable to reproduce this issue from that time. If I encounter the issue again in the future, I will provide more information in a new issue.

Closing the issue now, thanks.