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

Fix locking situation of layout transition - #3217

Merged
Adlai-Holler merged 1 commit into
facebookarchive:masterfrom
nguyenhuy:HNLayoutTransitionDeadlock
Mar 24, 2017
Merged

Fix locking situation of layout transition#3217
Adlai-Holler merged 1 commit into
facebookarchive:masterfrom
nguyenhuy:HNLayoutTransitionDeadlock

Conversation

@nguyenhuy

@nguyenhuy nguyenhuy commented Mar 24, 2017

Copy link
Copy Markdown
Contributor
  • It's not safe to hold the lock of a supernode and:
    • Edit states of its subnodes
    • Call subclass hooks
    • Run completion block
    • Run animation, which can trigger layout passes on subnodes. Especially dangerous if one of them is a collection view because the layout pass can cause a change set update if it's the first pass.

This should fix https://jira.pinadmin.com/browse/BUG-53093

[Thread 0] Crashed: com.apple.main-thread
SIGABRT ABORT 0x000000001dc1f89c
  0 libsystem_kernel.dylib         499251356  semaphore_wait_trap + 8
  1 libdispatch.dylib              498348313  _dispatch_group_wait_slow + 234
> 2 Pinterest                      6453191    -[ASDataController updateWithChangeSet:] (ASDataController.mm:444)
  3 Pinterest                      6389189    -[ASCollectionView endUpdatesAnimated:completion:] (ASCollectionView.mm:791)
  4 Pinterest                      6389441    -[ASCollectionView performBatchAnimated:updates:completion:] (ASCollectionView.mm:803)
  5 Pinterest                      6389689    -[ASCollectionView performBatchUpdates:completion:] (ASCollectionView.mm:809)
  6 Pinterest                      6376343    -[ASCollectionView reloadDataWithCompletion:] (ASCollectionView.mm:330)
  7 UIKit                          594195201  -[UICollectionView numberOfSections] + 22
  8 UIKit                          601801303  -[UICollectionViewFlowLayout _getSizingInfosWithExistingSizingDictionary:] + 750
  9 UIKit                          601809707  -[UICollectionViewFlowLayout _fetchItemsInfoForRect:] + 136
 10 UIKit                          594194993  -[UICollectionViewFlowLayout prepareLayout] + 224
 11 UIKit                          593058551  -[UICollectionViewData _prepareToLoadData] + 164
 12 UIKit                          593055787  -[UICollectionViewData validateLayoutInRect:] + 72
 13 UIKit                          593054129  -[UICollectionView layoutSubviews] + 296
 14 Pinterest                      6408361    -[ASCollectionView layoutSubviews] (ASCollectionView.mm:1414)
 15 UIKit                          592666029  -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1290
 16 QuartzCore                     557094977  -[CALayer layoutSublayers] + 126
 17 Pinterest                      6249269    -[_ASDisplayLayer layoutSublayers] (_ASDisplayLayer.mm:132)
 18 QuartzCore                     557045647  CA::Layer::layout_if_needed(CA::Transaction*) + 354
 19 QuartzCore                     557045279  CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 16
 20 QuartzCore                     556589763  CA::Context::commit_transaction(CA::Transaction*) + 370
 21 QuartzCore                     556714933  CA::Transaction::commit() + 564
 22 UIKit                          597521413  __68+[UIScreen _beginDisableScreenUpdatesForSnapshotUsingSnapshotCover:]_block_invoke + 32
 23 UIKit                          595347643  -[UIApplication _performWithUICACommitStateSnapshotting:] + 738
 24 UIKit                          597521349  +[UIScreen _beginDisableScreenUpdatesForSnapshotUsingSnapshotCover:] + 426
 25 UIKit                          595713583  __73-[UIView resizableSnapshotViewFromRect:afterScreenUpdates:withCapInsets:]_block_invoke + 86
 26 UIKit                          595797737  +[_UIReplicantView _pendingSnapshotOfTarget:snapshotBlock:] + 398
 27 UIKit                          595713301  -[UIView resizableSnapshotViewFromRect:afterScreenUpdates:withCapInsets:] + 240
 28 UIKit                          595713051  -[UIView snapshotViewAfterScreenUpdates:] + 102
 29 Pinterest                      4973667    +[PIBasicLayoutTransitionController animateLayoutTransition:forNode:] (PIBasicLayoutTransitionController.m:33)
 30 Pinterest                      2754339    -[PIPinCloseupMetadataNode animateLayoutTransition:] (PIPinCloseupMetadataNode.m:388)

- It's not safe to hold the lock of a supernode and:
  - Edit states of its subnodes
  - Call subclass hooks
  - Run completion block
  - Run animation, which can trigger layout passes on subnodes, especially if one of them is a collection view.
@Adlai-Holler
Adlai-Holler merged commit 0f50cd0 into facebookarchive:master Mar 24, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants