Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[_ASDisplayLayer setDelegate:] is not called by UIViews #1595

Closed
siucarlos opened this issue Jul 23, 2019 · 6 comments · Fixed by #1609
Closed

[_ASDisplayLayer setDelegate:] is not called by UIViews #1595

siucarlos opened this issue Jul 23, 2019 · 6 comments · Fixed by #1609
Labels

Comments

@siucarlos
Copy link

UIView should call setDelegate on its backing layer to itself, which happens in iOS 12. But in iOS 13, this does not happen.
Stack in iOS 12:

#0 0x00000001102e1124 in ::-_ASDisplayLayer setDelegate: at Texture/Source/Details/_ASDisplayLayer.mm:37
#1 0x0000000125b50923 in _UIViewLayerSetView ()
#2 0x0000000125b1538f in -[UIView _createLayerWithFrame:] ()
#3 0x0000000125b15ec3 in UIViewCommonInitWithFrame ()
#4 0x0000000125b15b2d in -[UIView initWithFrame:] ()
#5 0x0000000125b1522f in -[UIView init] ()
#6 0x0000000110124fa0 in ::-ASDisplayNode _locked_viewToLoad at /Texture/Source/ASDisplayNode.mm:497
#7 0x00000001101259db in ::-ASDisplayNode _locked_loadViewOrLayer at Texture/Source/ASDisplayNode.mm:564
#8 0x00000001101265c6 in ::-ASDisplayNode view at /Texture/Source/ASDisplayNode.mm:634
#9 0x00000001102a5bf2 in ::-ASViewController loadView at r/Texture/Source/ASViewController.mm:128

UICollectionView relies on a delegate call from its layer to trigger a relayout when the frame changes. Since the delegate is not set on _ASDisplayLayer, it never gets the callback.

Example of a stack of the delegate method

  • (void)layer:(CALayer *)layer didChangeBoundsWithOldValue:(CGRect)oldBounds newValue:(CGRect)newBounds;

being called

#0 0x00000001101bd02b in ::-[ASPagerNode collectionNode:constrainedSizeForItemAtIndexPath:](ASCollectionNode *, NSIndexPath *) at Texture/Source/ASPagerNode.mm:174
#1 0x00000001100d0560 in ::-[ASCollectionViewFlowLayoutInspector collectionView:constrainedSizeForNodeAtIndexPath:](ASCollectionView *, NSIndexPath *) at Texture/Source/Private/ASCollectionViewFlowLayoutInspector.mm:69
#2 0x00000001100c8f6c in ::-[ASCollectionView dataController:constrainedSizeForNodeAtIndexPath:](ASDataController *, NSIndexPath *) at Texture/Source/ASCollectionView.mm:2142
#3 0x00000001100e4622 in ::-[ASDataController constrainedSizeForNodeOfKind:atIndexPath:](NSString *, NSIndexPath *) at Texture/Source/Details/ASDataController.mm:472
#4 0x00000001100eba76 in ::-ASDataController _relayoutAllNodes at Texture/Source/Details/ASDataController.mm:887
#5 0x00000001100eb297 in ::__58-[ASDataController relayoutAllNodesWithInvalidationBlock:]_block_invoke() at Texture/Source/Details/ASDataController.mm:860
#6 0x000000011019d52f in ::__30-[ASMainSerialQueue runBlocks]_block_invoke() at Texture/Source/Details/ASMainSerialQueue.mm:65
#7 0x0000000110175b24 in ::ASPerformBlockOnMainThread(void (^)()) at Texture/Source/Private/ASInternalHelpers.mm:130
#8 0x000000011019d39e in ::-ASMainSerialQueue runBlocks at Texture/Source/Details/ASMainSerialQueue.mm:71
#9 0x000000011019d2c4 in ::-ASMainSerialQueue performBlockOnMainThread: at Texture/Source/Details/ASMainSerialQueue.mm:48
#10 0x00000001100ec792 in ::-ASDataController _scheduleBlockOnMainSerialQueue: at Texture/Source/Details/ASDataController.mm:937
#11 0x00000001100eb1a8 in ::-[ASDataController relayoutAllNodesWithInvalidationBlock:](void (^)()) at Texture/Source/Details/ASDataController.mm:852
#12 0x00000001100af076 in ::-ASCollectionView relayoutItems at Texture/Source/ASCollectionView.mm:378
#13 0x00000001100cf21a in ::-[ASCollectionView layer:didChangeBoundsWithOldValue:newValue:](CALayer *, CGRect, CGRect) at Texture/Source/ASCollectionView.mm:2498
#14 0x00000001102e1b0e in ::-_ASDisplayLayer setBounds: at Texture/Source/Details/_ASDisplayLayer.mm:66
#15 0x0000000119837e2c in -[CALayer setFrame:] ()
#16 0x0000000125b292f3 in -[UIView(Geometry) setFrame:] ()
#17 0x0000000125abe690 in -[UIScrollView setFrame:] ()
#18 0x0000000124eef79a in -[UICollectionView setFrame:] ()
#19 0x000000011010c93d in ::-ASDisplayNode(UIViewBridge) setFrame: at Texture/Source/Private/ASDisplayNode+UIViewBridge.mm:399

@hovox
Copy link

hovox commented Aug 5, 2019

Is there any workaround/solution for this?

@atecle
Copy link

atecle commented Aug 7, 2019

Hi, I'm also seeking a workaround. I'm having an issue on iOS 13 where a cell does not properly resize after changing orientation -- seeing in the view debugger that the top ASDisplayView in my cell isn't filling its container UIView.

@rahul-malik
Copy link
Contributor

@atecle @hovox - I have a PR coming that I'd be interested for you to patch and test out

@rahul-malik
Copy link
Contributor

@atecle @hovox - Can you patch the changes in this PR and see if it resolves your issue? #1609

@atecle
Copy link

atecle commented Aug 8, 2019

@rahul-malik Just tested your patch, the issue has been resolved. Thanks very much for finding and fixing that! 💯

@SoundBlaster
Copy link

iOS calls -setUnsafeUnretainedDelegate: instead -setDelegate:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants