[iOS]Fix: FlyoutPage memory leak#28769
Merged
PureWeen merged 6 commits intodotnet:inflight/currentfrom May 5, 2025
Merged
Conversation
bhavanesh2001
commented
Apr 2, 2025
|
|
||
| EmptyContainers(); | ||
|
|
||
| Page.SendDisappearing(); |
Contributor
Author
There was a problem hiding this comment.
this shouldn't be here. We are already calling this above
Member
There was a problem hiding this comment.
Does it matter if we just leave it?
Contributor
Author
There was a problem hiding this comment.
@PureWeen Without the PR changes, since we’re inside Dispose, the wrapper’s Element will be null at this point — so Page falls back to the strongly referenced _element:
With the PR changes, _element is resolved through a weak reference, so keeping the SendDisappearing() call here won’t make a difference
Let me know if you think I should keep the call.
src/Controls/src/Core/Compatibility/Handlers/FlyoutPage/iOS/PhoneFlyoutPageRenderer.cs
Outdated
Show resolved
Hide resolved
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla31255.cs
Outdated
Show resolved
Hide resolved
Contributor
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
Contributor
Author
|
/rebase |
3f656df to
e444f42
Compare
Member
|
/rebase |
d657670 to
27e1a6b
Compare
PureWeen
reviewed
May 2, 2025
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla31255.cs
Show resolved
Hide resolved
Member
|
/azp run MAUI-UITests-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
PureWeen
previously approved these changes
May 3, 2025
Member
|
/azp run MAUI-DeviceTests-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
PureWeen
approved these changes
May 5, 2025
PureWeen
pushed a commit
that referenced
this pull request
May 5, 2025
* fix * enable Bugzilla31255Test * add device test * make _element a weak reference directly * fix device test * Use AssertMemoryTest in UITest
PureWeen
added a commit
that referenced
this pull request
May 8, 2025
For more information about inflight process check https://github.com/dotnet/maui/wiki/Inflight-Branch-Process ## .NET MAUI Release Notes - inflight/candidate This document contains release notes for changes from main branch to inflight/candidate branch. ### MAUI Product Fixes * [iOS] Fix: FlyoutPage memory leak by @bhavanesh001 in #28769 * [Windows] Fix for CarouselView IsSwipeEnabled=False Prevents Visual Navigation by @SubhikshaSF4852 in #29286 * [Windows] Fix for Argument Exception raised when the GetStringSize method of ICanvas called with default font by @SyedAbdulAzeemSF4852 in #29048 * Removed frame styles by @Vignesh-SF3580 in #29222 * [Android] Fixed the CollectionView Header and Footer Do Not Align with Horizontal ItemsLayout When EmptyView is Displayed by @Ahamed-Ali in #28779 * Add global xmlns in template by @StephaneDelcroix in #29203 * Fixed - On iOS GestureRecognizers don't work on Span in a Label, which doesn't get IsVisible (=true) update from its parent by @KarthikRajaKalaimani in #29024 * Fixed Footer not displayed at the Bottom When EmptyView in CV2 by @Dhivya-SF4094 in #28681 * Fixed typo in Connectivity.shared.cs by @corvinsz in #29213 ### Testing * Re-enabled flaky UI test TextInEditorShouldScroll by @NirmalKumarYuvaraj in #29167 * [Testing] Re-Enabled UI Test - Issue10222Test by @TamilarasanSF4853 in #29226 * [Testing] Feature Matrix UITest Cases for CollectionView Selection Feature by @LogishaSelvarajSF4525 in #29165 ### Dependency Updates *No dependency updates in this release* ### Docs *No documentation changes in this release* ### Housekeeping *No housekeeping changes in this release* ## New Contributors * @corvinsz made their first contribution in #29213 **Full Changelog**: main...inflight/candidate
SuthiYuvaraj
pushed a commit
to SuthiYuvaraj/maui
that referenced
this pull request
May 9, 2025
* fix * enable Bugzilla31255Test * add device test * make _element a weak reference directly * fix device test * Use AssertMemoryTest in UITest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Change
While enabling the UITest
Bugzilla31255Test, which pushes aFlyoutPagemodally and then pops it, I encountered a memory leak on iOS. TheFlyoutPageinstance was not being collected even after the modal pop.Originally, the test case was also causing a crash because
FlyoutandDetailwere being set to instances ofPage, which is not supported. I updated them to useContentPage, which resolved the crash.The memory leak was caused by the renderer holding a strong reference to the virtual view (
_element), which prevented theFlyoutPagefrom being garbage collected.I also added a device test that reproduces the same modal flow and asserts that the page is collected by the GC. While this device test covers the same scenario as the UITest, I’ve kept both for now.
If you'd prefer to remove the UITest and rely only on the device test, let me know.
Issues Fixed
Fixes #21206