-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
.Net Maui 7 and 8 Preview Android Performing a full GC + Crash Collection View Back Forward #15860
Comments
I have made a simple repo : https://github.com/lucianparvu/MauiApp16.App starting from animals samples and i receive out of memory too in Android without accesing API just a simple list . It is a critical bug for me , preventing to go live with the application. It is there something i can do ? It is something wrong with what i have done ? Thank's |
Hi @lucianparvu. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version. You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
This simple repo it seems not to crash in .net 8 preview, at least for 10 min of testing, but the real application crash . I will make some changes and come back. Log for Crashing : https://github.com/lucianparvu/Files/blob/main/LogMaui8 I have notice that the memory is increasing .... , i dont know if is normal for this simple app to go in 10 min to 680 MB. |
@jonathanpeppers thoughts? |
I can give in private some sample source code 8 version. |
Can I run the linked sample to see the problem? https://github.com/lucianparvu/MauiApp16.App Or are we now talking about two different issues? |
Hello, This simple repo is in .NET 7 https://github.com/lucianparvu/MauiApp16.App and it crashes if you go back and forword for a few minutes and you will see memory will increase and in the end crash The same simple repo upgraded at .net 8 didnt crash after the same period, but the memory increased from 100 MB to 700 MB in a few minutes of back and forward My real application crashes in .NET 7 and .NET 8 too . I can send a sample in private . |
There are various memory leaks that are solved in .NET 8, so it makes sense the behavior you describe. So, the only issue in .NET 8, is you'd like the sample to use less memory? We can talk about the second app after looking at the first one. |
In .NET 8 in a real app with services, api, etc i get a crash too !!! I dont get a crash in this simple app . Can use as mutch memory it wants, if i dont get a crash :)) Give me please an email where to send the real app sample in .NET 8, where you can see you will get crash . |
The above sample, one issue is how large the images are:
Some of these are 720x480 and placed in a tiny If you are getting a crash, what is the crash? You can use Example: # enable extra Mono logging
adb shell setprop debug.mono.log default,debugger,assembly,mono_log_level=debug,mono_log_mask=all
# clear the log
adb logcat -c
# cause the app to crash
# save the log
adb logcat -d > log.txt And then |
This is the log i saw in VS at that time : https://github.com/lucianparvu/Files/blob/main/LogMaui8 This is homepage from real app : https://github.com/lucianparvu/Files/blob/main/HomePage.xaml This is DetailPage from real app : https://github.com/lucianparvu/Files/blob/main/ProductCategoryDetailPage.xaml I will try to to use adb logcat and come back |
The log from VS will not have the info we need. Can you get |
If i run those commands when i start the app it seems the log is written only at the beginning, i have used them when the application crashed and display: Isnt Responding ... Close app / Wait. --------- beginning of main |
Did you run this one?
There should be
|
Yes, of course. How this should work ? It will write to log all the time ? because if i run those commands at the beginning i cant see there more logs, only initial logs, if i run them when the app crash you have that log. |
Can i send u source code on your email ? jonathan.peppers@gmail.com it is correct ? Thanks |
Does I wonder if you are debugging the app from VS, and it overwrites the value? |
I took the log from Device Log cu copy paste , may this helps https://raw.githubusercontent.com/lucianparvu/Files/main/log.txt |
Is the above log from Visual Studio? It doesn't look like logcat. Some of the messages like this are expected when you enable the extra logging:
|
I tested @lucianparvu's real app (over email). One thing I found are several <svg width="800px" height="800px" Which are resized to 3200x3200 in for I was already planning to make a build warning for this situation, but I will investigate other issues in this app. |
Beyond the In this example, I navigated 5 times (and sprinkled some Still investigating what is going on here. |
Context: dotnet#15860 In a customer's app, they have the setup: <!-- Resources/Styles/Styles.xaml --> <Style TargetType="Grid" x:Key="GridStyleWithColumnDefinitions"> <Setter Property="ColumnDefinitions" Value="18,*"/> </Style> Then a page with: <Grid Style="{StaticResource GridStyleWithColumnDefinitions}" /> Navigating forward & back from this page would show that the entire `Page` would live forever! What is interesting, is simply removing the Grid's `Style` solved the problem?!? I narrowed this down to a unit test: [Fact] public async Task ColumnDefinitionDoesNotLeak() { // Long-lived column, like from a Style in App.Resources var column = new ColumnDefinition(); WeakReference reference; { var grid = new Grid(); grid.ColumnDefinitions.Add(column); reference = new(grid); } await Task.Yield(); GC.Collect(); GC.WaitForPendingFinalizers(); Assert.False(reference.IsAlive, "Grid should not be alive!"); } https://github.com/dotnet/maui/blob/cda3eb3381cfb686567ed05e3eb8e8f26c02d785/src/Controls/src/Core/Layout/Grid.cs#L20 `Grid` subscribes to `DefinitionCollection<T>.ItemSizeChanged`, and in this case the `DefinitionCollection<T>` lived indefinitely in an application-wide `ResourceDictionary`. The simplest solution is to make the `ItemSizeChanged` event use `WeakEventManager` as was done for other events like `Application.RequestedThemeChanged`: https://github.com/dotnet/maui/blob/cda3eb3381cfb686567ed05e3eb8e8f26c02d785/src/Controls/src/Core/Application/Application.cs#L221-L225 Since MAUI owns the property, we can use the simple solution here. This is one issue solved in the customer app, but I will need to retest the app in dotnet#15860 to see if there are further issues.
Context: #15860 In a customer's app, they have the setup: <!-- Resources/Styles/Styles.xaml --> <Style TargetType="Grid" x:Key="GridStyleWithColumnDefinitions"> <Setter Property="ColumnDefinitions" Value="18,*"/> </Style> Then a page with: <Grid Style="{StaticResource GridStyleWithColumnDefinitions}" /> Navigating forward & back from this page would show that the entire `Page` would live forever! What is interesting, is simply removing the Grid's `Style` solved the problem?!? I narrowed this down to a unit test: [Fact] public async Task ColumnDefinitionDoesNotLeak() { // Long-lived column, like from a Style in App.Resources var column = new ColumnDefinition(); WeakReference reference; { var grid = new Grid(); grid.ColumnDefinitions.Add(column); reference = new(grid); } await Task.Yield(); GC.Collect(); GC.WaitForPendingFinalizers(); Assert.False(reference.IsAlive, "Grid should not be alive!"); } https://github.com/dotnet/maui/blob/cda3eb3381cfb686567ed05e3eb8e8f26c02d785/src/Controls/src/Core/Layout/Grid.cs#L20 `Grid` subscribes to `DefinitionCollection<T>.ItemSizeChanged`, and in this case the `DefinitionCollection<T>` lived indefinitely in an application-wide `ResourceDictionary`. The simplest solution is to make the `ItemSizeChanged` event use `WeakEventManager` as was done for other events like `Application.RequestedThemeChanged`: https://github.com/dotnet/maui/blob/cda3eb3381cfb686567ed05e3eb8e8f26c02d785/src/Controls/src/Core/Application/Application.cs#L221-L225 Since MAUI owns the property, we can use the simple solution here. This is one issue solved in the customer app, but I will need to retest the app in #15860 to see if there are further issues.
Description
After using the app for 1- 2 minutes back and forward (Shell) to a collectionView Page with Observable Collection I receive "Performing a full GC" than a i get a crash in .Net Maui 7 and 8 Preview Android in any Physical device : Google Pixel 6, etc Performing a full GC + Crash
I saw some similar issue reports but they are closed as solved and i can't comment.
IOS works without problems.
Steps to Reproduce
Link to public reproduction project repository
https://github.com/lucianparvu/MauiApp16.App
Version with bug
7
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Did you find any workaround?
No
Relevant log output
No response
The text was updated successfully, but these errors were encountered: