Skip to content

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

Closed
@siucarlos

Description

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

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions