You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We ran into this behavior in our App.
From #374 I know that page components are supposed to be reused when we open a new Page in our application and go back.
But that doesn't seem to apply to ListView items.
When we navigate away from the Page containing a ListView and back again.
New instances of the item components are created, but ngOnDestroy on the old components are never called.
Which could lead to leaks, since we cannot do clean up on destruction.
If you checkout my example, you should see this behavior (on Android, haven't tested it on iOS):
0. Start the App.
* You should see in the log:
ListView(N)
HomeItemComponent<1>.ngOnInit()
HomeItemComponent<2>.ngOnInit()
HomeItemComponent<.>.ngOnInit()
HomeItemComponent<.>.ngOnInit()
HomeItemComponent<.>.ngOnInit()
HomeItemComponent<N>.ngOnInit()
1. Click on 'Read all about it'.
* You should see in the log:
No calls to ngOnDestroy on the HomeItemComponent elements.
2. Click back-button
* You should see in the log:
ListView(N) <--- Note same number e.g. same instance of the ListView
HomeItemComponent<N+1>.ngOnInit()
HomeItemComponent<N+2>.ngOnInit()
HomeItemComponent<.>.ngOnInit()
HomeItemComponent<.>.ngOnInit()
HomeItemComponent<.>.ngOnInit()
HomeItemComponent<N+N2>.ngOnInit()
The text was updated successfully, but these errors were encountered:
We hit several crashes in our internal tests, and I had to reinvestigate this issue. It turns out that we are not supposed to destroy item views on element unloaded events since those were being fired when navigating to a new page. Destroying views there caused removal of items that were supposed to be recycled by the underlying ListView component, which is a major no-no.
Not destroying item views seems to be the correct behavior here since the list view items should stay loaded when navigating to a new page, and navigating back, should reattach the listview and all its items. ngOnDestroy will be called when you navigate back, or just remove the listview from the visual tree.
This uncovered another memory leak, which is probably what is the problem here. I am opening a new issue to track it. #737
We ran into this behavior in our App.
From #374 I know that page components are supposed to be reused when we open a new Page in our application and go back.
But that doesn't seem to apply to ListView items.
When we navigate away from the Page containing a
ListView
and back again.New instances of the item components are created, but
ngOnDestroy
on the old components are never called.Which could lead to leaks, since we cannot do clean up on destruction.
I've written an example here:
https://github.com/m-abs/ns-debugging/tree/ng2-list-view-no-reuse-post-navigate
If you checkout my example, you should see this behavior (on Android, haven't tested it on iOS):
The text was updated successfully, but these errors were encountered: