Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions AsyncDisplayKit/ASDisplayNode+Subclasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,9 @@
*
* @discussion Subclasses may override this method to be notified when they should begin to fetch data. Fetching
* should be done asynchronously. The node is also responsible for managing the memory of any data.
* The data may be remote and accessed via the network, but could also be a local database query.
*/
- (void)fetchRemoteData ASDISPLAYNODE_REQUIRES_SUPER;
- (void)fetchData ASDISPLAYNODE_REQUIRES_SUPER;

/**
* @abstract Indicates that the receiver is about to display its subnodes. This method is not called if there are no
Expand Down Expand Up @@ -323,18 +324,18 @@
* Provides an opportunity to clear backing store and other memory-intensive intermediates, such as text layout managers
* on the current node.
*
* @discussion Called by -recursivelyClearRendering. Base class implements self.contents = nil, clearing any backing
* @discussion Called by -recursivelyClearContents. Base class implements self.contents = nil, clearing any backing
* store, for asynchronous regeneration when needed.
*/
- (void)clearRendering ASDISPLAYNODE_REQUIRES_SUPER;
- (void)clearContents ASDISPLAYNODE_REQUIRES_SUPER;

/**
* Provides an opportunity to clear any remote data on the current node.
* Provides an opportunity to clear any fetched data (e.g. remote / network or database-queried) on the current node.
*
* @discussion This will not clear data recursively for all subnodes. Either call -recursivelyClearRemoteData or
* selectively clear remote data.
* @discussion This will not clear data recursively for all subnodes. Either call -recursivelyClearFetchedData or
* selectively clear fetched data.
*/
- (void)clearRemoteData ASDISPLAYNODE_REQUIRES_SUPER;
- (void)clearFetchedData ASDISPLAYNODE_REQUIRES_SUPER;


/** @name Placeholders */
Expand Down
16 changes: 8 additions & 8 deletions AsyncDisplayKit/ASDisplayNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ typedef CALayer *(^ASDisplayNodeLayerBlock)();
- (void)recursivelySetDisplaySuspended:(BOOL)flag;

/**
* @abstract Calls -clearRendering on the receiver and its subnode hierarchy.
* @abstract Calls -clearContents on the receiver and its subnode hierarchy.
*
* @discussion Clears backing stores and other memory-intensive intermediates.
* If the node is removed from a visible hierarchy and then re-added, it will automatically trigger a new asynchronous display,
Expand All @@ -322,27 +322,27 @@ typedef CALayer *(^ASDisplayNodeLayerBlock)();
* @see displaySuspended and setNeedsDisplay
*/

- (void)recursivelyClearRendering;
- (void)recursivelyClearContents;

/**
* @abstract Calls -clearRemoteData on the receiver and its subnode hierarchy.
* @abstract Calls -clearFetchedData on the receiver and its subnode hierarchy.
*
* @discussion Clears any memory-intensive fetched content.
* This method is used to notify the node that it should purge any content that is both expensive to fetch and to
* retain in memory.
*
* @see clearRemoteData and fetchRemoteData
* @see clearFetchedData and fetchData
*/
- (void)recursivelyClearRemoteData;
- (void)recursivelyClearFetchedData;

/**
* @abstract Calls -fetchRemoteData on the receiver and its subnode hierarchy.
* @abstract Calls -fetchData on the receiver and its subnode hierarchy.
*
* @discussion Fetches content from remote sources for the current node and all subnodes.
*
* @see fetchRemoteData and clearRemoteData
* @see fetchData and clearFetchedData
*/
- (void)recursivelyFetchRemoteData;
- (void)recursivelyFetchData;

/**
* @abstract Toggle displaying a placeholder over the node that covers content until the node and all subnodes are
Expand Down
32 changes: 16 additions & 16 deletions AsyncDisplayKit/ASDisplayNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ + (void)initialize
// Subclasses should never override these
ASDisplayNodeAssert(!ASDisplayNodeSubclassOverridesSelector(self, @selector(calculatedSize)), @"Subclass %@ must not override calculatedSize method", NSStringFromClass(self));
ASDisplayNodeAssert(!ASDisplayNodeSubclassOverridesSelector(self, @selector(measure:)), @"Subclass %@ must not override measure method", NSStringFromClass(self));
ASDisplayNodeAssert(!ASDisplayNodeSubclassOverridesSelector(self, @selector(recursivelyClearRendering)), @"Subclass %@ must not override recursivelyClearRendering method", NSStringFromClass(self));
ASDisplayNodeAssert(!ASDisplayNodeSubclassOverridesSelector(self, @selector(recursivelyClearRemoteData)), @"Subclass %@ must not override recursivelyClearRemoteData method", NSStringFromClass(self));
ASDisplayNodeAssert(!ASDisplayNodeSubclassOverridesSelector(self, @selector(recursivelyClearContents)), @"Subclass %@ must not override recursivelyClearContents method", NSStringFromClass(self));
ASDisplayNodeAssert(!ASDisplayNodeSubclassOverridesSelector(self, @selector(recursivelyClearFetchedData)), @"Subclass %@ must not override recursivelyClearFetchedData method", NSStringFromClass(self));
}

+ (BOOL)layerBackedNodesEnabled
Expand Down Expand Up @@ -1329,44 +1329,44 @@ - (void)didExitHierarchy
[self __exitedHierarchy];
}

- (void)clearRendering
- (void)clearContents
{
self.layer.contents = nil;
_placeholderLayer.contents = nil;
}

- (void)recursivelyClearRendering
- (void)recursivelyClearContents
{
for (ASDisplayNode *subnode in self.subnodes) {
[subnode recursivelyClearRendering];
[subnode recursivelyClearContents];
}
[self clearRendering];
[self clearContents];
}

- (void)fetchRemoteData
- (void)fetchData
{
// subclass override
}

- (void)recursivelyFetchRemoteData
- (void)recursivelyFetchData
{
for (ASDisplayNode *subnode in self.subnodes) {
[subnode recursivelyFetchRemoteData];
[subnode recursivelyFetchData];
}
[self fetchRemoteData];
[self fetchData];
}

- (void)clearRemoteData
- (void)clearFetchedData
{
// subclass override
}

- (void)recursivelyClearRemoteData
- (void)recursivelyClearFetchedData
{
for (ASDisplayNode *subnode in self.subnodes) {
[subnode recursivelyClearRemoteData];
[subnode recursivelyClearFetchedData];
}
[self clearRemoteData];
[self clearFetchedData];
}

- (void)layout
Expand Down Expand Up @@ -1816,12 +1816,12 @@ - (BOOL)placeholderFadesOut

- (void)reclaimMemory
{
[self clearRendering];
[self clearContents];
}

- (void)recursivelyReclaimMemory
{
[self recursivelyClearRendering];
[self recursivelyClearContents];
}

@end
10 changes: 5 additions & 5 deletions AsyncDisplayKit/ASMultiplexImageNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ - (instancetype)init
}

#pragma mark - ASDisplayNode Overrides
- (void)clearRendering
- (void)clearContents
{
[super clearRendering]; // This actually clears the contents, so we need to do this first for our displayedImageIdentifier to be meaningful.
[super clearContents]; // This actually clears the contents, so we need to do this first for our displayedImageIdentifier to be meaningful.
[self _setDisplayedImageIdentifier:nil withImage:nil];

if (_downloadIdentifier) {
Expand All @@ -177,12 +177,12 @@ - (void)displayWillStart
{
[super displayWillStart];

[self fetchRemoteData];
[self fetchData];
}

- (void)fetchRemoteData
- (void)fetchData
{
[super fetchRemoteData];
[super fetchData];

[self _loadImageIdentifiers];
}
Expand Down
10 changes: 5 additions & 5 deletions AsyncDisplayKit/ASNetworkImageNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ - (void)displayWillStart
{
[super displayWillStart];

[self fetchRemoteData];
[self fetchData];
}

- (void)clearRemoteData
- (void)clearFetchedData
{
[super clearRemoteData];
[super clearFetchedData];

{
ASDN::MutexLocker l(_lock);
Expand All @@ -143,9 +143,9 @@ - (void)clearRemoteData
}
}

- (void)fetchRemoteData
- (void)fetchData
{
[super fetchRemoteData];
[super fetchData];

{
ASDN::MutexLocker l(_lock);
Expand Down
4 changes: 2 additions & 2 deletions AsyncDisplayKit/ASTextNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,12 @@ - (void)displayDidFinish
[self _invalidateRenderer];
}

- (void)clearRendering
- (void)clearContents
{
// We discard the backing store and renderer to prevent the very large
// memory overhead of maintaining these for all text nodes. They can be
// regenerated when layout is necessary.
[super clearRendering]; // ASDisplayNode will set layer.contents = nil
[super clearContents]; // ASDisplayNode will set layer.contents = nil
[self _invalidateRenderer];
}

Expand Down
4 changes: 2 additions & 2 deletions AsyncDisplayKit/Details/ASRangeHandlerPreload.mm
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ @implementation ASRangeHandlerPreload
- (void)node:(ASDisplayNode *)node enteredRangeOfType:(ASLayoutRangeType)rangeType
{
ASDisplayNodeAssert(rangeType == ASLayoutRangeTypePreload, @"Preload delegate should not handle other ranges");
[node recursivelyFetchRemoteData];
[node recursivelyFetchData];
}

- (void)node:(ASDisplayNode *)node exitedRangeOfType:(ASLayoutRangeType)rangeType
{
ASDisplayNodeAssert(rangeType == ASLayoutRangeTypePreload, @"Preload delegate should not handle other ranges");
[node recursivelyClearRemoteData];
[node recursivelyClearFetchedData];
}

@end
2 changes: 1 addition & 1 deletion AsyncDisplayKit/Details/ASRangeHandlerRender.mm
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ - (void)node:(ASDisplayNode *)node exitedRangeOfType:(ASLayoutRangeType)rangeTyp
[node recursivelySetDisplaySuspended:YES];
[node.view removeFromSuperview];

[node recursivelyClearRendering];
[node recursivelyClearContents];
}

@end
2 changes: 2 additions & 0 deletions AsyncDisplayKitTests/ASBasicImageDownloaderContextTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ - (void)testContextInvalidation
XCTAssert([context isCancelled], @"Context should be cancelled");
}

/* This test is currently unreliable. See https://github.com/facebook/AsyncDisplayKit/issues/459
- (void)testAsyncContextInvalidation
{
NSURL *url = [self randomURL];
Expand All @@ -56,6 +57,7 @@ - (void)testAsyncContextInvalidation
[context cancel];
[self waitForExpectationsWithTimeout:30.0 handler:nil];
}
*/

- (void)testContextSessionCanceled
{
Expand Down
2 changes: 1 addition & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ SPEC CHECKSUMS:
FBSnapshotTestCase: 3dc3899168747a0319c5278f5b3445c13a6532dd
OCMock: a6a7dc0e3997fb9f35d99f72528698ebf60d64f2

COCOAPODS: 0.36.3
COCOAPODS: 0.37.1