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

.Net Maui 7 and 8 Preview Android Performing a full GC + Crash Collection View Back Forward #15860

Closed
lucianparvu opened this issue Jun 26, 2023 · 21 comments · Fixed by #16145
Closed
Assignees
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView fixed-in-8.0.0-preview.7.8842 Look for this fix in 8.0.0-preview.7.8842! memory-leak 💦 Memory usage grows / objects live forever platform/android 🤖 t/bug Something isn't working

Comments

@lucianparvu
Copy link

lucianparvu commented Jun 26, 2023

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

@lucianparvu lucianparvu added the t/bug Something isn't working label Jun 26, 2023
@Eilon Eilon added the area-controls-collectionview CollectionView, CarouselView, IndicatorView label Jun 26, 2023
@jsuarezruiz jsuarezruiz added platform/android 🤖 legacy-area-perf Startup / Runtime performance labels Jun 27, 2023
@lucianparvu
Copy link
Author

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

@PureWeen PureWeen added the s/try-latest-version Please try to reproduce the potential issue on the latest public version label Jun 27, 2023
@ghost
Copy link

ghost commented Jun 27, 2023

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.

@lucianparvu
Copy link
Author

lucianparvu commented Jun 28, 2023

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.
....

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.

MicrosoftTeams-image (35)

MicrosoftTeams-image (32)

@ghost ghost removed the s/try-latest-version Please try to reproduce the potential issue on the latest public version label Jun 28, 2023
@PureWeen
Copy link
Member

PureWeen commented Jul 6, 2023

@jonathanpeppers thoughts?

@lucianparvu
Copy link
Author

@jonathanpeppers thoughts?

I can give in private some sample source code 8 version.

@jonathanpeppers
Copy link
Member

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?

@lucianparvu
Copy link
Author

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 .

@jonathanpeppers
Copy link
Member

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.

@lucianparvu
Copy link
Author

lucianparvu commented Jul 7, 2023

So, the only issue in .NET 8, is you'd like the sample to use less memory?

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 .

@jonathanpeppers
Copy link
Member

The above sample, one issue is how large the images are:

Some of these are 720x480 and placed in a tiny CollectionView row. Can you use thumbnail images instead for this? Something that is sized the same (or close) as the row's size, for example.

If you are getting a crash, what is the crash? You can use adb logcat to save a log.

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 log.txt should contain information as to what happened, can you share it here? Thanks.

@lucianparvu
Copy link
Author

lucianparvu commented Jul 7, 2023

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

@jonathanpeppers
Copy link
Member

The log from VS will not have the info we need. Can you get adb logcat output?

@lucianparvu
Copy link
Author

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
07-07 18:51:34.325 17079 17079 D Mono : GC_TAR_BRIDGE bridges 29134 objects 44615 opaque 687 colors 29134 colors-bridged 29134 colors-visible 29134 xref 8688 cache-hit 0 cache-semihit 0 cache-miss 0 setup 1.25ms tarjan 11.47ms scc-setup 2.67ms gather-xref 0.38ms xref-setup 0.14ms cleanup 4.21ms
07-07 18:51:34.325 17079 17079 D Mono : GC_BRIDGE: Complete, was running for 543.67ms
07-07 18:51:34.325 17079 17079 D Mono : GC_MAJOR: (user request) time 135.70ms, stw 138.89ms los size: 10984K in use: 3434K
07-07 18:51:34.325 17079 17079 D Mono : GC_MAJOR_SWEEP: major size: 116192K in use: 110272K
07-07 18:51:34.325 17079 17079 I Choreographer: Skipped 3582 frames! The application may be doing too much work on its main thread.
07-07 18:51:34.327 17079 17079 I monodroid-gc: 46203 outstanding GREFs. Performing a full GC!
07-07 18:51:34.338 1046 1123 I VSyncReactor: Current= 60, Period= 60, hwcPeriod= 60
--------- beginning of system
07-07 18:51:34.539 677 677 D io_stats: !@ 8,0 r 4790966 122177588 w 1751249 13042140 d 424051 9958932 f 0 0 iot 2179032 0 th 0 0 0 pt 0 inp 0 0 23577.693
07-07 18:51:34.539 677 677 D io_stats: !@ Read_top(KB): sait.sohservice(25895) 24
07-07 18:51:34.539 677 677 D io_stats: !@ Write_top(KB): kworker/u16:0(31677) 1548 sait.sohservice(25895) 4
07-07 18:51:34.545 1400 1865 D SemWifiSwitchForIndividualAppsService: isSkipNetworkCondition - result:2
07-07 18:51:34.611 17079 17079 I .defaultmauiapp: Explicit concurrent copying GC freed 22(31KB) AllocSpace objects, 0(0B) LOS objects, 38% free, 38MB/62MB, paused 22us,23us total 119.267ms
07-07 18:51:35.004 17079 17079 D Mono : GC_TAR_BRIDGE bridges 29138 objects 44621 opaque 688 colors 29138 colors-bridged 29138 colors-visible 29138 xref 8688 cache-hit 0 cache-semihit 0 cache-miss 0 setup 1.29ms tarjan 12.26ms scc-setup 2.64ms gather-xref 0.39ms xref-setup 0.14ms cleanup 4.14ms
07-07 18:51:35.004 17079 17079 D Mono : GC_BRIDGE: Complete, was running for 536.85ms
07-07 18:51:35.004 17079 17079 D Mono : GC_MAJOR: (user request) time 137.67ms, stw 140.66ms los size: 10984K in use: 3434K
07-07 18:51:35.004 17079 17079 D Mono : GC_MAJOR_SWEEP: major size: 116192K in use: 110340K
07-07 18:51:35.005 17079 17079 I monodroid-gc: 46204 outstanding GREFs. Performing a full GC!
07-07 18:51:35.285 17079 17079 I .defaultmauiapp: Explicit concurrent copying GC freed 4(32KB) AllocSpace objects, 0(0B) LOS objects, 38% free, 38MB/62MB, paused 23us,21us total 117.810ms
07-07 18:51:35.552 1400 1865 D SemWifiSwitchForIndividualAppsService: isSkipNetworkCondition - result:2
07-07 18:51:35.679 17079 17079 D Mono : GC_TAR_BRIDGE bridges 29139 objects 44622 opaque 688 colors 29139 colors-bridged 29139 colors-visible 29139 xref 8688 cache-hit 0 cache-semihit 0 cache-miss 0 setup 1.22ms tarjan 11.43ms scc-setup 2.62ms gather-xref 0.38ms xref-setup 0.15ms cleanup 4.07ms
07-07 18:51:35.679 17079 17079 D Mono : GC_BRIDGE: Complete, was running for 535.69ms
07-07 18:51:35.679 17079 17079 D Mono : GC_MAJOR: (user request) time 135.31ms, stw 138.30ms los size: 10984K in use: 3434K
07-07 18:51:35.679 17079 17079 D Mono : GC_MAJOR_SWEEP: major size: 116192K in use: 110135K
07-07 18:51:35.680 17079 17079 I monodroid-gc: 46204 outstanding GREFs. Performing a full GC!
07-07 18:51:35.963 17079 17079 I .defaultmauiapp: Explicit concurrent copying GC freed 4(32KB) AllocSpace objects, 0(0B) LOS objects, 38% free, 38MB/62MB, paused 22us,23us total 119.654ms
07-07 18:51:36.135 1400 4779 D SemWifiUsabilityStatsMonitor: onWifiUsabilityStats - seqNum 4668, isSameBssidAndFreq true
07-07 18:51:36.136 1400 1851 I SemWifiLinkQualityMonitor: Link Qos Query: 0.022 ms / 360.030 Mbps (526 / 0.007 / 1.000)
07-07 18:51:36.136 1953 1953 D NetworkController.WifiSignalController: notifyListener: visible=true, connected=true, inetCondition=1, isDefault=true, wifiTestReported=true, receivedInetCondition=-1, hideDuringMobileSwitching=false
07-07 18:51:36.155 1046 1123 I VSyncReactor: Current= 60, Period= 60, hwcPeriod= 60
07-07 18:51:36.356 17079 17079 D Mono : GC_TAR_BRIDGE bridges 29139 objects 44622 opaque 688 colors 29139 colors-bridged 29139 colors-visible 29139 xref 8688 cache-hit 0 cache-semihit 0 cache-miss 0 setup 1.23ms tarjan 11.75ms scc-setup 2.62ms gather-xref 0.38ms xref-setup 0.15ms cleanup 4.17ms
07-07 18:51:36.356 17079 17079 D Mono : GC_BRIDGE: Complete, was running for 536.58ms
07-07 18:51:36.356 17079 17079 D Mono : GC_MAJOR: (user request) time 136.59ms, stw 139.59ms los size: 10984K in use: 3434K
07-07 18:51:36.356 17079 17079 D Mono : GC_MAJOR_SWEEP: major size: 116192K in use: 108890K
07-07 18:51:36.357 17079 17079 I monodroid-gc: 46204 outstanding GREFs. Performing a full GC!
07-07 18:51:36.521 1400 18934 D TrafficStats: tagSocket(1118) with statsTag=0xffffffff, statsUid=-1
07-07 18:51:36.522 1400 18934 D TrafficStats: tagSocket(1125) with statsTag=0xffffffff, statsUid=-1
07-07 18:51:36.539 677 677 D io_stats: !@ 8,0 r 4790966 122177588 w 1751252 13042180 d 424051 9958932 f 0 0 iot 2179036 0 th 0 0 0 pt 0 inp 0 0 23579.694
07-07 18:51:36.562 1400 1865 D SemWifiSwitchForIndividualAppsService: isSkipNetworkCondition - result:2
07-07 18:51:36.655 17079 17079 I .defaultmauiapp: Explicit concurrent copying GC freed 4(32KB) AllocSpace objects, 0(0B) LOS objects, 38% free, 38MB/62MB, paused 24us,20us total 118.942ms
07-07 18:51:36.724 1400 18934 D WifiConnectivityMonitor.DnsThread: [|203] []
07-07 18:51:36.724 1400 1869 D WifiConnectivityMonitor.NetworkStatsAnalyzer: DNS resultType : 0, responseTime : 203
07-07 18:51:36.725 1400 1867 D OpenNetworkQos[4.00]: updateBssidLatestDnsResultType - result: 0
07-07 18:51:36.725 1400 1867 D OpenNetworkQos[4.00]: updateBssidNoInternet: mBssidNoInternet = false
07-07 18:51:36.725 1400 1867 D OpenNetworkQos[4.00]: getOpenNetworkQosNoInternetStatus: false
07-07 18:51:36.725 1400 1867 D OpenNetworkQos[4.00]: getOpenNetworkQosScores: 0 26 23
07-07 18:51:36.725 1400 1867 D SettingsProvider: isChangeAllowed() : name = wifi_wcm_qos_sharing_score_summary
07-07 18:51:36.725 1400 1867 I WifiProfileShare: network QoS data was changed (internet), updateQoSData networkType: true, qosData: false
07-07 18:51:36.725 1400 3062 V WifiProfileShare.Caster: update wips network, size: 0
07-07 18:51:36.725 1400 3062 D WifiProfileShare: nearby scanning settings run
07-07 18:51:36.726 1400 3062 D WifiProfileShare: network score provider settings enabled
07-07 18:51:36.726 1400 3062 D OpenNetworkQos[4.00]: getOpenNetworkQosScores: 0 26 23
07-07 18:51:36.726 1400 3062 D OpenNetworkQos[4.00]: getOpenNetworkQosNoInternetStatus: false
07-07 18:51:36.726 1400 3062 I WifiProfileShare.Caster: current network type: 0, score: [0, 26, 23]
07-07 18:51:36.726 1400 3062 V WifiProfileShare.Cache: update network score a8:b4:56:::80
07-07 18:51:36.726 1400 3062 D WifiProfileShare.ScanMatcher: getMcfDataList size:1
07-07 18:51:36.726 1400 3062 I WifiProfileShare.Caster: qos data was updated , before:type:QOS, pBssid:ab:ce:28, qosData:17 after:type:QOS, pBssid:ab:ce:28, qosData:17
07-07 18:51:36.727 1400 3062 I [MCFSDK_android_1.2.4010]_4_b: isNetworkEnabled - type : 1 ret : true
07-07 18:51:36.727 1400 3062 D WifiProfileShare.McfCast: -ME--- mIsNetworkEnabled :true
07-07 18:51:36.727 1400 3062 D WifiProfileShare.McfCast: updateQoSData ignored, same contents
07-07 18:51:36.727 1400 3062 D WifiProfileShare.MCF: success update QosData !
07-07 18:51:36.727 1400 3062 I [MCFSDK_android_1.2.4010]_4_b: isNetworkEnabled - type : 1 ret : true
07-07 18:51:36.727 1400 3062 D WifiProfileShare.McfCast: -ME--- mIsNetworkEnabled :true
07-07 18:51:36.727 1400 3062 D WifiProfileShare.McfCast: -ME--- updatePasswordDate pwdData size:1
07-07 18:51:36.763 1400 3002 D FreecessController: com.facebook.orca(state: Freezeable -> Frozen, Reason: Binder(1)-free_buffer_full)
07-07 18:51:36.764 1400 3002 D FreecessController: FZ : com.facebook.orca(29831)
07-07 18:51:36.765 1400 3002 D FreecessController: FZ : com.facebook.orca(0), reason: Bg
07-07 18:51:36.770 1400 3002 I PowerManagerService: [PWL] SetWakeLockEnableDisable uid = 10465 , disable= true
07-07 18:51:36.770 1400 3002 I PowerManagerService: [PWL] can not change uid = 10465
07-07 18:51:36.770 1400 3002 W LocationManagerService: onFreezeStateChanged, uid[10465]=true
07-07 18:51:36.948 1953 1953 D SecPowerUI.Notification: showChargingNotice oldChargingType : 11 / currentChargingType : 11, oldChargingTime : 28917000 / mChargingTime : 28917000
07-07 18:51:36.948 1953 1953 D SecPowerUI.Notification: There is no change about charging status, so return!
07-07 18:51:37.050 17079 17079 D Mono : GC_TAR_BRIDGE bridges 29139 objects 44622 opaque 688 colors 29139 colors-bridged 29139 colors-visible 29139 xref 8688 cache-hit 0 cache-semihit 0 cache-miss 0 setup 1.42ms tarjan 13.92ms scc-setup 2.61ms gather-xref 0.37ms xref-setup 0.14ms cleanup 4.52ms
07-07 18:51:37.050 17079 17079 D Mono : GC_BRIDGE: Complete, was running for 540.62ms
07-07 18:51:37.050 17079 17079 D Mono : GC_MAJOR: (user request) time 149.07ms, stw 152.21ms los size: 10984K in use: 3434K
07-07 18:51:37.050 17079 17079 D Mono : GC_MAJOR_SWEEP: major size: 116192K in use: 109850K
07-07 18:51:37.051 17079 17079 I monodroid-gc: 46204 outstanding GREFs. Performing a full GC!
07-07 18:51:37.334 17079 17079 I .defaultmauiapp: Explicit concurrent copying GC freed 4(32KB) AllocSpace objects, 0(0B) LOS objects, 38% free, 38MB/62MB, paused 23us,23us total 118.344ms
07-07 18:51:37.570 1400 1865 D SemWifiSwitchForIndividualAppsService: isSkipNetworkCondition - result:2
07-07 18:51:37.729 17079 17079 D Mono : GC_TAR_BRIDGE bridges 29139 objects 44622 opaque 688 colors 29139 colors-bridged 29139 colors-visible 29139 xref 8688 cache-hit 0 cache-semihit 0 cache-miss 0 setup 1.23ms tarjan 12.01ms scc-setup 2.68ms gather-xref 0.38ms xref-setup 0.15ms cleanup 4.16ms
07-07 18:51:37.729 17079 17079 D Mono : GC_BRIDGE: Complete, was running for 536.71ms
07-07 18:51:37.729 17079 17079 D Mono : GC_MAJOR: (user request) time 137.16ms, stw 140.67ms los size: 10984K in use: 3434K
07-07 18:51:37.729 17079 17079 D Mono : GC_MAJOR_SWEEP: major size: 116192K in use: 110231K
07-07 18:51:37.733 17079 17079 I monodroid-gc: 46204 outstanding GREFs. Performing a full GC!
07-07 18:51:38.014 17079 17079 I .defaultmauiapp: Explicit concurrent copying GC freed 45(33KB) AllocSpace objects, 0(0B) LOS objects, 38% free, 38MB/62MB, paused 26us,20us total 118.367ms
07-07 18:51:38.409 17079 17079 D Mono : GC_TAR_BRIDGE bridges 29139 objects 44622 opaque 688 colors 29139 colors-bridged 29139 colors-visible 29139 xref 8686 cache-hit 0 cache-semihit 0 cache-miss 0 setup 1.21ms tarjan 11.53ms scc-setup 2.70ms gather-xref 0.38ms xref-setup 0.15ms cleanup 4.22ms
07-07 18:51:38.409 17079 17079 D Mono : GC_BRIDGE: Complete, was running for 537.45ms
07-07 18:51:38.409 17079 17079 D Mono : GC_MAJOR: (user request) time 135.38ms, stw 138.53ms los size: 10984K in use: 3434K
07-07 18:51:38.409 17079 17079 D Mono : GC_MAJOR_SWEEP: major size: 116192K in use: 110062K
07-07 18:51:38.412 17079 17079 I monodroid-gc: 46204 outstanding GREFs. Performing a full GC!
07-07 18:51:38.473 6818 6818 I wpa_supplicant: Heartbeat 1511
07-07 18:51:38.540 677 677 D io_stats: !@ 8,0 r 4790966 122177588 w 1751258 13042224 d 424051 9958932 f 0 0 iot 2179040 0 th 0 0 0 pt 0 inp 0 0 23581.695
07-07 18:51:38.540 677 677 D io_stats: !@ Write_top(KB): kworker/u16:2(9371) 44 sait.sohservice(25895) 40
07-07 18:51:38.577 1400 1865 D SemWifiSwitchForIndividualAppsService: isSkipNetworkCondition - result:2
07-07 18:51:38.696 17079 17079 I .defaultmauiapp: Explicit concurrent copying GC freed 4(32KB) AllocSpace objects, 0(0B) LOS objects, 38% free, 38MB/62MB, paused 26us,23us total 119.181ms
07-07 18:51:39.057 1400 1869 D WifiConnectivityMonitor.NetworkStatsAnalyzer: Backhaul result - RSSI:-65, CE:6, PE:8, TI:13, PTI:15, TW:0, PTW:0, Tx:2, Rx:17, TxS:0, RxS:2, RESULT:true, IC:0, ICT:5, WC:0, WCT:5, R:0, RC:2, IE:0, EC:0
07-07 18:51:39.090 17079 17079 D Mono : GC_TAR_BRIDGE bridges 29139 objects 44622 opaque 688 colors 29139 colors-bridged 29139 colors-visible 29139 xref 8686 cache-hit 0 cache-semihit 0 cache-miss 0 setup 1.21ms tarjan 12.20ms scc-setup 2.69ms gather-xref 0.37ms xref-setup 0.14ms cleanup 4.13ms
07-07 18:51:39.090 17079 17079 D Mono : GC_BRIDGE: Complete, was running for 537.16ms
07-07 18:51:39.090 17079 17079 D Mono : GC_MAJOR: (user request) time 137.21ms, stw 140.60ms los size: 10984K in use: 3434K
07-07 18:51:39.090 17079 17079 D Mono : GC_MAJOR_SWEEP: major size: 116192K in use: 108493K
07-07 18:51:39.092 17079 17079 I monodroid-gc: 46204 outstanding GREFs. Performing a full GC!
07-07 18:51:39.223 1400 4779 D SemWifiUsabilityStatsMonitor: onWifiUsabilityStats - seqNum 4669, isSameBssidAndFreq true
07-07 18:51:39.224 1953 1953 D NetworkController.WifiSignalController: notifyListener: visible=true, connected=true, inetCondition=1, isDefault=true, wifiTestReported=true, receivedInetCondition=-1, hideDuringMobileSwitching=false
07-07 18:51:39.224 1400 1851 I SemWifiLinkQualityMonitor: Link Qos Query: 0.021 ms / 372.424 Mbps (526 / 0.006 / 1.000)
07-07 18:51:39.240 1046 1123 I VSyncReactor: Current= 60, Period= 60, hwcPeriod= 60

@jonathanpeppers
Copy link
Member

Did you run this one?

adb shell setprop debug.mono.log default,debugger,assembly,mono_log_level=debug,mono_log_mask=all

There should be monodroid-assembly messages like:

07-07 08:33:25.695 18759 18759 D monodroid-assembly: assembly_store_open_from_bundles: looking for bundled name: 'System.Private.CoreLib' (hash 0x6b0ff375198b9c17)

@lucianparvu
Copy link
Author

lucianparvu commented Jul 7, 2023

Did you run this one?

adb shell setprop debug.mono.log default,debugger,assembly,mono_log_level=debug,mono_log_mask=all

There should be monodroid-assembly messages like:

07-07 08:33:25.695 18759 18759 D monodroid-assembly: assembly_store_open_from_bundles: looking for bundled name: 'System.Private.CoreLib' (hash 0x6b0ff375198b9c17)

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.

@lucianparvu
Copy link
Author

Can i send u source code on your email ? jonathan.peppers@gmail.com it is correct ?

Thanks

@jonathanpeppers
Copy link
Member

jonathanpeppers commented Jul 7, 2023

Does adb shell 'getprop | grep mono' show the value is what you set?

I wonder if you are debugging the app from VS, and it overwrites the value?

@lucianparvu
Copy link
Author

I took the log from Device Log cu copy paste , may this helps

https://raw.githubusercontent.com/lucianparvu/Files/main/log.txt

@jonathanpeppers
Copy link
Member

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:

typemap: unable to find mapping to a managed type from Java type 'java/util/Collections$UnmodifiableCollection$1' (hash 0x151b978993453376)

@jonathanpeppers
Copy link
Member

I tested @lucianparvu's real app (over email).

One thing I found are several .svg files like this:

<svg width="800px" height="800px"

Which are resized to 3200x3200 in for xxxhdpi on Android. These look like small icons that probably don't need to be any larger than 200x200 (and could maybe even be smaller). You can set BaseSize in your .csproj to limit how large .svg files are resized to.

I was already planning to make a build warning for this situation, but I will investigate other issues in this app.

@jonathanpeppers jonathanpeppers added memory-leak 💦 Memory usage grows / objects live forever and removed legacy-area-perf Startup / Runtime performance labels Jul 12, 2023
@jonathanpeppers
Copy link
Member

Beyond the .svg issue, I am able to see a memory leak in @lucianparvu's app, after navigating to a new page and back the new page lives forever.

In this example, I navigated 5 times (and sprinkled some GC.Collect() calls in the app):

image

Still investigating what is going on here.

jonathanpeppers added a commit to jonathanpeppers/maui that referenced this issue Jul 13, 2023
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.
@jonathanpeppers jonathanpeppers self-assigned this Jul 13, 2023
PureWeen pushed a commit that referenced this issue Jul 18, 2023
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.
@samhouts samhouts added the fixed-in-8.0.0-preview.7.8842 Look for this fix in 8.0.0-preview.7.8842! label Aug 8, 2023
@samhouts samhouts added this to the .NET 8 milestone Aug 8, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Sep 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView fixed-in-8.0.0-preview.7.8842 Look for this fix in 8.0.0-preview.7.8842! memory-leak 💦 Memory usage grows / objects live forever platform/android 🤖 t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants