mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-11 08:50:24 +00:00
Fix recursive description of ASDisplayNode (#3186)
- Before this commit: - Bridged properties are accessed to construct a recursive description without considering thread affinity. - We have multiple methods that does the same thing: generates a debug description. - After this commit: - Bridged properties are accessed without triggering thread affinity assertions. - We have only one method that provides debug description of a node. It is then used to construct a recursive description.
This commit is contained in:
parent
ef2ed54d0b
commit
7a11c4b32b
@ -3972,10 +3972,13 @@ ASDISPLAYNODE_INLINE BOOL nodeIsInRasterizedTree(ASDisplayNode *node) {
|
||||
}
|
||||
|
||||
if (_view != nil) {
|
||||
[result addObject:@{ @"alpha" : @(_view.alpha) }];
|
||||
[result addObject:@{ @"frame" : [NSValue valueWithCGRect:_view.frame] }];
|
||||
} else if (_layer != nil) {
|
||||
[result addObject:@{ @"alpha" : @(_layer.opacity) }];
|
||||
[result addObject:@{ @"frame" : [NSValue valueWithCGRect:_layer.frame] }];
|
||||
} else if (_pendingViewState != nil) {
|
||||
[result addObject:@{ @"alpha" : @(_pendingViewState.alpha) }];
|
||||
[result addObject:@{ @"frame" : [NSValue valueWithCGRect:_pendingViewState.frame] }];
|
||||
}
|
||||
|
||||
@ -4000,6 +4003,11 @@ ASDISPLAYNODE_INLINE BOOL nodeIsInRasterizedTree(ASDisplayNode *node) {
|
||||
} else if (_layerBlock != nil) {
|
||||
[result addObject:@{ @"layerBlock" : _layerBlock }];
|
||||
}
|
||||
|
||||
#if TIME_DISPLAYNODE_OPS
|
||||
NSString *creationTypeString = [NSString stringWithFormat:@"cr8:%.2lfms dl:%.2lfms ap:%.2lfms ad:%.2lfms", 1000 * _debugTimeToCreateView, 1000 * _debugTimeForDidLoad, 1000 * _debugTimeToApplyPendingState, 1000 * _debugTimeToAddSubnodeViews];
|
||||
[result addObject:@{ @"creationTypeString" : creationTypeString }];
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -4140,16 +4148,6 @@ ASLayoutElementStyleExtensibilityForwarding
|
||||
|
||||
@implementation ASDisplayNode (Debugging)
|
||||
|
||||
- (NSString *)descriptionForRecursiveDescription
|
||||
{
|
||||
NSString *creationTypeString = nil;
|
||||
#if TIME_DISPLAYNODE_OPS
|
||||
creationTypeString = [NSString stringWithFormat:@"cr8:%.2lfms dl:%.2lfms ap:%.2lfms ad:%.2lfms", 1000 * _debugTimeToCreateView, 1000 * _debugTimeForDidLoad, 1000 * _debugTimeToApplyPendingState, 1000 * _debugTimeToAddSubnodeViews];
|
||||
#endif
|
||||
|
||||
return [NSString stringWithFormat:@"<%@ alpha:%.2f isLayerBacked:%d frame:%@ %@>", self.description, self.alpha, self.isLayerBacked, NSStringFromCGRect(self.frame), creationTypeString];
|
||||
}
|
||||
|
||||
- (NSString *)displayNodeRecursiveDescription
|
||||
{
|
||||
return [self _recursiveDescriptionHelperWithIndent:@""];
|
||||
@ -4157,7 +4155,7 @@ ASLayoutElementStyleExtensibilityForwarding
|
||||
|
||||
- (NSString *)_recursiveDescriptionHelperWithIndent:(NSString *)indent
|
||||
{
|
||||
NSMutableString *subtree = [[[indent stringByAppendingString: self.descriptionForRecursiveDescription] stringByAppendingString:@"\n"] mutableCopy];
|
||||
NSMutableString *subtree = [[[indent stringByAppendingString:self.debugDescription] stringByAppendingString:@"\n"] mutableCopy];
|
||||
for (ASDisplayNode *n in self.subnodes) {
|
||||
[subtree appendString:[n _recursiveDescriptionHelperWithIndent:[indent stringByAppendingString:@" | "]]];
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user