Description
From @molon on November 26, 2015 13:20
Hi,
There's a ASTextNode
in a ASLazyLoadCellNode
.
I try to set attributedString to it at the end of table view.
Then I insert new rows.
This is just the happen scene upon.
debug below:
some test I added:
break at the function
the output, we can see it breaks before the last isCancelledBlock
We can see that the willMoveToWindow:
(window is nil) is called because of inserting rows.
it cause cancelAsyncDisplay
to be called. This led to dirty contents of layer.
Then the last isCancelledBlock will return YES. The last draw attributedString will be ignored. So it layer.content
is stale(dirty) now.
__enterHierarchy
will be called when willMoveToWindow
(window is not nil).
setNeedsDisplay
is called in __enterHierarchy
when layer.content == nil
.
But the layer.content==nil
can only ensure the layer will be redraw when nil, not stale(dirty).
And It's really dirty sometimes.
eg:
updateVisibleNodeIndexPaths
will lead to recursivelyClearContents
with some indexPaths. it's ok.
But [_layoutController indexPathsForScrolling:_scrollDirection viewportSize:viewportSize rangeType:rangeType]
will return indexPaths which not visible sometimes, thus these rows will be remove from window by configureContentView:forCellNode:
but havn't clear content.
So the rows will not be redisplay. I think it's a BUG.
In summary, the cancelAsyncDisplay
only cancel the next drawing of layer, but! but! not clear the dirty contents of layer. So it will be not redraw because it's contents not nil ,when the layer display again,
I think views is not necessary to call cancelAsyncDisplay
after removing from a window unless we can throw the dirty contents away.
It will cause some unforeseen circumstances.
:)
Copied from original issue: facebookarchive/AsyncDisplayKit#889