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

Nested nav stacks are not destroyed when their root does #10286

Closed
4mp3R opened this issue Feb 2, 2017 · 2 comments
Closed

Nested nav stacks are not destroyed when their root does #10286

4mp3R opened this issue Feb 2, 2017 · 2 comments
Assignees

Comments

@4mp3R
Copy link

4mp3R commented Feb 2, 2017

Ionic version: (check one with "x")
[ ] 1.x
[x] 2.x

I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/

Current behavior:
When using nested navigation stacks, the children nav stacks are not destroyed when their root does.

Expected behavior:
All the children nav stacks along with the pages they contain should be destroyed when their root nav stack is destroyed.

Steps to reproduce:
Plunkr link: http://plnkr.co/edit/365N234EjkVepp1GQbhJ?p=preview

If my understanding is correct, the initial set of nav stacks should look as follows:

Component Nav Controller Type Nav Stack
AppComponent Nav [ HomePage ]
HomePage Nav [ TabsView ]
TabsView Tabs [ Tab1Component ], [ Tab2Component ] -> One nav stack per tab

You can see the stream observer in the Tab1Component printing console logs once a second.

When you click on the Change the root page button in the 1st tab,
the .setRoot(AltHomePage) is called on the application's root nav controller.

At this point I'd expect the only nav stack to be like this:

Component Nav Controller Type Nav Stack
AppComponent Nav [ AltHomePage ]

I would also expect the nested nav stacks to be destroyed along with the pages they contain.
However, we can observe that:

  • The subscription made in the 1st tab remain active and reacts on new stream data
  • The ionViewWillUnload() methods of the components in the nested nav controllers' stacks are not called
  • The ngOnDestroy() hooks are called

So it seems like the components are actually destroyed from Angular's point of view, but not from Ionic's one.
Moreover, it seems like Ionic continues to keep track of the nested nav stacks (that should be removed at this point)
thus preventing the page instances from being released from memory.

This issue leads to memory leaks.
My impression is that some cleanup methods are not called in the Ionic's navigation system internals.
Anyways, I think there should be a way to release all the resources (nav controllers and relative pages) related to a nav stack.

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

Your system information:

Cordova CLI: 6.4.0
Ionic Framework Version: 2.0.0
Ionic CLI Version: 2.1.13
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 1.0.0
ios-deploy version: 1.9.0
ios-sim version: 5.0.8
OS: OS X El Capitan
Node Version: v6.5.0
Xcode version: Xcode 8.1 Build version 8B62
@manucorporat manucorporat self-assigned this Feb 2, 2017
@tafax
Copy link

tafax commented Feb 10, 2017

Any news for this (maybe) bug?

manucorporat added a commit to manucorporat/ionic that referenced this issue Feb 26, 2017
@ionitron-bot
Copy link

ionitron-bot bot commented Sep 3, 2018

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants