Texture icon indicating copy to clipboard operation
Texture copied to clipboard

[ASCollectionNode ASTableNode] reloaded cell is not deinit correctly

Open jeffersonsetiawan opened this issue 4 years ago • 0 comments

When do the collectionNode.reloadItems(at: ) the old cell is not call deinit yet. Gist: https://gist.github.com/jeffersonsetiawan/1632ffb6fb03e8edc11b87d45b71f997

Sample case in the gist code:

  • Collection with 10 items
  • Tapping the button, it will reloadItems in index number 2.
  • If the cell that would be replaced is visible in the screen (cell no 2), the deinit will not get called, it will called if we reloaditems again or we scroll a bit

Deinit is called after I scroll a bit

Another way to call the deinit is when we reload the items when the cell no 2 is not visible, it will directly call the deinit.

When checking in memory debugger, the old unseen cell (TestCellNode number 2), it is retain by the ASCollectionViewCell. Screen Shot 2021-09-30 at 14 08 19

This can cause issue for example when you are using Reactive programming, and run the timer, the timer will still running even when the cell is not visible/not valid.

The issue will not happen if I used reloadData()

Update Finding

Checking for the memory debugger, the Cell is holded by ASCollectionView. _subviewCache, I think if we can remove the cache, we can closed this issue. Still not found how to remove that cache yet. Screen Shot 2021-09-30 at 18 19 55

I have tested in both Texture 2.7 and Texture 3.

jeffersonsetiawan avatar Sep 30 '21 07:09 jeffersonsetiawan