-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[iOS]Fix: FlyoutPage memory leak #28769
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -1,5 +1,4 @@ | ||||||||
#if IOS | ||||||||
using NUnit.Framework; | ||||||||
using NUnit.Framework; | ||||||||
using UITest.Appium; | ||||||||
using UITest.Core; | ||||||||
|
||||||||
|
@@ -14,15 +13,14 @@ public Bugzilla31255(TestDevice testDevice) : base(testDevice) | |||||||
public override string Issue => "Flyout's page Icon cause memory leak after FlyoutPage is popped out by holding on page"; | ||||||||
|
||||||||
[Test] | ||||||||
[Ignore("The sample is crashing. More information: https://github.com/dotnet/maui/issues/21206")] | ||||||||
[Category(UITestCategories.Navigation)] | ||||||||
[Category(UITestCategories.Compatibility)] | ||||||||
public async Task Bugzilla31255Test() | ||||||||
public void Bugzilla31255Test() | ||||||||
{ | ||||||||
App.Screenshot("I am at Bugzilla 31255"); | ||||||||
await Task.Delay(5000); | ||||||||
App.WaitForNoElement("Page1. But Page2 IsAlive = False"); | ||||||||
Thread.Sleep(5000); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test is probably going to be flaky as-is (possible to fail at some percentage), best results are to do something like these other tests: maui/src/Controls/tests/Core.UnitTests/WeakEventProxyTests.cs Lines 25 to 27 in dad356b
@PureWeen is there a helper method for this in the UITests project? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jonathanpeppers checking for memory leaks in a UI test isn’t really ideal and not something we typically do. That’s exactly why I added a device test that covers the same modal I’ve still kept the UI test for now just because it was already there and passing with the fix, but I think we can safely remove it if we’re good with the device test coverage. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Recently, there was this attempt https://github.com/dotnet/maui/pull/28489/files by @simonrozsival. Hopefully, it will get resurrected. :) |
||||||||
var text = App.WaitForElement("MauiLabel").GetText(); | ||||||||
Assert.That(text, Is.EqualTo("Page1. But Page2 IsAlive = False")); | ||||||||
} | ||||||||
} | ||||||||
} | ||||||||
#endif | ||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this shouldn't be here. We are already calling this above
maui/src/Controls/src/Core/Compatibility/Handlers/FlyoutPage/iOS/PhoneFlyoutPageRenderer.cs
Line 132 in 8ee00e0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it matter if we just leave it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PureWeen Without the PR changes, since we’re inside
Dispose
, the wrapper’s Element will be null at this point — soPage
falls back to the strongly referenced _element:maui/src/Controls/src/Core/Compatibility/Handlers/FlyoutPage/iOS/PhoneFlyoutPageRenderer.cs
Line 78 in 8ee00e0
With the PR changes,
_element
is resolved through a weak reference, so keeping theSendDisappearing()
call here won’t make a differenceLet me know if you think I should keep the call.