AsyncDisplayKit icon indicating copy to clipboard operation
AsyncDisplayKit copied to clipboard

[ASDisplayNode] Node display failing after alternating between view and node hierarchy in 1.9.3

Open 1nput0utput opened this issue 10 years ago • 12 comments

I am facing an issue where I am animating an ASNetworkImageNode by removing it from ASCellNode to later add it to an UIViewController's view. Animating ASNetworkImageNode back to ASCellNode worked until 1.9.3, now when I add my image view back to ASCellNode, although the image view exists in ASCellNode view hierarchy, it doesn't show up.

My -layoutSpecThatFits isn't being called on ASCellNode. I have tried -setNeedLayout upon my ASCellNode after adding my image view and that didn't help.

1nput0utput avatar Dec 09 '15 18:12 1nput0utput

Does adding your image to the cell node cause a resize? Please try to trigger an empty transaction on the table/collection view and see if the view is updated.

I'm happy to debug if you could put up a sample project. It's possible that ASCellNode's layoutDelegate is gone by the time you add the image back (code), or perhaps there is a new bug introduced by #898.

nguyenhuy avatar Dec 09 '15 18:12 nguyenhuy

@1nput0utput thanks for the report - I think I know what could have caused this, and can fix quickly, but need more information.

Could you include some code snippets or an example flow of steps to reproduce this, broken out by each method call / action involved to make this happen?

appleguy avatar Dec 10 '15 20:12 appleguy

@nguyenhuy @appleguy sorry for not being quick to reply back. I'v quickly created a test project using the Kittens sample and I can see the exact same behaviour https://github.com/1nput0utput/ImageTest.git

Thanks for helping out!

1nput0utput avatar Dec 11 '15 21:12 1nput0utput

@1nput0utput thanks a lot! I'm looking at the sample project now, and should be able to fix this tonight or tomorrow - and roll a 1.9.4 before Monday. Note your Podfile for the sample project appears to be specifying version 1.9, which you don't really want, so make sure your main project is getting the latest version!

appleguy avatar Dec 19 '15 03:12 appleguy

@1nput0utput please try out the fix as soon as you have the opportunity. It does fix your test project, although there is a flash that I see. If the flash is your main problem now, let me know and I can definitely investigate fixing that specifically. Overall though I would highly recommend you re-evaluate the architectural approach here and avoid re-hosting nodes between view and node hierarchies.

appleguy avatar Dec 19 '15 04:12 appleguy

To clarify - I definitely agree it should be supported, and bug-free, which is why I jumped on fixing this for 1.9.4 - but still, even view re-hosting is a bit of a hacky technique. Re-hosting nodes /between different types of hierarchies/ is an additional level of hacky :)

appleguy avatar Dec 19 '15 04:12 appleguy

@1nput0utput oops. I didn't completely fix it. I changed your code slightly, to use imageViewOriginalSupernode instead of imageViewOriginalView. It was a very quick change to do.

However, after reverting that, it doesn't quite fix it. The reason is that right now, adding a subnode directly to another subnode's view does not correctly hook up their node hierarchies. I can fix this in a separate commit, and will file an issue for it now.

appleguy avatar Dec 19 '15 04:12 appleguy

@appleguy changing from using view to node definitely did the trick. I can't wait for the actual fix so that the node behaviour resemble as of UIView.

I do understand the hacky way my image viewer is implemented, I was trying to give a smoother user experience, somewhat similar to the Facebook's app. I unfortunately ended up with the flash when presenting and dismissing the view controller. If you have any suggestions or a direction I can take to smoothly transition the image from one view to another, I'd love to hear.

1nput0utput avatar Dec 19 '15 18:12 1nput0utput

@1nput0utput ok, thank you for the update. I am looking at the auto-magical hookup right now and will see if I can fix the flash for you :)

appleguy avatar Dec 19 '15 21:12 appleguy

@1nput0utput @appleguy For what it's worth, I was running into a flickering problem in a similar situation where I was moving an ASImageNode from a collection view cell to an ASViewController, using a custom transition. I was able to tweak my transition animation code a bit to fix the issue. The key was to insert the image node into the destination viewController's node immediately after adding that viewController's view to the transition context's containerView. Hope that helps.

tomizimobile avatar Dec 23 '15 20:12 tomizimobile

Thanks @tomizimobile. Are you supporting orientation in your ASViewController?

A brief history. I did not have flickering in my view controller prior to supporting orientation. As my main view controller needs to stay in portrait, my image viewer did not. For this situation you're bound to a full screen presentation style instead of UIModalPresentationCurrentContext. As you can imagine, upon dismiss my presentingViewController's view is not present causing to flicker when it becomes visible again.

1nput0utput avatar Dec 25 '15 02:12 1nput0utput

@1nput0utput I'm not supporting anything but .Portrait orientation, but I am presenting it as .FullScreen. However, just after applying the animations I need for dismissal, I'm inserting the presentingViewController's view below the presentedViewController's view. My animation fades every view in the presentedViewController's view aside from the ASImageNode as you dismiss. Then I insert the ASImageNode back to where it belongs just before completing the transition.

tomizimobile avatar Dec 28 '15 14:12 tomizimobile