Skip to content

Update to v2.12.1 #42

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

Merged
merged 1 commit into from
Feb 21, 2019
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
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@

## Info

**Document version:** 2.12.0
**Document version:** 2.12.1

**Last updated:** 12/18/2018
**Last updated:** 01/22/2018

**Author:** Nolan O'Brien

## History

### 2.12.1

- Fix bugs related to capping the sizes of caches
- Capping a cache to `0` bytes would not completely disable it as documented, fixed
- Setting the max ratio value to a negative value would not use the default value as documented, fixed
- Thanks to @jml5qh for filing this issue (#41)

### 2.12.0

- Add `TIPImageTypeHEIC` and `TIPImageTypeAVCI` support
Expand Down
4 changes: 2 additions & 2 deletions TwitterImagePipeline.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = 'TwitterImagePipeline'
s.version = '2.12.0'
s.compiler_flags = '-DTIP_PROJECT_VERSION=2.12.0'
s.version = '2.12.1'
s.compiler_flags = '-DTIP_PROJECT_VERSION=2.12'
s.summary = 'Twitter Image Pipeline is a robust and performant image loading and caching framework for iOS'
s.description = 'Twitter created a framework for image loading/caching in order to fulfill the numerous needs of Twitter for iOS including being fast, safe, modular and versatile.'
s.homepage = 'https://github.com/twitter/ios-twitter-image-pipeline'
Expand Down
40 changes: 4 additions & 36 deletions TwitterImagePipeline.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1305,10 +1305,9 @@
isa = PBXNativeTarget;
buildConfigurationList = 8B6511D92135DE7300ED057B /* Build configuration list for PBXNativeTarget "TwitterImagePipeline.framework tvOS" */;
buildPhases = (
8B6511BB2135DE7300ED057B /* Headers */,
8B6511952135DE7300ED057B /* Sources */,
8B6511BA2135DE7300ED057B /* Frameworks */,
8B6511BB2135DE7300ED057B /* Headers */,
8B6511D82135DE7300ED057B /* Resources */,
);
buildRules = (
);
Expand All @@ -1323,10 +1322,9 @@
isa = PBXNativeTarget;
buildConfigurationList = 8B6511F82135DEB400ED057B /* Build configuration list for PBXNativeTarget "TIPTests tvOS" */;
buildPhases = (
8B6511F12135DEB400ED057B /* Headers */,
8B6511E12135DEB400ED057B /* Sources */,
8B6511ED2135DEB400ED057B /* Frameworks */,
8B6511F12135DEB400ED057B /* Headers */,
8B6511F72135DEB400ED057B /* Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -1379,10 +1377,9 @@
isa = PBXNativeTarget;
buildConfigurationList = 8BA9755C1D77E2CA00601D70 /* Build configuration list for PBXNativeTarget "TIPTests" */;
buildPhases = (
8BA975501D77E2C900601D70 /* Headers */,
8BA9754E1D77E2C900601D70 /* Sources */,
8BA9754F1D77E2C900601D70 /* Frameworks */,
8BA975501D77E2C900601D70 /* Headers */,
8BA975511D77E2C900601D70 /* Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -1471,10 +1468,9 @@
isa = PBXNativeTarget;
buildConfigurationList = 8BFF17751DF5B4AD005DE734 /* Build configuration list for PBXNativeTarget "TwitterImagePipeline.framework" */;
buildPhases = (
8BFF17671DF5B4AD005DE734 /* Headers */,
8BFF17651DF5B4AD005DE734 /* Sources */,
8BFF17661DF5B4AD005DE734 /* Frameworks */,
8BFF17671DF5B4AD005DE734 /* Headers */,
8BFF17681DF5B4AD005DE734 /* Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -1577,20 +1573,6 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
8B6511D82135DE7300ED057B /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
8B6511F72135DEB400ED057B /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
8B65120B2135DFC600ED057B /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -1619,13 +1601,6 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
8BA975511D77E2C900601D70 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
8BB66A0E1E450DFB00A8F241 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -1667,13 +1642,6 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
8BFF17681DF5B4AD005DE734 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,6 @@
ReferencedContainer = "container:TwitterImagePipeline.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "NO"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "8BA975521D77E2C900601D70"
BuildableName = "TIPTests.framework"
BlueprintName = "TIPTests"
ReferencedContainer = "container:TwitterImagePipeline.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "NO"
Expand Down
2 changes: 2 additions & 0 deletions TwitterImagePipeline/Project/NSDictionary+TIPAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ - (void)tip_setObject:(id)object forCaseInsensitiveKey:(NSString *)key
{
TIPAssert(key);
[self tip_removeObjectsForCaseInsensitiveKey:key];
#ifndef __clang_analyzer__ // reports key can be nil nil; we prefer to crash if it is
self[key] = object;
#endif
}

- (void)tip_makeAllKeysLowercase
Expand Down
66 changes: 37 additions & 29 deletions TwitterImagePipeline/Project/TIPImageDiskCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ - (TIPLRUCache *)manifest
}

TIPAssert(manifest != nil);
return manifest;
return (TIPLRUCache * _Nonnull)manifest; // TIPAssert() performed 1 line above
}

- (NSUInteger)totalCost
Expand Down Expand Up @@ -1022,38 +1022,46 @@ static void _diskCache_updateImageEntry(SELF_ARG,
didChangeComplete = YES;
}

// Update xattrs and LRU
const NSUInteger newCost = existingEntry.partialFileSize + existingEntry.completeFileSize;
_diskCache_updateByteCounts(self, newCost /*bytesAdded*/, oldCost /*bytesRemoved*/);
if (!hasPreviousEntry && existingEntry) {
self->_globalConfig.internalTotalCountForAllDiskCaches += 1;
}
if (!existingEntry.partialImageContext && !existingEntry.completeImageContext) {
// shoot... the save cannot complete -- purge the entry
if (hasPreviousEntry) {
[manifest removeEntry:existingEntry];
}
} else {

if (gTwitterImagePipelineAssertEnabled) {
if (existingEntry.partialImageContext && 0 == existingEntry.partialFileSize) {
NSDictionary *info = @{
@"dimension" : NSStringFromCGSize(existingEntry.partialImageContext.dimensions),
@"URL" : existingEntry.partialImageContext.URL,
@"id" : existingEntry.identifier,
};
TIPLogError(@"Cached zero cost partial image to disk cache %@", info);
// Update xattrs and LRU
const NSUInteger newCost = existingEntry.partialFileSize + existingEntry.completeFileSize;
_diskCache_updateByteCounts(self, newCost /*bytesAdded*/, oldCost /*bytesRemoved*/);
if (!hasPreviousEntry && existingEntry) {
self->_globalConfig.internalTotalCountForAllDiskCaches += 1;
}
if (existingEntry.completeImageContext && 0 == existingEntry.completeFileSize) {
NSDictionary *info = @{
@"dimension" : NSStringFromCGSize(existingEntry.completeImageContext.dimensions),
@"URL" : existingEntry.completeImageContext.URL,
@"id" : existingEntry.identifier,
};
TIPLogError(@"Cached zero cost complete image to disk cache %@", info);

[manifest addEntry:existingEntry];
if (didChangePartial) {
_diskCache_touchEntry(self, existingEntry, forciblyReplaceExisting /*forced*/, YES /*partial*/);
}
if (didChangeComplete) {
_diskCache_touchEntry(self, existingEntry, forciblyReplaceExisting /*forced*/, NO /*partial*/);
}
}

[manifest addEntry:existingEntry];
if (didChangePartial) {
_diskCache_touchEntry(self, existingEntry, forciblyReplaceExisting /*forced*/, YES /*partial*/);
}
if (didChangeComplete) {
_diskCache_touchEntry(self, existingEntry, forciblyReplaceExisting /*forced*/, NO /*partial*/);
if (gTwitterImagePipelineAssertEnabled) {
if (existingEntry.partialImageContext && 0 == existingEntry.partialFileSize) {
NSDictionary *info = @{
@"dimension" : NSStringFromCGSize(existingEntry.partialImageContext.dimensions),
@"URL" : existingEntry.partialImageContext.URL,
@"id" : existingEntry.identifier,
};
TIPLogError(@"Cached zero cost partial image to disk cache %@", info);
}
if (existingEntry.completeImageContext && 0 == existingEntry.completeFileSize) {
NSDictionary *info = @{
@"dimension" : NSStringFromCGSize(existingEntry.completeImageContext.dimensions),
@"URL" : existingEntry.completeImageContext.URL,
@"id" : existingEntry.identifier,
};
TIPLogError(@"Cached zero cost complete image to disk cache %@", info);
}
}
}

[self->_globalConfig pruneAllCachesOfType:self.cacheType withPriorityCache:self];
Expand Down
2 changes: 2 additions & 0 deletions TwitterImagePipeline/Project/TIPImageRenderedCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ - (void)inspect:(TIPInspectableCacheCallback)callback
class:[TIPImagePipelineInspectionResultRenderedEntry class]];
TIPAssert(entry != nil);
entry.bytesUsed = [entry.image tip_estimatedSizeInBytes];
#ifndef __clang_analyzer__ // reports entry can be nil; we prefer to crash if it is
[inspectedEntries addObject:entry];
#endif
}
}

Expand Down
18 changes: 15 additions & 3 deletions TwitterImagePipeline/Project/TIPImageStoreAndMoveOperations.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ @interface TIPImageStoreOperation (Private)
static TIPImageContainer * __nullable _getImageContainer(PRIVATE_SELF(TIPImageStoreOperation));
static TIPCompleteImageEntryContext *_getEntryContext(PRIVATE_SELF(TIPImageStoreOperation),
NSURL *imageURL,
TIPImageContainer * __nullable imageContainer);
TIPImageContainer * __nullable imageContainer,
NSString * __nullable imageFilePath,
NSData * __nullable imageData);
static void _asyncStoreMemoryEntry(PRIVATE_SELF(TIPImageStoreOperation),
TIPImageCacheEntry *memoryEntry,
void(^complete)(BOOL));
Expand Down Expand Up @@ -193,7 +195,11 @@ - (void)main
NSString *identifier = TIPImageStoreRequestGetImageIdentifier(_request);

// Create context
TIPCompleteImageEntryContext *context = _getEntryContext(self, imageURL, imageContainer);
TIPCompleteImageEntryContext *context = _getEntryContext(self,
imageURL,
imageContainer,
imageFilePath,
imageData);

// Create Memory Entry
TIPImageCacheEntry *memoryEntry = nil;
Expand Down Expand Up @@ -330,7 +336,9 @@ @implementation TIPImageStoreOperation (Private)

static TIPCompleteImageEntryContext *_getEntryContext(PRIVATE_SELF(TIPImageStoreOperation),
NSURL *imageURL,
TIPImageContainer * __nullable imageContainer)
TIPImageContainer * __nullable imageContainer,
NSString * __nullable imageFilePath,
NSData * __nullable imageData)
{
TIPAssert(self);
if (!self) {
Expand All @@ -354,6 +362,10 @@ @implementation TIPImageStoreOperation (Private)
context.dimensions = imageContainer.dimensions;
} else if ([self->_request respondsToSelector:@selector(imageDimensions)]) {
context.dimensions = self->_request.imageDimensions;
} else if (imageData) {
context.dimensions = TIPDetectImageDataDimensions(imageData);
} else if (imageFilePath) {
context.dimensions = TIPDetectImageFileDimensions(imageFilePath);
}
if ([self->_request respondsToSelector:@selector(imageType)]) {
context.imageType = [self->_request imageType];
Expand Down
12 changes: 12 additions & 0 deletions TwitterImagePipeline/Project/TIPLRUCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,22 @@ - (void)addEntry:(id<TIPLRUEntry>)entry

NSString *identifier = entry.LRUEntryIdentifier;
TIPAssert(identifier != nil);
#ifndef __clang_analyzer__
// clang analyzer reports identifier can be nil for the check if (... && _cache[identifier]) {
// just below. (and then, if we ignore only that with #ifndef __clang_analyzer__, then it reports
// _cache[identifier] within the TIPAssert() protected by the if stmt.)
// however, in real life, the TIPAssert(identifier != nil) just above will prevent control from getting to
// the if stmt at all when gTwitterImagePipelineAssertEnabled is true, and when it is false, then the 2nd
// part of the condition (and the stmts protected by the condition) will never be executed and won't crash.
if (gTwitterImagePipelineAssertEnabled && _cache[identifier]) {
TIPAssert((id)_cache[identifier] == (id)entry);
}
#endif

[self moveEntryToFront:entry];
#ifndef __clang_analyzer__ // reports identifier can be nil; we prefer to crash if it is
_cache[identifier] = entry;
#endif

TIPLRUCacheAssertHeadAndTail(self);
}
Expand All @@ -114,7 +124,9 @@ - (void)appendEntry:(id<TIPLRUEntry>)entry
entry.previousLRUEntry = _tailEntry;
entry.nextLRUEntry = nil;
_tailEntry = entry;
#ifndef __clang_analyzer__ // reports identifier can be nil; we prefer to crash if it is
_cache[identifier] = entry;
#endif

if (!_headEntry) {
_headEntry = _tailEntry;
Expand Down
2 changes: 1 addition & 1 deletion TwitterImagePipeline/Project/TIP_Project.m
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ CGSize TIPScaleToFitKeepingAspectRatio(CGSize sourceSize, CGSize targetSize, CGF
TIPAssert(safe != 0);
NSString *raw = TIPURLDecodeString(safe, NO);
TIPAssert(raw != 0);
return raw;
return (NSString * _Nonnull)raw; // TIPAssert() performed 1 line above
}

dispatch_block_t __nullable TIPStartBackgroundTask(NSString * __nullable name)
Expand Down
Loading