Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Truncated ASTextNode appearing in node that should not be truncated. #1841

Closed
nickvelloff opened this issue Jul 2, 2016 · 7 comments · Fixed by #1863 or #1924
Closed

Truncated ASTextNode appearing in node that should not be truncated. #1841

nickvelloff opened this issue Jul 2, 2016 · 7 comments · Fixed by #1863 or #1924
Milestone

Comments

@nickvelloff
Copy link
Contributor

ASCollectionNode, with ASCellNodes

Please note there is no cell re-use. They look similar (aside from background images) for testing purposes. This reproduces with any string that gets truncated at smaller cell sizes.

Layout approach is pure layoutSpecThatFits from root ASCellNode down the view hierarchy.

In overriding visibilityDidChange I can see that the constrainedSize is correct for every node, including the text nodes that have the incorrect truncation. The bounds, however, are incorrect for the truncated text nodes.

After the resize transition, many nodes are properly laid out. When you scroll you eventually hit cells that have the ASTextNode truncating the NSAttributedString to the same place as it was previous to the resize.

This happens regardless of text formatting or otherwise, and can be reproduced with a plain NSAttributedString.

In summary, if a ASTextNode has ever been truncated, it can appear again truncated with a larger constrainedSize, as if it was cached and reused or something. Important to note that this seems to happen for cells that are well out of any buffer ranges.

errrr-cat

@appleguy
Copy link
Contributor

appleguy commented Jul 4, 2016

@nickvelloff Great report! Would you be able to modify one of our examples, or make a new one, that generates this behavior? It might be as simple as calling measure: at one size, having that display, and after a timer (or a tap) having it measure at another size. You may be able to use the Kittens app by setting the cells to a fixed height and changing the text, as tapping the cells makes the image take up more of the cell.

I can see why this would happen for items outside of any preload ranges - but it certainly shouldn't happen at all, and indeed is probably a missing invalidateCalculatedLayout somewhere. Should not be that hard to fix.

What framework version? We have some changes to ASTextNode in master, although I don't think they will fix this.

@appleguy appleguy added this to the 1.9.9 milestone Jul 4, 2016
@nickvelloff
Copy link
Contributor Author

@appleguy I'm working on an example to reproduce with the lease amount of unrelated factors. I've pretty much sticking to master during heavy development.
I'll post a link to the example here shortly.
Thanks for looking into this!

@nickvelloff
Copy link
Contributor Author

nickvelloff commented Jul 4, 2016

@appleguy I did everything I could to boil this down to something easily reproducible. Alas, it took a lot more to build the environment necessary than I had hoped.

The issue is there are currently a lot of customizations required to get ASCollectionNode/View to transition from one layout to another (animated). Once a constrained size is received for a node, it never asks again. That is unless I do all the things I do to force it to transition, hence all the custom code you'll see.

My new approach to test and learn is taking advantage of Playgrounds. So I went ahead and did the example that way, in hopes of it being easier to debug. Curious as to your thoughts on it.

https://github.com/the-grid/TruncationBug-AsyncDisplayKitPlayground

@nickvelloff
Copy link
Contributor Author

@appleguy Also you asked if this is a regression. Unfortunately I can't say, because I noticed it in a completely new app design approach, which is full stack ASDK using ASLayoutSpec.
I can say however that using ASTextNode in a far less efficient manner as part of the UIKit view hierarchy did not exhibit this behavior. But that's not super useful as a comparison.

@nickvelloff
Copy link
Contributor Author

nickvelloff commented Jul 4, 2016

Thought of one more thing... in testing this I did notice that even calling measure on the node at a very late visibilityDidChange did not cause it to correct it's bounds. I would attribute this to it already having the correct constrainedSize, but incorrect bounds. Just having dug through a lot of ASDK source I would guess it would ignore a size sent to measure that was the same as is already stored internally. Just a guess though.

@maicki
Copy link
Contributor

maicki commented Jul 11, 2016

Initial PR was reverted. Will reopen.

@knowsudhanshu
Copy link

knowsudhanshu commented Aug 30, 2018

Struggling with a similar issue.
preload is working fine but as a new CellNode is inserted at an index out of visible range its TextNode gets clipped when I scroll directly to that indexPath ( on tap of a button ).

Have a look at attached screenshots. Please suggest a solution

https://user-images.githubusercontent.com/3315175/44842123-ab915100-ac62-11e8-8c36-d4168cc1ea37.png
https://user-images.githubusercontent.com/3315175/44842138-b21fc880-ac62-11e8-9172-38fcf29213bc.png

aimalygin pushed a commit to aimalygin/AsyncDisplayKit that referenced this issue Sep 16, 2020
- Followup to facebookarchive#1742
- At Pinterest this shipped with D516974 in late 02/2020
- As discussed in facebookarchive#858 this is iOS10 or later, so the runtime `gMutex_unfair` check is still necessary for Texture.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
5 participants
@maicki @appleguy @nickvelloff @knowsudhanshu and others