-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Comments
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:
|
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. |
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? |
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 |
This behavior probably didn't change in net9 can you attach a repro? |
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. |
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. |
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
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
The text was updated successfully, but these errors were encountered: