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

Refactor Sample to Trigger MyPage Disposal #1

Closed
wants to merge 1 commit into from

Conversation

brminnick
Copy link

Hey @marco-skizza!

After some refactoring, I was able to trigger the finalizer in MyPage on both iOS + Android, despite it using the MediaElement.

This fork contains the updated sample. To trigger the disposal of MyPage, continue to click the Button on each page to navigate back-and-forth between MyPage and MyThirdPage. With the debugger attached and a breakpoint in ~MyPage(), you will see the page does get disposed.

image

@marco-skizza
Copy link
Owner

Hi @brminnick

Thanks for your code.

Unfortunately, the code doesn't work as expected anymore (tested on iOS).
The navigation was more for illustration purposes:

  • I have a page (MainPage)
    • I can navigate to a page with a MediaElement (MyPage)
      • I can navigate to a next page and back again (to MyThirdPage)

I can't foresee the actual order of the pages visited forth and back in the real app.
So I guess the routing, where MyPage "knows" about MyThirdPage doesn't work for me.

But maybe you can point me to the key point of your change that fixed the problem...?

@marco-skizza
Copy link
Owner

Hi @brminnick

I think my last comment was more about the Unloaded problem.

I played around with your code a bit and found out that it starts "leaking" again when you add the MyViewModel back to the MyPage as binding context. So I can imagine that there may be some "leaking" with the source binding Source="{Binding FilePath}" in MediaElement...

@brminnick
Copy link
Author

This is likely a leak in .NET MAUI or Shell.

I encourage you to open an Issue on the dotnet/maui repo.

My focus is on the Community Toolkit.

@marco-skizza
Copy link
Owner

marco-skizza commented Feb 21, 2024

It may be a similar problem as: dotnet/maui#20710
It affects not every binding in .NET MAUI - but I found that on the CollectionView by investigating as well.
But we can also wait and see what this MAUI Issue brings to light...

@marco-skizza
Copy link
Owner

P.S.: I added the link to the MAUI Issue on the main bugreport - so it's easier for people to find/follow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants