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

Changing the MainPage resets the ModalStack of Navigation without popping the pages #24090

Closed
dalux-era opened this issue Aug 8, 2024 · 7 comments
Labels
area-controls-modal platform/android 🤖 platform/iOS 🍎 s/needs-repro Attach a solution or code which reproduces the issue t/bug Something isn't working

Comments

@dalux-era
Copy link

Description

If you have a place in the code where you need to change the MainPage to something else, we usually change the MainPage and then dispose of the old main page and its Navigation. This is done to prevent memory leaks of the pages related to the old Main Page. However, in the following example

oldMainPage = MainPage;
vat t = oldMainPage.Navigation.ModalStack;		
MainPage = newMainPage;
vat t1 = oldMainPage.Navigation.ModalStack;	

I can see that the t and t1 differ, t1 will be an empty IReadOnlyList. Meaning that reference to the Modal pages is gone and can only be accessed in Window. This is not the case for oldMainPage.Navigation.NavigationStack, this one still keeps reference of the old pages.

Is this a known or expected thing?

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

8.0.61 SR6.1

Is this a regression from previous behavior?

No, this is something new

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android

Affected platform versions

No response

Did you find any workaround?

The workaround in this particular case is to Pop the pages before we change the main page, which can create visual artifacts

Relevant log output

No response

@dalux-era dalux-era added the t/bug Something isn't working label Aug 8, 2024
Copy link
Contributor

github-actions bot commented Aug 8, 2024

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@jfversluis
Copy link
Member

Just a heads up, we probably won't be prioritizing this as MainPage will be obsoleted as of .NET 9. So you might want to look into doing things differently altogether.

@PureWeen PureWeen added the s/needs-repro Attach a solution or code which reproduces the issue label Aug 9, 2024
@PureWeen
Copy link
Member

PureWeen commented Aug 9, 2024

I might have misunderstood but when I tested the stack is cleared. From what I can remember when you query the modal stack it basically just walks up to the window until it finds the window and returns the modal stack.

If a page doesn't have a window it returns zero.

Maybe you're pushing modals before a window has loaded and those are staying cached somewhere and then are still around when it swaps?

image

@dalux-era
Copy link
Author

The stack is cleared, but as far as I can see, the modal page stays in Windows[0].LogicalChildren for a while. We mainly experience this because we want to call DisconnectHandler on the pages in modal stack. We cannot do it before we change MainPage and after we change MainPage we do not have them in ModalStack. The current workaround is to manually pop them before MainPage is changed.

Also, judging from previous comments this might work differently in .net9

@dotnet-policy-service dotnet-policy-service bot added s/needs-attention Issue has more information and needs another look and removed s/needs-repro Attach a solution or code which reproduces the issue labels Aug 14, 2024
@PureWeen
Copy link
Member

This behavior probably didn't change in net9 can you attach a repro?

@PureWeen PureWeen added s/needs-repro Attach a solution or code which reproduces the issue and removed s/needs-attention Issue has more information and needs another look labels Aug 14, 2024
Copy link
Contributor

Hi @era-maui. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

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.

@dotnet-policy-service dotnet-policy-service bot added the s/no-recent-activity Issue has had no recent activity label Aug 19, 2024
Copy link
Contributor

This issue has been automatically marked as stale because it has been marked as requiring author feedback to reproduce the issue but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

@dotnet-policy-service dotnet-policy-service bot removed the s/no-recent-activity Issue has had no recent activity label Aug 28, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Sep 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-modal platform/android 🤖 platform/iOS 🍎 s/needs-repro Attach a solution or code which reproduces the issue t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants