Skip to content

Commit fb6d183

Browse files
nguyenhuyAdlai Holler
authored andcommitted
Beter table/collection update history (facebookarchive#2562)
- Introduce thread-safe ASEventLog - ASCollectionNode and ASTableNode share their event log with their ASDataController. The controller uses it to log change set submitting and finishing events. - ASCollectionNode and ASTableNode print their data source and delegate in their debug description.
1 parent 06f5754 commit fb6d183

22 files changed

Lines changed: 365 additions & 110 deletions

AsyncDisplayKit.xcodeproj/project.pbxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,10 @@
486486
E52405B31C8FEF03004DC8E7 /* ASLayoutTransition.mm in Sources */ = {isa = PBXBuildFile; fileRef = E52405B21C8FEF03004DC8E7 /* ASLayoutTransition.mm */; };
487487
E55D86321CA8A14000A0C26F /* ASLayoutElement.mm in Sources */ = {isa = PBXBuildFile; fileRef = E55D86311CA8A14000A0C26F /* ASLayoutElement.mm */; };
488488
E55D86331CA8A14000A0C26F /* ASLayoutElement.mm in Sources */ = {isa = PBXBuildFile; fileRef = E55D86311CA8A14000A0C26F /* ASLayoutElement.mm */; };
489+
E55FFC8F1DCCA50700060AC4 /* ASEventLog.h in Headers */ = {isa = PBXBuildFile; fileRef = E55FFC8E1DCCA50700060AC4 /* ASEventLog.h */; settings = {ATTRIBUTES = (Public, ); }; };
490+
E55FFC911DCCA5A600060AC4 /* ASEventLog.mm in Sources */ = {isa = PBXBuildFile; fileRef = E55FFC901DCCA5A600060AC4 /* ASEventLog.mm */; };
491+
E55FFC921DCCA5A600060AC4 /* ASEventLog.mm in Sources */ = {isa = PBXBuildFile; fileRef = E55FFC901DCCA5A600060AC4 /* ASEventLog.mm */; };
492+
E55FFC931DCCB0A800060AC4 /* ASEventLog.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = E55FFC8E1DCCA50700060AC4 /* ASEventLog.h */; };
489493
E5711A2C1C840C81009619D4 /* ASIndexedNodeContext.h in Headers */ = {isa = PBXBuildFile; fileRef = E5711A2A1C840C81009619D4 /* ASIndexedNodeContext.h */; };
490494
E5711A2E1C840C96009619D4 /* ASIndexedNodeContext.mm in Sources */ = {isa = PBXBuildFile; fileRef = E5711A2D1C840C96009619D4 /* ASIndexedNodeContext.mm */; };
491495
E5711A301C840C96009619D4 /* ASIndexedNodeContext.mm in Sources */ = {isa = PBXBuildFile; fileRef = E5711A2D1C840C96009619D4 /* ASIndexedNodeContext.mm */; };
@@ -658,6 +662,7 @@
658662
dstPath = "include/$(PRODUCT_NAME)";
659663
dstSubfolderSpec = 16;
660664
files = (
665+
E55FFC931DCCB0A800060AC4 /* ASEventLog.h in CopyFiles */,
661666
693117CE1DC7C72700DE4784 /* ASDisplayNode+Deprecated.h in CopyFiles */,
662667
69F381A51DA4630D00CF2278 /* NSArray+Diffing.h in CopyFiles */,
663668
CC4C2A7A1D8902350039ACAB /* ASTraceEvent.h in CopyFiles */,
@@ -1168,6 +1173,8 @@
11681173
E52405B21C8FEF03004DC8E7 /* ASLayoutTransition.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASLayoutTransition.mm; sourceTree = "<group>"; };
11691174
E52405B41C8FEF16004DC8E7 /* ASLayoutTransition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASLayoutTransition.h; sourceTree = "<group>"; };
11701175
E55D86311CA8A14000A0C26F /* ASLayoutElement.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ASLayoutElement.mm; path = AsyncDisplayKit/Layout/ASLayoutElement.mm; sourceTree = "<group>"; };
1176+
E55FFC8E1DCCA50700060AC4 /* ASEventLog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASEventLog.h; sourceTree = "<group>"; };
1177+
E55FFC901DCCA5A600060AC4 /* ASEventLog.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASEventLog.mm; sourceTree = "<group>"; };
11711178
E5711A2A1C840C81009619D4 /* ASIndexedNodeContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIndexedNodeContext.h; sourceTree = "<group>"; };
11721179
E5711A2D1C840C96009619D4 /* ASIndexedNodeContext.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASIndexedNodeContext.mm; sourceTree = "<group>"; };
11731180
EFA731F0396842FF8AB635EE /* libPods-AsyncDisplayKitTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-AsyncDisplayKitTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -1583,6 +1590,8 @@
15831590
6959433C1D70815300B0EE1F /* ASDisplayNodeLayout.mm */,
15841591
69E100691CA89CB600D88C1B /* ASEnvironmentInternal.h */,
15851592
69E1006A1CA89CB600D88C1B /* ASEnvironmentInternal.mm */,
1593+
E55FFC8E1DCCA50700060AC4 /* ASEventLog.h */,
1594+
E55FFC901DCCA5A600060AC4 /* ASEventLog.mm */,
15861595
68B8A4DB1CBD911D007E4543 /* ASImageNode+AnimatedImagePrivate.h */,
15871596
058D0A0D195D050800B7D73C /* ASImageNode+CGExtras.h */,
15881597
058D0A0E195D050800B7D73C /* ASImageNode+CGExtras.m */,
@@ -1765,6 +1774,7 @@
17651774
isa = PBXHeadersBuildPhase;
17661775
buildActionMask = 2147483647;
17671776
files = (
1777+
E55FFC8F1DCCA50700060AC4 /* ASEventLog.h in Headers */,
17681778
683489281D70DE3400327501 /* ASDisplayNode+Deprecated.h in Headers */,
17691779
6907C2581DC4ECFE00374C66 /* ASObjectDescriptionHelpers.h in Headers */,
17701780
69E0E8A71D356C9400627613 /* ASEqualityHelpers.h in Headers */,
@@ -2235,6 +2245,7 @@
22352245
E5711A2E1C840C96009619D4 /* ASIndexedNodeContext.mm in Sources */,
22362246
9C8221971BA237B80037F19A /* ASStackBaselinePositionedLayout.mm in Sources */,
22372247
251B8EF81BBB3D690087C538 /* ASCollectionDataController.mm in Sources */,
2248+
E55FFC911DCCA5A600060AC4 /* ASEventLog.mm in Sources */,
22382249
ACF6ED301B17843500DA7C62 /* ASStackLayoutSpec.mm in Sources */,
22392250
257754BE1BEE458E00737CA5 /* ASTextKitComponents.m in Sources */,
22402251
257754A91BEE44CD00737CA5 /* ASTextKitContext.mm in Sources */,
@@ -2422,6 +2433,7 @@
24222433
254C6B851BF94F8A003EC431 /* ASTextKitAttributes.mm in Sources */,
24232434
509E68601B3AED8E009B9150 /* ASScrollDirection.m in Sources */,
24242435
B35062091B010EFD0018CF92 /* ASScrollNode.m in Sources */,
2436+
E55FFC921DCCA5A600060AC4 /* ASEventLog.mm in Sources */,
24252437
9C8221981BA237B80037F19A /* ASStackBaselinePositionedLayout.mm in Sources */,
24262438
8BDA5FC81CDBDF95007D13B2 /* ASVideoPlayerNode.mm in Sources */,
24272439
34EFC7721B701D0300AD841F /* ASStackLayoutSpec.mm in Sources */,

AsyncDisplayKit/ASCollectionNode.mm

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#import "ASCollectionInternal.h"
1414
#import "ASCollectionViewLayoutFacilitatorProtocol.h"
1515
#import "ASCollectionNode.h"
16+
#import "ASDisplayNodeInternal.h"
1617
#import "ASDisplayNode+Subclasses.h"
1718
#import "ASEnvironmentInternal.h"
1819
#import "ASInternalHelpers.h"
@@ -121,7 +122,7 @@ - (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionVi
121122
- (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout layoutFacilitator:(id<ASCollectionViewLayoutFacilitatorProtocol>)layoutFacilitator
122123
{
123124
ASDisplayNodeViewBlock collectionViewBlock = ^UIView *{
124-
return [[ASCollectionView alloc] _initWithFrame:frame collectionViewLayout:layout layoutFacilitator:layoutFacilitator];
125+
return [[ASCollectionView alloc] _initWithFrame:frame collectionViewLayout:layout layoutFacilitator:layoutFacilitator eventLog:ASDisplayNodeGetEventLog(self)];
125126
};
126127

127128
if (self = [super initWithViewBlock:collectionViewBlock]) {
@@ -561,4 +562,14 @@ - (void)updateCurrentRangeWithMode:(ASLayoutRangeMode)rangeMode;
561562

562563
ASEnvironmentCollectionTableSetEnvironmentState(_environmentStateLock)
563564

565+
#pragma mark - Debugging (Private)
566+
567+
- (NSMutableArray<NSDictionary *> *)propertiesForDebugDescription
568+
{
569+
NSMutableArray<NSDictionary *> *result = [super propertiesForDebugDescription];
570+
[result addObject:@{ @"dataSource" : ASObjectDescriptionMakeTiny(self.dataSource) }];
571+
[result addObject:@{ @"delegate" : ASObjectDescriptionMakeTiny(self.delegate) }];
572+
return result;
573+
}
574+
564575
@end

AsyncDisplayKit/ASCollectionView.mm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,10 @@ - (instancetype)initWithCollectionViewLayout:(UICollectionViewLayout *)layout
244244

245245
- (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout
246246
{
247-
return [self _initWithFrame:frame collectionViewLayout:layout layoutFacilitator:nil];
247+
return [self _initWithFrame:frame collectionViewLayout:layout layoutFacilitator:nil eventLog:nil];
248248
}
249249

250-
- (instancetype)_initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout layoutFacilitator:(id<ASCollectionViewLayoutFacilitatorProtocol>)layoutFacilitator
250+
- (instancetype)_initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout layoutFacilitator:(id<ASCollectionViewLayoutFacilitatorProtocol>)layoutFacilitator eventLog:(ASEventLog *)eventLog
251251
{
252252
if (!(self = [super initWithFrame:frame collectionViewLayout:layout]))
253253
return nil;
@@ -259,7 +259,7 @@ - (instancetype)_initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionV
259259
_rangeController.delegate = self;
260260
_rangeController.layoutController = _layoutController;
261261

262-
_dataController = [[ASCollectionDataController alloc] initWithDataSource:self];
262+
_dataController = [[ASCollectionDataController alloc] initWithDataSource:self eventLog:eventLog];
263263
_dataController.delegate = _rangeController;
264264
_dataController.environmentDelegate = self;
265265

AsyncDisplayKit/ASDisplayNode+Beta.h

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#import "ASDisplayNode.h"
1212
#import "ASLayoutRangeType.h"
13-
#import "ASTraceEvent.h"
13+
#import "ASEventLog.h"
1414

1515
NS_ASSUME_NONNULL_BEGIN
1616

@@ -19,18 +19,16 @@ void ASPerformBlockOnMainThread(void (^block)());
1919
void ASPerformBlockOnBackgroundThread(void (^block)()); // DISPATCH_QUEUE_PRIORITY_DEFAULT
2020
ASDISPLAYNODE_EXTERN_C_END
2121

22-
#ifndef ASDISPLAYNODE_EVENTLOG_CAPACITY
23-
#define ASDISPLAYNODE_EVENTLOG_CAPACITY 20
24-
#endif
25-
26-
#ifndef ASDISPLAYNODE_EVENTLOG_ENABLE
27-
#define ASDISPLAYNODE_EVENTLOG_ENABLE DEBUG
22+
#if ASEVENTLOG_ENABLE
23+
#define ASDisplayNodeLogEvent(node, ...) [node.eventLog logEventWithBacktrace:[NSThread callStackSymbols] format:__VA_ARGS__]
24+
#else
25+
#define ASDisplayNodeLogEvent(node, ...)
2826
#endif
2927

30-
#if ASDISPLAYNODE_EVENTLOG_ENABLE
31-
#define ASDisplayNodeLogEvent(node, ...) [node _logEventWithBacktrace:[NSThread callStackSymbols] format:__VA_ARGS__]
28+
#if ASEVENTLOG_ENABLE
29+
#define ASDisplayNodeGetEventLog(node) node.eventLog
3230
#else
33-
#define ASDisplayNodeLogEvent(node, ...)
31+
#define ASDisplayNodeGetEventLog(node) nil
3432
#endif
3533

3634
/**
@@ -94,6 +92,13 @@ typedef struct {
9492
*/
9593
@property (nonatomic, assign, readonly) ASDisplayNodePerformanceMeasurements performanceMeasurements;
9694

95+
#if ASEVENTLOG_ENABLE
96+
/*
97+
* @abstract The primitive event tracing object. You shouldn't directly use it to log event. Use the ASDisplayNodeLogEvent macro instead.
98+
*/
99+
@property (nonatomic, strong, readonly) ASEventLog *eventLog;
100+
#endif
101+
97102
/**
98103
* @abstract Currently used by ASNetworkImageNode and ASMultiplexImageNode to allow their placeholders to stay if they are loading an image from the network.
99104
* Otherwise, a display pass is scheduled and completes, but does not actually draw anything - and ASDisplayNode considers the element finished.
@@ -118,20 +123,6 @@ typedef struct {
118123
*/
119124
+ (void)setRangeModeForMemoryWarnings:(ASLayoutRangeMode)rangeMode;
120125

121-
#if ASDISPLAYNODE_EVENTLOG_ENABLE
122-
123-
/**
124-
* The primitive event tracing method. You shouldn't call this. Use the ASDisplayNodeLogEvent macro instead.
125-
*/
126-
- (void)_logEventWithBacktrace:(NSArray<NSString *> *)backtrace format:(NSString *)format, ... NS_FORMAT_FUNCTION(2, 3);
127-
128-
/**
129-
* @abstract The most recent trace events for this node. Max count is ASDISPLAYNODE_EVENTLOG_CAPACITY.
130-
*/
131-
@property (readonly, copy) NSArray *eventLog;
132-
133-
#endif
134-
135126
@end
136127

137128
NS_ASSUME_NONNULL_END

AsyncDisplayKit/ASDisplayNode.mm

Lines changed: 12 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,11 @@ - (void)_staticInitialize
300300
- (void)_initializeInstance
301301
{
302302
[self _staticInitialize];
303-
_eventLogHead = -1;
303+
304+
#if ASEVENTLOG_ENABLE
305+
_eventLog = [[ASEventLog alloc] init];
306+
#endif
307+
304308
_contentsScaleForDisplay = ASScreenScale();
305309

306310
_environmentState = ASEnvironmentStateMakeDefault();
@@ -575,51 +579,6 @@ - (void)_loadViewOrLayerIsLayerBacked:(BOOL)isLayerBacked
575579
}
576580
}
577581

578-
#if ASDISPLAYNODE_EVENTLOG_ENABLE
579-
- (void)_logEventWithBacktrace:(NSArray<NSString *> *)backtrace format:(NSString *)format, ...
580-
{
581-
va_list args;
582-
va_start(args, format);
583-
ASTraceEvent *event = [[ASTraceEvent alloc] initWithObject:self
584-
backtrace:backtrace
585-
format:format
586-
arguments:args];
587-
va_end(args);
588-
589-
ASDN::MutexLocker l(__instanceLock__);
590-
// Create the array if needed.
591-
if (_eventLog == nil) {
592-
_eventLog = [NSMutableArray arrayWithCapacity:ASDISPLAYNODE_EVENTLOG_CAPACITY];
593-
}
594-
595-
// Increment the head index.
596-
_eventLogHead = (_eventLogHead + 1) % ASDISPLAYNODE_EVENTLOG_CAPACITY;
597-
if (_eventLogHead < _eventLog.count) {
598-
[_eventLog replaceObjectAtIndex:_eventLogHead withObject:event];
599-
} else {
600-
[_eventLog insertObject:event atIndex:_eventLogHead];
601-
}
602-
}
603-
604-
- (NSArray<ASTraceEvent *> *)eventLog
605-
{
606-
ASDN::MutexLocker l(__instanceLock__);
607-
NSUInteger tail = (_eventLogHead + 1);
608-
NSUInteger count = _eventLog.count;
609-
610-
NSMutableArray<ASTraceEvent *> *result = [NSMutableArray array];
611-
612-
// Start from `tail` and go through array, wrapping around when we exceed end index.
613-
for (NSUInteger actualIndex = 0; actualIndex < ASDISPLAYNODE_EVENTLOG_CAPACITY; actualIndex++) {
614-
NSInteger ringIndex = (tail + actualIndex) % ASDISPLAYNODE_EVENTLOG_CAPACITY;
615-
if (ringIndex < count) {
616-
[result addObject:_eventLog[ringIndex]];
617-
}
618-
}
619-
return result;
620-
}
621-
#endif
622-
623582
- (UIView *)view
624583
{
625584
ASDisplayNodeAssert(!_flags.layerBacked, @"Call to -view undefined on layer-backed nodes");
@@ -3344,6 +3303,13 @@ - (void)setInHierarchy:(BOOL)inHierarchy
33443303

33453304
#pragma mark Debugging (Private)
33463305

3306+
#if ASEVENTLOG_ENABLE
3307+
- (ASEventLog *)eventLog
3308+
{
3309+
return _eventLog;
3310+
}
3311+
#endif
3312+
33473313
- (NSMutableArray<NSDictionary *> *)propertiesForDescription
33483314
{
33493315
NSMutableArray<NSDictionary *> *result = [NSMutableArray array];

AsyncDisplayKit/ASTableNode.mm

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#import "ASTableNode.h"
1414
#import "ASTableViewInternal.h"
1515
#import "ASEnvironmentInternal.h"
16+
#import "ASDisplayNodeInternal.h"
1617
#import "ASDisplayNode+Subclasses.h"
1718
#import "ASInternalHelpers.h"
1819
#import "ASCellNode+Internal.h"
@@ -79,7 +80,7 @@ - (instancetype)_initWithTableView:(ASTableView *)tableView
7980
- (instancetype)_initWithFrame:(CGRect)frame style:(UITableViewStyle)style dataControllerClass:(Class)dataControllerClass
8081
{
8182
ASDisplayNodeViewBlock tableViewBlock = ^UIView *{
82-
return [[ASTableView alloc] _initWithFrame:frame style:style dataControllerClass:dataControllerClass];
83+
return [[ASTableView alloc] _initWithFrame:frame style:style dataControllerClass:dataControllerClass eventLog:ASDisplayNodeGetEventLog(self)];
8384
};
8485

8586
if (self = [super initWithViewBlock:tableViewBlock]) {
@@ -574,4 +575,14 @@ - (void)waitUntilAllUpdatesAreCommitted
574575
[self.view waitUntilAllUpdatesAreCommitted];
575576
}
576577

578+
#pragma mark - Debugging (Private)
579+
580+
- (NSMutableArray<NSDictionary *> *)propertiesForDebugDescription
581+
{
582+
NSMutableArray<NSDictionary *> *result = [super propertiesForDebugDescription];
583+
[result addObject:@{ @"dataSource" : ASObjectDescriptionMakeTiny(self.dataSource) }];
584+
[result addObject:@{ @"delegate" : ASObjectDescriptionMakeTiny(self.delegate) }];
585+
return result;
586+
}
587+
577588
@end

AsyncDisplayKit/ASTableView.mm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ + (Class)dataControllerClass
212212
#pragma mark -
213213
#pragma mark Lifecycle
214214

215-
- (void)configureWithDataControllerClass:(Class)dataControllerClass
215+
- (void)configureWithDataControllerClass:(Class)dataControllerClass eventLog:(ASEventLog *)eventLog
216216
{
217217
_layoutController = [[ASFlowLayoutController alloc] initWithScrollOption:ASFlowLayoutDirectionVertical];
218218

@@ -221,7 +221,7 @@ - (void)configureWithDataControllerClass:(Class)dataControllerClass
221221
_rangeController.dataSource = self;
222222
_rangeController.delegate = self;
223223

224-
_dataController = [[dataControllerClass alloc] initWithDataSource:self];
224+
_dataController = [[dataControllerClass alloc] initWithDataSource:self eventLog:eventLog];
225225
_dataController.delegate = _rangeController;
226226
_dataController.environmentDelegate = self;
227227

@@ -248,10 +248,10 @@ - (void)configureWithDataControllerClass:(Class)dataControllerClass
248248

249249
- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style
250250
{
251-
return [self _initWithFrame:frame style:style dataControllerClass:nil];
251+
return [self _initWithFrame:frame style:style dataControllerClass:nil eventLog:nil];
252252
}
253253

254-
- (instancetype)_initWithFrame:(CGRect)frame style:(UITableViewStyle)style dataControllerClass:(Class)dataControllerClass
254+
- (instancetype)_initWithFrame:(CGRect)frame style:(UITableViewStyle)style dataControllerClass:(Class)dataControllerClass eventLog:(ASEventLog *)eventLog
255255
{
256256
if (!(self = [super initWithFrame:frame style:style])) {
257257
return nil;
@@ -261,7 +261,7 @@ - (instancetype)_initWithFrame:(CGRect)frame style:(UITableViewStyle)style dataC
261261
dataControllerClass = [[self class] dataControllerClass];
262262
}
263263

264-
[self configureWithDataControllerClass:dataControllerClass];
264+
[self configureWithDataControllerClass:dataControllerClass eventLog:eventLog];
265265

266266
if (!AS_AT_LEAST_IOS9) {
267267
_retainedLayer = self.layer;

AsyncDisplayKit/ASTableViewInternal.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@
3131
* @param style A constant that specifies the style of the table view. See UITableViewStyle for descriptions of valid constants.
3232
*
3333
* @param dataControllerClass A controller class injected to and used to create a data controller for the table view.
34+
*
35+
* @param eventLog An event log passed through to the data controller.
3436
*/
35-
- (instancetype)_initWithFrame:(CGRect)frame style:(UITableViewStyle)style dataControllerClass:(Class)dataControllerClass;
37+
- (instancetype)_initWithFrame:(CGRect)frame style:(UITableViewStyle)style dataControllerClass:(Class)dataControllerClass eventLog:(ASEventLog *)eventLog;
3638

3739
/// Set YES and we'll log every time we call [super insertRows…] etc
3840
@property (nonatomic) BOOL test_enableSuperUpdateCallLogging;

AsyncDisplayKit/Details/ASChangeSetDataController.mm

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ - (void)endUpdatesAnimated:(BOOL)animated completion:(void (^)(BOOL))completion
4747

4848
[_changeSet addCompletionHandler:completion];
4949
if (_changeSetBatchUpdateCounter == 0) {
50-
void (^batchCompletion)(BOOL finished) = _changeSet.completionHandler;
50+
void (^batchCompletion)(BOOL) = _changeSet.completionHandler;
5151

5252
/**
5353
* If the initial reloadData has not been called, just bail because we don't have
@@ -66,6 +66,8 @@ - (void)endUpdatesAnimated:(BOOL)animated completion:(void (^)(BOOL))completion
6666
[self invalidateDataSourceItemCounts];
6767
[_changeSet markCompletedWithNewItemCounts:[self itemCountsFromDataSource]];
6868

69+
ASDataControllerLogEvent(self, @"triggeredUpdate: %@", _changeSet);
70+
6971
[super beginUpdates];
7072

7173
for (_ASHierarchyItemChange *change in [_changeSet itemChangesOfType:_ASHierarchyChangeTypeDelete]) {
@@ -84,6 +86,16 @@ - (void)endUpdatesAnimated:(BOOL)animated completion:(void (^)(BOOL))completion
8486
[super insertRowsAtIndexPaths:change.indexPaths withAnimationOptions:change.animationOptions];
8587
}
8688

89+
#if ASEVENTLOG_ENABLE
90+
NSString *changeSetDescription = ASObjectDescriptionMakeTiny(_changeSet);
91+
batchCompletion = ^(BOOL finished) {
92+
if (batchCompletion != nil) {
93+
batchCompletion(finished);
94+
}
95+
ASDataControllerLogEvent(self, @"finishedUpdate: %@", changeSetDescription);
96+
};
97+
#endif
98+
8799
[super endUpdatesAnimated:animated completion:batchCompletion];
88100

89101
_changeSet = nil;

AsyncDisplayKit/Details/ASCollectionDataController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ NS_ASSUME_NONNULL_BEGIN
4343

4444
@interface ASCollectionDataController : ASChangeSetDataController
4545

46-
- (instancetype)initWithDataSource:(id<ASCollectionDataControllerSource>)dataSource NS_DESIGNATED_INITIALIZER;
46+
- (instancetype)initWithDataSource:(id<ASCollectionDataControllerSource>)dataSource eventLog:(nullable ASEventLog *)eventLog NS_DESIGNATED_INITIALIZER;
4747

4848
- (ASCellNode *)supplementaryNodeOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath;
4949

0 commit comments

Comments
 (0)