Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add experiments to skip waiting for updates of collection and table views #1311

Merged
merged 10 commits into from
Jan 24, 2019
7 changes: 5 additions & 2 deletions Schemas/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@
"exp_unfair_lock",
"exp_infer_layer_defaults",
"exp_network_image_queue",
"exp_dealloc_queue_v2",
"exp_collection_teardown",
"exp_framesetter_cache",
"exp_skip_clear_data"
"exp_skip_clear_data",
"exp_did_enter_preload_skip_asm_layout",
"exp_disable_a11y_cache",
"exp_skip_a11y_wait",
"exp_skip_default_cell_layout_mode"
]
}
}
Expand Down
26 changes: 17 additions & 9 deletions Source/ASCollectionView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1869,14 +1869,20 @@ - (BOOL)dataController:(ASDataController *)dataController shouldSynchronouslyPro
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;
}
CGSize contentSize = self.contentSize;
CGSize boundsSize = self.bounds.size;
if (contentSize.height <= boundsSize.height && contentSize.width <= boundsSize.width) {
return YES;
if (!ASActivateExperimentalFeature(ASExperimentalSkipDefaultCellLayoutMode)) {
// Reload data is expensive, don't block main while doing so.
if (changeSet.includesReloadData) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this check because countForAsyncLayout doesn't account for reload data.

return NO;
}
// If we have very few ASCellNodes (besides UIKit passthrough ones), match UIKit by blocking.
if (changeSet.countForAsyncLayout < 2) {
return YES;
}
CGSize contentSize = self.contentSize;
CGSize boundsSize = self.bounds.size;
if (contentSize.height <= boundsSize.height && contentSize.width <= boundsSize.width) {
return YES;
}
}
return NO;
}
Expand Down Expand Up @@ -2465,7 +2471,9 @@ - (void)setPrefetchingEnabled:(BOOL)prefetchingEnabled

- (NSArray *)accessibilityElements
{
[self waitUntilAllUpdatesAreCommitted];
if (!ASActivateExperimentalFeature(ASExperimentalSkipAccessibilityWait)) {
[self waitUntilAllUpdatesAreCommitted];
}
return [super accessibilityElements];
}

Expand Down
2 changes: 2 additions & 0 deletions Source/ASExperimentalFeatures.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ typedef NS_OPTIONS(NSUInteger, ASExperimentalFeatures) {
ASExperimentalSkipClearData = 1 << 8, // exp_skip_clear_data
ASExperimentalDidEnterPreloadSkipASMLayout = 1 << 9, // exp_did_enter_preload_skip_asm_layout
ASExperimentalDisableAccessibilityCache = 1 << 10, // exp_disable_a11y_cache
ASExperimentalSkipAccessibilityWait = 1 << 11, // exp_skip_a11y_wait
ASExperimentalSkipDefaultCellLayoutMode = 1 << 12, // exp_skip_default_cell_layout_mode
ASExperimentalFeatureAll = 0xFFFFFFFF
};

Expand Down
4 changes: 3 additions & 1 deletion Source/ASExperimentalFeatures.mm
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
@"exp_framesetter_cache",
@"exp_skip_clear_data",
@"exp_did_enter_preload_skip_asm_layout",
@"exp_disable_a11y_cache"]));
@"exp_disable_a11y_cache",
@"exp_skip_a11y_wait",
@"exp_skip_default_cell_layout_mode"]));

if (flags == ASExperimentalFeatureAll) {
return allNames;
Expand Down
26 changes: 17 additions & 9 deletions Source/ASTableView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1677,14 +1677,20 @@ - (BOOL)dataControllerShouldSerializeNodeCreation:(ASDataController *)dataContro

- (BOOL)dataController:(ASDataController *)dataController shouldSynchronouslyProcessChangeSet:(_ASHierarchyChangeSet *)changeSet
{
// For more details on this method, see the comment in the ASCollectionView implementation.
if (changeSet.countForAsyncLayout < 2) {
return YES;
}
CGSize contentSize = self.contentSize;
CGSize boundsSize = self.bounds.size;
if (contentSize.height <= boundsSize.height && contentSize.width <= boundsSize.width) {
return YES;
if (!ASActivateExperimentalFeature(ASExperimentalSkipDefaultCellLayoutMode)) {
// Reload data is expensive, don't block main while doing so.
if (changeSet.includesReloadData) {
return NO;
}
// For more details on this method, see the comment in the ASCollectionView implementation.
if (changeSet.countForAsyncLayout < 2) {
return YES;
}
CGSize contentSize = self.contentSize;
CGSize boundsSize = self.bounds.size;
if (contentSize.height <= boundsSize.height && contentSize.width <= boundsSize.width) {
return YES;
}
}
return NO;
}
Expand Down Expand Up @@ -2004,7 +2010,9 @@ - (void)didMoveToSuperview

- (NSArray *)accessibilityElements
{
[self waitUntilAllUpdatesAreCommitted];
if (!ASActivateExperimentalFeature(ASExperimentalSkipAccessibilityWait)) {
[self waitUntilAllUpdatesAreCommitted];
}
return [super accessibilityElements];
}

Expand Down
8 changes: 6 additions & 2 deletions Tests/ASConfigurationTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
ASExperimentalFramesetterCache,
ASExperimentalSkipClearData,
ASExperimentalDidEnterPreloadSkipASMLayout,
ASExperimentalDisableAccessibilityCache
ASExperimentalDisableAccessibilityCache,
ASExperimentalSkipAccessibilityWait,
ASExperimentalSkipDefaultCellLayoutMode
};

@interface ASConfigurationTests : ASTestCase <ASConfigurationDelegate>
Expand All @@ -51,7 +53,9 @@ + (NSArray *)names {
@"exp_framesetter_cache",
@"exp_skip_clear_data",
@"exp_did_enter_preload_skip_asm_layout",
@"exp_disable_a11y_cache"
@"exp_disable_a11y_cache",
@"exp_skip_a11y_wait",
@"exp_skip_default_cell_layout_mode"
];
}

Expand Down