Skip to content

Commit

Permalink
Remove ASExperimentalTransactionOperationRetainCycle (TextureGroup#1547)
Browse files Browse the repository at this point in the history
* Remove ASExperimentalTransactionOperationRetainCycle
  • Loading branch information
Greg Bolsinga authored Jun 13, 2019
1 parent 2de8eec commit c67acab
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 67 deletions.
1 change: 0 additions & 1 deletion Schemas/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"exp_did_enter_preload_skip_asm_layout",
"exp_dispatch_apply",
"exp_oom_bg_dealloc_disable",
"exp_transaction_operation_retain_cycle",
"exp_remove_textkit_initialising_lock"
]
}
Expand Down
5 changes: 2 additions & 3 deletions Source/ASExperimentalFeatures.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ typedef NS_OPTIONS(NSUInteger, ASExperimentalFeatures) {
ASExperimentalDidEnterPreloadSkipASMLayout = 1 << 7, // exp_did_enter_preload_skip_asm_layout
ASExperimentalDispatchApply = 1 << 8, // exp_dispatch_apply
ASExperimentalOOMBackgroundDeallocDisable = 1 << 9, // exp_oom_bg_dealloc_disable
ASExperimentalTransactionOperationRetainCycle = 1 << 10, // exp_transaction_operation_retain_cycle
ASExperimentalRemoveTextKitInitialisingLock = 1 << 11, // exp_remove_textkit_initialising_lock
ASExperimentalDrawingGlobal = 1 << 12, // exp_drawing_global
ASExperimentalRemoveTextKitInitialisingLock = 1 << 10, // exp_remove_textkit_initialising_lock
ASExperimentalDrawingGlobal = 1 << 11, // exp_drawing_global
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 @@ -22,7 +22,6 @@
@"exp_did_enter_preload_skip_asm_layout",
@"exp_dispatch_apply",
@"exp_oom_bg_dealloc_disable",
@"exp_transaction_operation_retain_cycle",
@"exp_remove_textkit_initialising_lock",
@"exp_drawing_global"]));
if (flags == ASExperimentalFeatureAll) {
Expand Down
39 changes: 12 additions & 27 deletions Source/Details/Transactions/_ASAsyncTransactionContainer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -56,33 +56,18 @@ - (_ASAsyncTransaction *)asyncdisplaykit_asyncTransaction
self.asyncdisplaykit_asyncLayerTransactions = transactions;
}
__weak CALayer *weakSelf = self;
if (ASActivateExperimentalFeature(ASExperimentalTransactionOperationRetainCycle)) {
transaction = [[_ASAsyncTransaction alloc] initWithCompletionBlock:^(_ASAsyncTransaction *completedTransaction, BOOL cancelled) {
__strong CALayer *self = weakSelf;
if (self == nil) {
return;
}
[self.asyncdisplaykit_asyncLayerTransactions removeObject:completedTransaction];
if (self.asyncdisplaykit_asyncLayerTransactions.count == 0) {
// Reclaim object memory.
self.asyncdisplaykit_asyncLayerTransactions = nil;
}
[self asyncdisplaykit_asyncTransactionContainerDidCompleteTransaction:completedTransaction];
}];
} else {
transaction = [[_ASAsyncTransaction alloc] initWithCompletionBlock:^(_ASAsyncTransaction *completedTransaction, BOOL cancelled) {
__strong CALayer *self = weakSelf;
if (self == nil) {
return;
}
[transactions removeObject:completedTransaction];
if (transactions.count == 0) {
// Reclaim object memory.
self.asyncdisplaykit_asyncLayerTransactions = nil;
}
[self asyncdisplaykit_asyncTransactionContainerDidCompleteTransaction:completedTransaction];
}];
}
transaction = [[_ASAsyncTransaction alloc] initWithCompletionBlock:^(_ASAsyncTransaction *completedTransaction, BOOL cancelled) {
__strong CALayer *self = weakSelf;
if (self == nil) {
return;
}
[self.asyncdisplaykit_asyncLayerTransactions removeObject:completedTransaction];
if (self.asyncdisplaykit_asyncLayerTransactions.count == 0) {
// Reclaim object memory.
self.asyncdisplaykit_asyncLayerTransactions = nil;
}
[self asyncdisplaykit_asyncTransactionContainerDidCompleteTransaction:completedTransaction];
}];
[transactions addObject:transaction];
self.asyncdisplaykit_currentAsyncTransaction = transaction;
[self asyncdisplaykit_asyncTransactionContainerWillBeginTransaction:transaction];
Expand Down
2 changes: 0 additions & 2 deletions Tests/ASConfigurationTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
ASExperimentalDidEnterPreloadSkipASMLayout,
ASExperimentalDispatchApply,
ASExperimentalOOMBackgroundDeallocDisable,
ASExperimentalTransactionOperationRetainCycle,
ASExperimentalRemoveTextKitInitialisingLock,
ASExperimentalDrawingGlobal
};
Expand All @@ -53,7 +52,6 @@ + (NSArray *)names {
@"exp_did_enter_preload_skip_asm_layout",
@"exp_dispatch_apply",
@"exp_oom_bg_dealloc_disable",
@"exp_transaction_operation_retain_cycle",
@"exp_remove_textkit_initialising_lock",
@"exp_drawing_global"
];
Expand Down
33 changes: 0 additions & 33 deletions Tests/ASTransactionTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -52,41 +52,8 @@ - (void)testWeakWhenCancelled
XCTAssertNil(weakTransaction);
}

- (void)testWeakWithSingleOperation_noExperiment
{
__weak _ASAsyncTransaction* weakTransaction = nil;
@autoreleasepool {
CALayer *layer = [[CALayer alloc] init];
_ASAsyncTransaction *transaction = layer.asyncdisplaykit_asyncTransaction;

[transaction addOperationWithBlock:^id<NSObject> _Nullable{
return nil;
} priority:1
queue:dispatch_get_main_queue()
completion:^(id _Nullable value, BOOL canceled) {
;
}];

weakTransaction = transaction;
layer = nil;
}

// held by main transaction group
XCTAssertNotNil(weakTransaction);

// run so that transaction group drains.
static NSTimeInterval delay = 0.1;
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:delay]];

XCTAssertNotNil(weakTransaction); // Oops! Experiment will fix this.
}

- (void)testWeakWithSingleOperation
{
ASConfiguration *config = [[ASConfiguration alloc] initWithDictionary:nil];
config.experimentalFeatures = ASExperimentalTransactionOperationRetainCycle;
[ASConfigurationManager test_resetWithConfiguration:config];

__weak _ASAsyncTransaction* weakTransaction = nil;
@autoreleasepool {
CALayer *layer = [[CALayer alloc] init];
Expand Down

0 comments on commit c67acab

Please sign in to comment.