Skip to content

Commit

Permalink
Ship ASExperimentalOOMBackgroundDeallocDisable since it decreases OOMs (
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Bolsinga authored and rcancro committed May 28, 2020
1 parent b01cac9 commit 6eb5b26
Show file tree
Hide file tree
Showing 9 changed files with 4 additions and 58 deletions.
6 changes: 0 additions & 6 deletions Source/ASCollectionView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -331,12 +331,6 @@ - (void)dealloc
[self setAsyncDelegate:nil];
[self setAsyncDataSource:nil];
}

// Data controller & range controller may own a ton of nodes, let's deallocate those off-main.
if (ASActivateExperimentalFeature(ASExperimentalOOMBackgroundDeallocDisable) == NO) {
ASPerformBackgroundDeallocation(&_dataController);
ASPerformBackgroundDeallocation(&_rangeController);
}
}

#pragma mark -
Expand Down
9 changes: 4 additions & 5 deletions Source/ASExperimentalFeatures.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ typedef NS_OPTIONS(NSUInteger, ASExperimentalFeatures) {
ASExperimentalSkipClearData = 1 << 6, // exp_skip_clear_data
ASExperimentalDidEnterPreloadSkipASMLayout = 1 << 7, // exp_did_enter_preload_skip_asm_layout
ASExperimentalDispatchApply = 1 << 8, // exp_dispatch_apply
ASExperimentalOOMBackgroundDeallocDisable = 1 << 9, // exp_oom_bg_dealloc_disable
ASExperimentalDrawingGlobal = 1 << 10, // exp_drawing_global
ASExperimentalOptimizeDataControllerPipeline = 1 << 11, // exp_optimize_data_controller_pipeline
ASExperimentalTraitCollectionDidChangeWithPreviousCollection = 1 << 12, // exp_trait_collection_did_change_with_previous_collection
ASExperimentalDoNotCacheAccessibilityElements = 1 << 13, // exp_do_not_cache_accessibility_elements
ASExperimentalDrawingGlobal = 1 << 9, // exp_drawing_global
ASExperimentalOptimizeDataControllerPipeline = 1 << 10, // exp_optimize_data_controller_pipeline
ASExperimentalTraitCollectionDidChangeWithPreviousCollection = 1 << 11, // exp_trait_collection_did_change_with_previous_collection
ASExperimentalDoNotCacheAccessibilityElements = 1 << 12, // exp_do_not_cache_accessibility_elements
ASExperimentalFeatureAll = 0xFFFFFFFF
};

Expand Down
1 change: 0 additions & 1 deletion Source/ASExperimentalFeatures.mm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
@"exp_skip_clear_data",
@"exp_did_enter_preload_skip_asm_layout",
@"exp_dispatch_apply",
@"exp_oom_bg_dealloc_disable",
@"exp_drawing_global",
@"exp_optimize_data_controller_pipeline",
@"exp_trait_collection_did_change_with_previous_collection",
Expand Down
5 changes: 0 additions & 5 deletions Source/ASImageNode+AnimatedImage.mm
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ - (void)_locked_setAnimatedImage:(id <ASAnimatedImageProtocol>)animatedImage
// not fire e.g. while scrolling down
CFRunLoopPerformBlock(CFRunLoopGetCurrent(), kCFRunLoopCommonModes, ^(void) {
[self animatedImageSet:animatedImage previousAnimatedImage:previousAnimatedImage];

// Animated image can take while to dealloc, do it off the main queue
if (previousAnimatedImage != nil && ASActivateExperimentalFeature(ASExperimentalOOMBackgroundDeallocDisable) == NO) {
ASPerformBackgroundDeallocation(&previousAnimatedImage);
}
});
// Don't need to wakeup the runloop as the current is already running
// CFRunLoopWakeUp(runLoop); // Should not be necessary
Expand Down
13 changes: 0 additions & 13 deletions Source/ASImageNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
// TODO: It would be nice to remove this dependency; it's the only subclass using more than +FrameworkSubclasses.h
#import <AsyncDisplayKit/ASDisplayNodeInternal.h>

static const CGSize kMinReleaseImageOnBackgroundSize = {20.0, 20.0};

typedef void (^ASImageNodeDrawParametersBlock)(ASWeakMapEntry *entry);

@interface ASImageNodeDrawParameters : NSObject {
Expand Down Expand Up @@ -247,7 +245,6 @@ - (void)_locked_setImage:(UIImage *)image
return;
}

UIImage *oldImage = _image;
_image = image;

if (image != nil) {
Expand All @@ -268,16 +265,6 @@ - (void)_locked_setImage:(UIImage *)image
} else {
self.contents = nil;
}

// Destruction of bigger images on the main thread can be expensive
// and can take some time, so we dispatch onto a bg queue to
// actually dealloc.
CGSize oldImageSize = oldImage.size;
BOOL shouldReleaseImageOnBackgroundThread = oldImageSize.width > kMinReleaseImageOnBackgroundSize.width
|| oldImageSize.height > kMinReleaseImageOnBackgroundSize.height;
if (shouldReleaseImageOnBackgroundThread && ASActivateExperimentalFeature(ASExperimentalOOMBackgroundDeallocDisable) == NO) {
ASPerformBackgroundDeallocation(&oldImage);
}
}

- (UIImage *)image
Expand Down
12 changes: 0 additions & 12 deletions Source/ASMultiplexImageNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
static NSString *const kAssetsLibraryURLScheme = @"assets-library";
#endif

static const CGSize kMinReleaseImageOnBackgroundSize = {20.0, 20.0};

/**
@abstract Signature for the block to be performed after an image has loaded.
@param image The image that was loaded, or nil if no image was loaded.
Expand Down Expand Up @@ -533,17 +531,7 @@ - (void)_updateProgressImageBlockOnDownloaderIfNeeded

- (void)_clearImage
{
// Destruction of bigger images on the main thread can be expensive
// and can take some time, so we dispatch onto a bg queue to
// actually dealloc.
UIImage *image = self.image;
CGSize imageSize = image.size;
BOOL shouldReleaseImageOnBackgroundThread = imageSize.width > kMinReleaseImageOnBackgroundSize.width ||
imageSize.height > kMinReleaseImageOnBackgroundSize.height;
[self _setImage:nil];
if (shouldReleaseImageOnBackgroundThread && ASActivateExperimentalFeature(ASExperimentalOOMBackgroundDeallocDisable) == NO) {
ASPerformBackgroundDeallocation(&image);
}
}

#pragma mark -
Expand Down
6 changes: 0 additions & 6 deletions Source/ASTableView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -373,12 +373,6 @@ - (void)dealloc
[self setAsyncDelegate:nil];
[self setAsyncDataSource:nil];
}

// Data controller & range controller may own a ton of nodes, let's deallocate those off-main
if (ASActivateExperimentalFeature(ASExperimentalOOMBackgroundDeallocDisable) == NO) {
ASPerformBackgroundDeallocation(&_dataController);
ASPerformBackgroundDeallocation(&_rangeController);
}
}

#pragma mark -
Expand Down
8 changes: 0 additions & 8 deletions Source/ASViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,6 @@ - (void)_initializeInstance
}
}

- (void)dealloc
{
if (ASActivateExperimentalFeature(ASExperimentalOOMBackgroundDeallocDisable)) {
return;
}
ASPerformBackgroundDeallocation(&_node);
}

- (void)loadView
{
// Apple applies a frame and autoresizing masks we need. Allocating a view is not
Expand Down
2 changes: 0 additions & 2 deletions Tests/ASConfigurationTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
ASExperimentalSkipClearData,
ASExperimentalDidEnterPreloadSkipASMLayout,
ASExperimentalDispatchApply,
ASExperimentalOOMBackgroundDeallocDisable,
ASExperimentalDrawingGlobal,
ASExperimentalOptimizeDataControllerPipeline,
ASExperimentalTraitCollectionDidChangeWithPreviousCollection,
Expand All @@ -53,7 +52,6 @@ + (NSArray *)names {
@"exp_skip_clear_data",
@"exp_did_enter_preload_skip_asm_layout",
@"exp_dispatch_apply",
@"exp_oom_bg_dealloc_disable",
@"exp_drawing_global",
@"exp_optimize_data_controller_pipeline",
@"exp_trait_collection_did_change_with_previous_collection",
Expand Down

0 comments on commit 6eb5b26

Please sign in to comment.