mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-09-02 10:50:11 +00:00
We will revert #1023. The current solution introduces problems if we are unlocking before calling _completePendingLayoutTransition. _completePendingLayoutTransition needs to be happening in one transaction if called from _u_measureNodeWithBoundsIfNecessary.
This commit is contained in:
parent
ecfc7835da
commit
a34f45355e
@ -296,8 +296,6 @@ ASLayoutElementStyleExtensibilityForwarding
|
||||
{
|
||||
ASAssertUnlocked(__instanceLock__);
|
||||
|
||||
BOOL isInLayoutPendingState = NO;
|
||||
{
|
||||
ASDN::MutexLocker l(__instanceLock__);
|
||||
// Check if we are a subnode in a layout transition.
|
||||
// In this case no measurement is needed as it's part of the layout transition
|
||||
@ -410,11 +408,9 @@ ASLayoutElementStyleExtensibilityForwarding
|
||||
_pendingLayoutTransition = [[ASLayoutTransition alloc] initWithNode:self
|
||||
pendingLayout:nextLayout
|
||||
previousLayout:_calculatedDisplayNodeLayout];
|
||||
isInLayoutPendingState = ASHierarchyStateIncludesLayoutPending(_hierarchyState);
|
||||
}
|
||||
|
||||
// If a parent is currently executing a layout transition, perform our layout application after it.
|
||||
if (isInLayoutPendingState == NO) {
|
||||
if (ASHierarchyStateIncludesLayoutPending(_hierarchyState) == NO) {
|
||||
// If no transition, apply our new layout immediately (common case).
|
||||
[self _completePendingLayoutTransition];
|
||||
}
|
||||
@ -872,18 +868,12 @@ ASLayoutElementStyleExtensibilityForwarding
|
||||
*/
|
||||
- (void)_completePendingLayoutTransition
|
||||
{
|
||||
ASAssertUnlocked(__instanceLock__);
|
||||
|
||||
ASLayoutTransition *pendingLayoutTransition;
|
||||
{
|
||||
ASDN::MutexLocker l(__instanceLock__);
|
||||
pendingLayoutTransition = _pendingLayoutTransition;
|
||||
if (pendingLayoutTransition != nil) {
|
||||
[self _locked_setCalculatedDisplayNodeLayout:pendingLayoutTransition.pendingLayout];
|
||||
}
|
||||
}
|
||||
__instanceLock__.lock();
|
||||
ASLayoutTransition *pendingLayoutTransition = _pendingLayoutTransition;
|
||||
__instanceLock__.unlock();
|
||||
|
||||
if (pendingLayoutTransition != nil) {
|
||||
[self _setCalculatedDisplayNodeLayout:pendingLayoutTransition.pendingLayout];
|
||||
[self _completeLayoutTransition:pendingLayoutTransition];
|
||||
[self _pendingLayoutTransitionDidComplete];
|
||||
}
|
||||
@ -903,7 +893,8 @@ ASLayoutElementStyleExtensibilityForwarding
|
||||
// Trampoline to the main thread if necessary
|
||||
if (ASDisplayNodeThreadIsMain() || layoutTransition.isSynchronous == NO) {
|
||||
// Committing the layout transition will result in subnode insertions and removals, both of which must be called without the lock held
|
||||
ASAssertUnlocked(__instanceLock__);
|
||||
// TODO: Disabled due to PR: https://github.com/TextureGroup/Texture/pull/1204
|
||||
// ASAssertUnlocked(__instanceLock__);
|
||||
[layoutTransition commitTransition];
|
||||
} else {
|
||||
// Subnode insertions and removals need to happen always on the main thread if at least one subnode is already loaded
|
||||
@ -963,7 +954,8 @@ ASLayoutElementStyleExtensibilityForwarding
|
||||
#endif
|
||||
|
||||
// Subclass hook
|
||||
ASAssertUnlocked(__instanceLock__);
|
||||
// TODO: Disabled due to PR: https://github.com/TextureGroup/Texture/pull/1204
|
||||
// ASAssertUnlocked(__instanceLock__);
|
||||
[self calculatedLayoutDidChange];
|
||||
|
||||
// Grab lock after calling out to subclass
|
||||
|
@ -2215,7 +2215,8 @@ ASDISPLAYNODE_INLINE BOOL subtreeIsRasterized(ASDisplayNode *node) {
|
||||
- (void)_insertSubnode:(ASDisplayNode *)subnode atSubnodeIndex:(NSInteger)subnodeIndex sublayerIndex:(NSInteger)sublayerIndex andRemoveSubnode:(ASDisplayNode *)oldSubnode
|
||||
{
|
||||
ASDisplayNodeAssertThreadAffinity(self);
|
||||
ASAssertUnlocked(__instanceLock__);
|
||||
// TODO: Disabled due to PR: https://github.com/TextureGroup/Texture/pull/1204
|
||||
// ASAssertUnlocked(__instanceLock__);
|
||||
|
||||
as_log_verbose(ASNodeLog(), "Insert subnode %@ at index %zd of %@ and remove subnode %@", subnode, subnodeIndex, self, oldSubnode);
|
||||
|
||||
@ -2431,7 +2432,8 @@ ASDISPLAYNODE_INLINE BOOL subtreeIsRasterized(ASDisplayNode *node) {
|
||||
- (void)_insertSubnode:(ASDisplayNode *)subnode belowSubnode:(ASDisplayNode *)below
|
||||
{
|
||||
ASDisplayNodeAssertThreadAffinity(self);
|
||||
ASAssertUnlocked(__instanceLock__);
|
||||
// TODO: Disabled due to PR: https://github.com/TextureGroup/Texture/pull/1204
|
||||
// ASAssertUnlocked(__instanceLock__);
|
||||
|
||||
if (subnode == nil) {
|
||||
ASDisplayNodeFailAssert(@"Cannot insert a nil subnode");
|
||||
@ -2495,7 +2497,8 @@ ASDISPLAYNODE_INLINE BOOL subtreeIsRasterized(ASDisplayNode *node) {
|
||||
- (void)_insertSubnode:(ASDisplayNode *)subnode aboveSubnode:(ASDisplayNode *)above
|
||||
{
|
||||
ASDisplayNodeAssertThreadAffinity(self);
|
||||
ASAssertUnlocked(__instanceLock__);
|
||||
// TODO: Disabled due to PR: https://github.com/TextureGroup/Texture/pull/1204
|
||||
// ASAssertUnlocked(__instanceLock__);
|
||||
|
||||
if (subnode == nil) {
|
||||
ASDisplayNodeFailAssert(@"Cannot insert a nil subnode");
|
||||
@ -2557,7 +2560,8 @@ ASDISPLAYNODE_INLINE BOOL subtreeIsRasterized(ASDisplayNode *node) {
|
||||
- (void)_insertSubnode:(ASDisplayNode *)subnode atIndex:(NSInteger)idx
|
||||
{
|
||||
ASDisplayNodeAssertThreadAffinity(self);
|
||||
ASAssertUnlocked(__instanceLock__);
|
||||
// TODO: Disabled due to PR: https://github.com/TextureGroup/Texture/pull/1204
|
||||
// ASAssertUnlocked(__instanceLock__);
|
||||
|
||||
if (subnode == nil) {
|
||||
ASDisplayNodeFailAssert(@"Cannot insert a nil subnode");
|
||||
@ -2594,7 +2598,8 @@ ASDISPLAYNODE_INLINE BOOL subtreeIsRasterized(ASDisplayNode *node) {
|
||||
- (void)_removeSubnode:(ASDisplayNode *)subnode
|
||||
{
|
||||
ASDisplayNodeAssertThreadAffinity(self);
|
||||
ASAssertUnlocked(__instanceLock__);
|
||||
// TODO: Disabled due to PR: https://github.com/TextureGroup/Texture/pull/1204
|
||||
// ASAssertUnlocked(__instanceLock__);
|
||||
|
||||
// Don't call self.supernode here because that will retain/autorelease the supernode. This method -_removeSupernode: is often called while tearing down a node hierarchy, and the supernode in question might be in the middle of its -dealloc. The supernode is never messaged, only compared by value, so this is safe.
|
||||
// The particular issue that triggers this edge case is when a node calls -removeFromSupernode on a subnode from within its own -dealloc method.
|
||||
@ -2620,7 +2625,8 @@ ASDISPLAYNODE_INLINE BOOL subtreeIsRasterized(ASDisplayNode *node) {
|
||||
- (void)_removeFromSupernode
|
||||
{
|
||||
ASDisplayNodeAssertThreadAffinity(self);
|
||||
ASAssertUnlocked(__instanceLock__);
|
||||
// TODO: Disabled due to PR: https://github.com/TextureGroup/Texture/pull/1204
|
||||
// ASAssertUnlocked(__instanceLock__);
|
||||
|
||||
__instanceLock__.lock();
|
||||
__weak ASDisplayNode *supernode = _supernode;
|
||||
@ -2634,7 +2640,8 @@ ASDISPLAYNODE_INLINE BOOL subtreeIsRasterized(ASDisplayNode *node) {
|
||||
- (void)_removeFromSupernodeIfEqualTo:(ASDisplayNode *)supernode
|
||||
{
|
||||
ASDisplayNodeAssertThreadAffinity(self);
|
||||
ASAssertUnlocked(__instanceLock__);
|
||||
// TODO: Disabled due to PR: https://github.com/TextureGroup/Texture/pull/1204
|
||||
// ASAssertUnlocked(__instanceLock__);
|
||||
|
||||
__instanceLock__.lock();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user