Skip to content

Commit

Permalink
Revert "Add experiments to skip waiting for updates of collection and…
Browse files Browse the repository at this point in the history
… table views under some circumstances (TextureGroup#1311)"
  • Loading branch information
wiseoldduck committed Jun 25, 2019
1 parent a8adc23 commit c19b190
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
7 changes: 2 additions & 5 deletions Source/ASCollectionView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1911,10 +1911,7 @@ - (BOOL)dataController:(ASDataController *)dataController shouldSynchronouslyPro
if (ASCellLayoutModeIncludes(ASCellLayoutModeAlwaysAsync)) {
return NO;
}
// Reload data is expensive, don't block main while doing so.
if (changeSet.includesReloadData) {
return NO;
}
// The heuristics below apply to the ASCellLayoutModeNone.
// If we have very few ASCellNodes (besides UIKit passthrough ones), match UIKit by blocking.
if (changeSet.countForAsyncLayout < 2) {
return YES;
Expand All @@ -1924,7 +1921,7 @@ - (BOOL)dataController:(ASDataController *)dataController shouldSynchronouslyPro
if (contentSize.height <= boundsSize.height && contentSize.width <= boundsSize.width) {
return YES;
}
return NO; // ASCellLayoutModeNone
return NO;
}

- (BOOL)dataControllerShouldSerializeNodeCreation:(ASDataController *)dataController
Expand Down
12 changes: 6 additions & 6 deletions Tests/ASCollectionViewTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ - (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibB
@interface ASCollectionView (InternalTesting)

- (NSArray<NSString *> *)dataController:(ASDataController *)dataController supplementaryNodeKindsInSections:(NSIndexSet *)sections;
- (BOOL)dataController:(ASDataController *)dataController shouldSynchronouslyProcessChangeSet:(_ASHierarchyChangeSet *)changeSet;

@end

Expand Down Expand Up @@ -1046,18 +1047,15 @@ - (void)_primitiveBatchFetchingFillTestAnimated:(BOOL)animated visible:(BOOL)vis

- (void)testInitialRangeBounds
{
[self testInitialRangeBoundsWithCellLayoutMode:ASCellLayoutModeNone
shouldWaitUntilAllUpdatesAreProcessed:YES];
[self testInitialRangeBoundsWithCellLayoutMode:ASCellLayoutModeNone];
}

- (void)testInitialRangeBoundsCellLayoutModeAlwaysAsync
{
[self testInitialRangeBoundsWithCellLayoutMode:ASCellLayoutModeAlwaysAsync
shouldWaitUntilAllUpdatesAreProcessed:YES];
[self testInitialRangeBoundsWithCellLayoutMode:ASCellLayoutModeAlwaysAsync];
}

- (void)testInitialRangeBoundsWithCellLayoutMode:(ASCellLayoutMode)cellLayoutMode
shouldWaitUntilAllUpdatesAreProcessed:(BOOL)shouldWait
{
UIWindow *window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
ASCollectionViewTestController *testController = [[ASCollectionViewTestController alloc] initWithNibName:nil bundle:nil];
Expand All @@ -1073,7 +1071,9 @@ - (void)testInitialRangeBoundsWithCellLayoutMode:(ASCellLayoutMode)cellLayoutMod
// Trigger the initial reload to start
[window layoutIfNeeded];

if (shouldWait) {
// Test the APIs that monitor ASCollectionNode update handling if collection node should
// layout asynchronously
if (![cn.view dataController:nil shouldSynchronouslyProcessChangeSet:nil]) {
XCTAssertTrue(cn.isProcessingUpdates, @"ASCollectionNode should still be processing updates after initial layoutIfNeeded call (reloadData)");

[cn onDidFinishProcessingUpdates:^{
Expand Down

0 comments on commit c19b190

Please sign in to comment.