Giter Site home page Giter Site logo

fastimagecache's People

Contributors

chakrit avatar ciphercom avatar cxa avatar dcaunt avatar dezinezync avatar donholly avatar epatey avatar indragiek avatar ishawnwang avatar jmah avatar jszumski avatar jverdi avatar mallorypaine avatar mortonfox avatar mviamari avatar olivercameron avatar rromanchuk avatar ruiaaperes avatar sega-zero avatar vkovtash avatar zbigy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fastimagecache's Issues

Failed to map chunk. errno=22

Hi,
I'd like to report some information about this error and ask about the reasons and possible ways to fix it.

One of users ran into an issue when my app doesn't show a downloaded image. The image was downloaded successfully but it was not added to FIC.

I found "Failed to map chunk. errno=22" and "ERROR: FastImageCache error occured with message: *** FIC Error: -[FICImageTable _chunkAtIndex:] failed to get chunk for index 5" log messages.

After a search in the sources (v1.3) I found mmap call that led to "Failed to map chunk. errno=22" message.
errno 22 - EINVAL. Something wrong with input parameters: probably, length or offset.

Thanks!

Original images being fetched again on app update

I noticed something in my app when I update it on the App Store. The images in the collection view flash briefly because fast image cache is, for some reason, getting them from the original files on disk again instead of getting them from the cache. (logical conclusion because it does the exact same thing UI wise if you delete the cache files)

When the app gets updated the files in the ImageTables directory seem to be there and the same size before and after the app gets updated. However, I can't seem to figure out why FastImageCache would be getting the original image files when the image tables seem to still exist. This is hard to debug because it only seems to occur when the app updates. I was hoping someone else had run into this issue and could give me some guidance.

Thanks!

Use the same image table for image formats with the same metadata

Proposoal

I'd like to propose that image formats that have identical values for the following properties use the same image table:

  • family
  • style
  • imageSize
  • devices
  • maximumCount (Maybe? An argument could be made to exclude this from the decision on whether to use the same image table as another format)

Motivation

I'm setting up all of the various FIC configuration during app launch. For simplicity, let's assume I'm doing that in application:didFinishLaunchingWithOptions:. This means that my startup code needs to know about all of the various bits of UI in my app that will be harnessing FIC. It not only needs to know about the existence of these bits of UI that show images, but it also needs to know what size each would like to display images at. (And image style, etc)

What I'd like to do is have each of the image-displaying classes generate their own FICImageFormat, since their expected size (and other information) should be an implementation detail that the App Delegate shouldn't know about. Here's an example of what I'd like to be able to do in my App Delegate:

NSArray* imageDisplayingClasses = @[ /* all my UI classes that harness FIC */ ];
NSMutableArray* imageFormats = [NSMutableArray new];

for (Class uiClass in imageDisplayingClasses) {
    [imageFormats addObject:[uiClass imageFormat]];
}

FICImageCache* imageCache = [FICImageCache sharedImageCache];
imageCache.formats = imageFormats;

However, this falls down a little bit when more than one UI class intends to show the same image at the same size. For instance, there are several unrelated bits of UI in my app that show user avatars. Usually, they show at different sizes but sometimes the design might call for the avatar in a User Post cell be the same size as the avatar in the User Comment cell, for example. (Let's assume these cells are completely de-coupled, since the design might change and call for a different size image). If I use the example code I've included, what I'll get (as far as I can tell) are two separate image tables that are exactly the same. (Especially if I return YES in response to imageCache:shouldProcessAllFormatsInFamily:forEntity:!)

The enhancement I'm proposing is to de-duplicate these image tables. If the image table is the same in every way, use the same image table for the two identical formats.

Run demo error

I download the zip, run demo ,show some errors?
xcode4.6 llvm4.2
Command /Applications/Xcode4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1

FICImageFormat's maximumCount does not work?

Thank you for the great open source.
I want to limit the FICImageTable size, so I set the FICImageFormat's maximumCount. But it sometimes does not work. For example, in the FICImageCacheDemo, I only change "NSInteger squareImageFormatMaximumCount = 400;" from 400 to 4, then run the demo. In the debug console it will output:
"
2014-04-11 17:07:48.061 FastImageCacheDemo[33653:60b] *** FIC Warning: growing desired maximumCount (4) for format com.path.FastImageCacheDemo.FICDPhotoSquareImage32BitBGRAFormatName to fill a chunk (21)
...
2014-04-11 17:07:55.204 FastImageCacheDemo[33653:21b] FICImageTable - unable to evict entry from table 'com.path.FastImageCacheDemo.FICDPhotoSquareImage32BitBGRAFormatName' to make room. New index 99, desired max 21
"
and the com.path.FastImageCacheDemo.FICDPhotoSquareImage32BitBGRAFormatName.imageTable size is the same as before(when the maximumCount set 400).

I debugged the demo and found "- (NSString *)oldestEvictableEntityUUID" can not find the oldest evictableEntity UUID because all the entityUUID is in use.
I found the entityUUID will be free after the entryData dealloc.
"
[_inUseEntries addObject:entityUUID];
__weak FICImageTable *weakSelf = self;
[entryData executeBlockOnDealloc:^{
[weakSelf removeInUseForEntityUUID:entityUUID];
}];
"

I want to ask why change the demo maximumCount does not work? Is the demo must use 100 entityUUID or is the entryData not dealloc as soon as possible?

saveMetadata is called too frequently - causes a significant performance issue

It seems that saveMetadata on the FICImageTable class is called every time there's an interaction with one of the images in the cache (when images are processed to be added, updated or removed).

This is causing a very noticeable drop in frame-rate when scrolling down a network-populated UICollectionView with many (thousands) of images. It seems that the `saveMetadata' is important as it persists the data that is known about that image table to disk for retrieval later, but must it be done in a synchronous fashion (using a lock)?

Could we instead dispatch_async it on a serial queue and achieve the same safety?

Another option would be to bulk the updates so the disk IO wasn't so expensive (that method alone takes up about 90% of the time when calling _processImage:forEntity:imageTable:completionBlocks:

Perhaps it could be called after X number of changes or after a certain amount of time? From what I see, it shouldn't be more expensive to do it later vs after each entry change (still has to serialize all of the data and write it out).

If I don't call `saveMetadata' every single change when populating my image tables the scrolling performance stays pretty consistent and I don't get nearly as many hiccups. Yes, this is a one-time hit and once it's in the table, things are smooth as butter :) I'm mostly optimizing for the first-load experience.

I'm happy to submit a pull-request if you guys think this is the right move, I just wanted to see if there was a good reason to keep it synchronous!

Keep crashing in FICImageCache

My project is not using ARC (don't ask me why, long story :P). I've set flag -fobjc-arc for all FIC source files.

It keeps crashing on last line of this method:

  • (void)_processImage:(UIImage *)image forEntity:(id )entity imageTable:(FICImageTable *)imageTable completionBlocks:(NSArray *)completionBlocks

of FICImageCache.m

I've tried to set imageDrawingBlock to nil (in the same method)
FICEntityImageDrawingBlock imageDrawingBlock = nil;

the crash doesn't happen. But of course, nothing to render on screen.

Please advice. Thanks in advance.

Use case question

Hope you guys don't mind my asking here.

Trying to determine whether or not it makes sense to use this library in a situation where you have a constant stream of new images to deal with. Think of a case where every 'tweet' had a different thumbnail associated with it where the network source was of random size, and you had an 'infiniti load' table view model where you didn't have all the data to process thumbnails up front.

The fact that you need to effectively resize every incoming image so it can be written to the image table makes me think if the images aren't as likely to be seen repeatedly, that this might be more of a performance impact up front than a more traditional method.

Just curious on the cases where you shouldn't use this library.

Sharing formats between families?

The project I'm working on is setup similar to these families and formats.

  • portrait
    • small(75x75)
    • large(600x800)
  • landscape
    • small(75x75)
    • large(800x600)

In the app, there is only one entity and the family it uses is based on the orientation of the source image. All of these entities are displayed on the same screen.

To me, it doesn't make sense that the portraitSmall and landscapeSmall are stored in two different imageTables when they are identical. The main case that I can think of is when the portraitSmall imageTable is full and the landscapeSmall imageTable only has a few images. Adding a new portraitSmall image would remove and old image when there could be an even older image in the landscapeSmall imageTable.

I'm thinking about implementing this and have a couple ideas but I wanted to see if anyone else thinks this would be useful or if I'm just being silly 😃

deleteImageForEntity can not change the size of .imageTable

thanks for this great Fast Image Cache. It help me to improve the experience!
here is a little issue.
when i delete an image cache by deleteImageForEntity, the image cache really DOES NOT exist, however, the size of .imageTable still keeps same.
How could i make the size of .imageTable decreased when an image cache is deleted?
thanks~

Cancel image retrieval when the same entity is being loaded?

I have a table view with images (e.g. user profiles). Each user has its own entity.

I was using cancelImageRetrievalForEntity on UITableViewCell's prepareForReuse. However, I realized that it'll cancel all retrievals for that profile.

Is there a way to cancel a specific retrieval (and not all of them)?

I could create an entity for each cell (instead of by user), but I suppose it's not the best way, as I suppose it'd store and fetch several times the same image.

Get a null image in FICImageCacheCompletionBlock

Hi,
I've tried to use FIC as the document said, but always get a null image in FICImageCacheCompletionBlock callback.

I think [imageTable setEntryForEntityUUID:entityUUID sourceImageUUID:sourceImageUUID imageDrawingBlock:imageDrawingBlock]; may fail to set the cache, but I can find a way to debug or find out how to fix it.

[sharedImageCache asynchronouslyRetrieveImageForEntity:photo withFormatName:_imageFormatName completionBlock:^(id<FICEntity> entity, NSString *formatName, UIImage *image) {
 NSLog(@"img: %@", image); // log (null)
}];

Thanks for you help!

Is it possible to have multiple FICImageCache instances?

Hi,

Hope I will get an answer here since I'm facing a severe issue where metadata are written on disk but not imageTable.
I am using multiple instances of FICImageCache each used to deal with a single <FICEntity> class.

Images are visible in my application but there is only a metadata file.
Also sometimes when I retrieve images from a specific family, all metadata + imageTables are deleted for other families.

Thanks for your help!
Antoine

ImageTables not deleted

More issues from me :)

I notice that ImageTables folder or files inside it not deleted after I've done:

[[FICImageCache sharedImageCache] deleteImageForEntity:_mov withFormatName:XXPosterThumbnail];

or even after:
[[FICImageCache sharedImageCache] reset];

Is that by design?

The reason I wanna do that is for freeing up some space, just in case users notice that my app consume a lot of storage.

Thanks.

Video Linked in README Doesn't Display

When I click on the video image/link on the main Github project page, I get some XML file from AWS rather than the video. It says "Access Denied".

Thanks.

Is there a way to clear cache?

Since the table data grows, some user wish to have an option to clear it.
I've not find an API for this, is there?

Or can I just remove the table and meta data files in the cache folder and re-config FIC to implement this?

Thanks!

CGContextClearRect() intermittent crash inside of drawingBlockForImage:withFormatName:

One of my beta testers is getting a recurring crash inside of drawingBlockForImage:withFormatName:, specifically when CGContextClearRect() is called.

The crashed thread is:
com.path.FastImageCacheQueue.

The error given is:
EXC_BAD_ACCESS KERN_INVALID_ADDRESS at 0x1096d0000

The call stack is 7 or 8 frames deep inside the implementation of CGContextClearRect() when it crashes.

My drawing code is copied directly from the recommended sample code in the documentation, which includes the call to clear the passed-in context before performing the rest of the drawing code.

Attached below is a screenshot of the crashed thread:

screen shot 2014-01-06 at 6 47 37 pm

This is on an iPhone 5s running iOS 7.1.

Feature Request: simple way to retrieve disk usage

It would be nice to have a simple way to get the number of bytes currently being occupied on disk from FastImageCache. I understand there is 4 bytes per pixel × image width in pixels × image height in pixels × maximum number of entries but i would like to ask shared cache this question programmatically

Crash in iPad and iOS 5.0

Hi Lucas,

Thanks for sharing your code, it really good and its clear my most of the concept regarding caching image.

Apart from that the application is crashed in iPad version and iOS 5.0.

For these I shared the crash log please find the below.

-[UILabel attributedText]: unrecognized selector sent to instance 0x6bb2410
2013-10-21 14:30:38.090 FastImageCacheDemo[1101:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UILabel attributedText]: unrecognized selector sent to instance 0x6bb2410'

Please let me know if you require anything for trace above crash log.

_processImage/newImageForEntityUUID:sourceImageUUID Failing

Since I switched to FIC I noticed randomly my images would "fail" to load even when the HTTP request was successful.

It looks like the issue is in FICImageCache in the method _processImage:forEntity:imageTable:completionBlocks:.

On line 338 when newImageForEntityUUID:sourceImageUUID: is called, it returns nil even though _processImage was called with a valid image.

I can't find a scenario that consistently reproduces it, it seems to happen at random and most frequently presents itself when multiple images of the same format are loading at the same time.

Display the network picture?

Hello,
thanks for the great source, it works like a charm.
however i have a litte problem : How do I display the network picture, please?

Jack

Example implementation of FICEntity is misleading.

- (NSString *)UUID {
    return _userID;
}

- (NSString *)sourceImageUUID {
    return [_userPhotoURL absoluteString];
}

This example illustrate that UUID can be arbitrary string, but in fact it should be properly formatted string representation of UUID, or you get zero filled UUID in FICImageTableEntry.

EXC_BAD_ACCESS drawInRect

Hello,

I've used in FICEntityImageDrawingBlock code from documentation:

UIGraphicsPushContext(context);
[image drawInRect:contextBounds];
UIGraphicsPopContext();

It worked excellent, but I could replicate EXC_BAD_ACCESS in drawInRect method. I reset image cache, but some pending operation was still in queue

Scenarios is following

threadX inside FICEntityImageDrawingBlock

UIGraphicsPushContext(context);
image = SomeImageTransformation

switch to main thread

[ imageCache reset ];

return back to threadX

[image drawInRect:contextBounds];
UIGraphicsPopContext();

Reporting network error from delegate's wantsSourceImageForEntity up to the app's code

I've noticed in the following call chain:

[FICImageCache asynchronouslyRetrieveImageForEntity:withFormatName:completionBlock:]
->
[delegate wantsSourceImageForEntity:withFormatName:completionBlock:]
->
AFHTTPRequest operation
->
completionBlock(image)

There's no way to report a network layer error up to an app level caller. Passing nil to completionBlock simply ignores the lookup of the block in the dictionary inside of the FastImageCache.

Is there any way to overcome this design constraint?

FICImageCache can not reset in background?

Thank you for the great open source.
I want to reset the cache when App did enter background, so I did like this:
"

  • (void)applicationDidEnterBackground:(UIApplication *)application
    {
    [[FICImageCache sharedImageCache] reset];
    }
    "

It can reset the cache, but when the app come back to foreground, it will crash with the debug console output
"
Terminating in response to backboardd's termination.
"

I debugged and found maybe the crash happened when executed this function call:
"
int result = ftruncate(_fileDescriptor, fileLength);
"

I want to ask is there any way to reset the FICImageCache correctly when the app did enter background? Thank you!

`FICImageFormat` with variable image size

This is more of a question rather than an issue. But what's the motivation for limiting FICImageFormat to only support images of a fixed dimension? Is there any technical reason supporting unknown dimension images are problematic?

What happens to existing UIImage's when its image table memory is reused for another image?

I may be missing something. I'm tracking down a bug that causes the wrong image to be rendered from time to time. My suspicion is that it's related to reusing entries in the image tables when I exceed the maximum count for a particular format.

If I understand correctly, the whole point of FIC is to provide UIImage's on top of memory mapped files without copying the data. It seems that there's no protection from overwriting the on disk bits of image A with the bits for image B when the cache size is exceeded. If a UIImage was in use for image A, how is this supposed to work?

Am I supposed to set my FICImageFormat maximumCount to be the greatest number that will ever have UIImages allocated concurrently?

BTW, it's very easy for me to reproduce this problem by setting maximumCount down to a very small number. When I do that, I see the wrong images all over my UI.

Unable to delete images

I'm constantly adding images to the table and at the same time removing them when I have used them for our feature. However, our image table keeps growing in size and calling delete on the entity doesn't actually remove the data.

When does the data get deleted?

Problems getting drawingBlockForImage protocol to work in RubyMotion

Hi there - I'm not sure if you'll be able to help, but I'm pulling my hair out trying to get this to work on RubyMotion. The issue is that the block that I return from drawingBlockForImage in my class that implements the FICEntity protocol cannot be invoked by the FastImageCache framework without causing the app to die cold.

My RubyMotion implementation of that method looks like this:

    def drawingBlockForImage(image, withFormatName:formatName)
      lambda do |context, contextSize|
        contextBounds = CGRectZero
        contextBounds.size = contextSize
        CGContextClearRect(context, contextBounds)
        # Clip medium thumbnails so they have rounded corners
        if formatName == "imageFormatNameMediumThumbnail"
          clippingPath = self._clippingPath
          clippingPath.addClip
        end
        UIGraphicsPushContext(context)
        image.drawInRect(contextBounds)
        UIGraphicsPopContext()
      end
    end

And whenever that returned block is called, for example in the FICImageTable method setEntryForEntityUUID:(NSString *)entityUUID sourceImageUUID:(NSString *)sourceImageUUID imageDrawingBlock:(FICEntityImageDrawingBlock)imageDrawingBlock (line 276), the sim just crashes code:

            // Call drawing block to allow client to draw into the context
            imageDrawingBlock(context, [_imageFormat imageSize]);

And I have no idea why. Does anyone have any clues?

Here's a link to the discussion on the RubyMotion groups:

https://groups.google.com/forum/?fromgroups=#!topic/rubymotion/IBeC-p5uY1s

Thanks,
M@

Loading multiple images at once

I've got a view that has 9 images in it. The first time the app launches, it goes to retrieve the images. The problem I'm running in to is that the completion blocks for all the images are being run at around the same time even though they are all processed by the image cache in order.

Is this expected behaviour? I was expecting the completion block to be called as soon as it's done being precessed, that way my UI can have the images populate one by one, not all at the end.

Android

Do you guys have something like FIC that you use for the Path Android app?

I love using FIC on iOS, but I haven't come across anything nearly as good for Android, so I was wondering what Path actually uses.

FICUUIDBytesFromMD5HashOfString causing crash

I am getting a crash on the MD5 line in FICDPhoto.m -> line 170

The crash occurred on scrolling a tableview with images from website after about four screen - fast scrolling the first time and crashed on slow scrolling. exc_bad_access - and then on another attempt without changing anything, it did not crash at all and the scrolling was much faster than what I had before FastImageCache.

Any help would be appreciated.

pragma mark - FICImageCacheEntity

  • (NSString *)UUID {
    if (_UUID == nil) {
    // MD5 hashing is expensive enough that we only want to do it once - CRASH LINE BELOW
    CFUUIDBytes UUIDBytes = FICUUIDBytesFromMD5HashOfString([_sourceImageURL absoluteString]);
    _UUID = FICStringWithUUIDBytes(UUIDBytes);
    }

    return _UUID;
    }

Cancel image loading

Unless I'm completely missing something, there appears to be no way to cancel an image from loading (whether from cache or from network).

This is necessary for image loading in a table view/collection view, to cancel requests that are no longer on screen -- or at the very least, deprioritize them from images that that should be on the screen.

Support for ALAssetsLibrary

Is there any plan to support local images from ALAssetsLibrary?

The current ALAssetsLibrary API only provides access to 4 different image sizes (two thumbnails, a "fullscreen" version and the original).

Anything in-between the "thumbnail" size and "fullscreen" size typically requires pulling in the "fullscreen" size and scaling it (which has obvious performance implications). A caching mechanism that stores a processed version of these assets for later retrieval would be pretty awesome :)

This would make FIC very appealing for apps that provide a custom camera roll experience 👍

Retrieve image in a synchronous way without network call

Hi there,

Is it possible to expose public methods on FICImageCache that wrap calls to these two methods on FICImageTable?

- (BOOL)entryExistsForEntityUUID:(NSString *)entityUUID sourceImageUUID:(NSString *)sourceImageUUID;
- (UIImage *)newImageForEntityUUID:(NSString *)entityUUID sourceImageUUID:(NSString *)sourceImageUUID;

In fact I want to implement lazy loading as exposed in sample code from Apple.
Meaning loading (network calls) images only when the table view is not dragging nor decelerating.

I don't want to perform any retrieveImageForEntity or asynchronouslyRetrieveImageForEntity inside my cellForRowAtIndexPath:, I just want to check if the image is available, and load it (from disk/memory) if so.

Since retrieveImageForEntity is not designed to be 100% synchronous, I consider this API not relevant and don't want to use it due to indeterminate async behavior.

I have already worked on a wrapper (see below) on FICImageCache that make this available but I don't like the design since I need to recreate a FICImageTable each time I call these methods, which will load metadata each time, losing all the great improvements brought by your library.

My wrapper interface:

@interface YSUserImageProvider : NSObject

+ (instancetype)sharedProvider;

- (BOOL)hasPictureForUser:(YSUser *)user formatName:(NSString *)formatName;

// can return `nil` if there is no cached image
- (UIImage *)pictureForUser:(YSUser *)user formatName:(NSString *)formatName;

- (void)retrievePictureForUser:(YSUser *)user formatName:(NSString *)formatName completion:(void(^)(UIImage *image))completion;

- (void)cancelRetrievalPictureForUser:(YSUser *)user formatName:(NSString *)formatName;

- (void)deleteCache;

@end

And the implementation:

- (BOOL)hasPictureForUser:(YSUser *)user formatName:(NSString *)formatName
{
    NSParameterAssert(user != nil);
    NSParameterAssert(formatName != nil);

    FICImageFormat *format = [self.cache formatWithName:formatName];
    FICImageTable *table = [[[FICImageTable alloc] initWithFormat:format] autorelease];

    return [table entryExistsForEntityUUID:[user UUID] sourceImageUUID:[user sourceImageUUID]];
}

Since FICImageCache exposes methods to do nearly anything on images, from manually setting to deleting, I think it would totally make sense to add this feature.

I might create a PR if you agree with this design.

Thanks for your attention and help,
Antoine

Crash if requestURL has blank space

I don't know if I'm doing something very wrong, but it crashed every time my request has a blank space (i.e. in the name of image, http://ralf.moblee.com.br/api/v0//uploads/20131021autoes111/entry/42lugar_b1383916456/lugar bonito.jpg)

The crash itself is:
Exception: EXC_BAD_ACCESS (code=1, address=0x0)) at method CFUUIDBytes FICUUIDBytesFromMD5HashOfString(NSString *MD5Hash)

When I debugged I found the error is when I call retrieveImageForEntity:(id )entity withFormatName:(NSString *)formatName completionBlock:(FICImageCacheCompletionBlock)completionBlock my entity is nil, so when it will create the UUID the [_sourceImageURL absoluteString] is nil

Now follow my code:

RLFPhoto *photo = [[RLFPhoto alloc] init];
[photo setSourceImageURL:[NSURL URLWithString:feed.imageSource]];
BOOL imageExists = [[FICImageCache sharedImageCache] retrieveImageForEntity:photo withFormatName:RLFImageFormatFeedNormal completionBlock:^(id entity, NSString *formatName, UIImage *image)

Not working at all

I have downloaded the code but it's not working. It opens and show there is no image pop up after clicking pop up it gives bad access

Causing the App black

If an image is switched out while Cocoa framework is drawing it, sometimes will cause a tablecell or the entire app black.

memory growth when using completionBlock in wantsSourceImageForEntity:

FastImageCache library and am running into a retain problem.

Specifically, when trying to provide UIImages (downloaded from a server) to the image cache. The images, when handed to the completion block, seems to remain retained. ARC is not releasing is.

When dealing with a very large number of large images, this leads to a dramatic memory growth.

- (void)imageCache:(FICImageCache *)imageCache wantsSourceImageForEntity:(id<FICEntity>)entity withFormatName:(NSString*)formatName completionBlock:(FICImageRequestCompletionBlock)completionBlock
{
    ...
    NSData * data = [NSURLConnection sendSynchronousRequest:urlRequest
                                              returningResponse:&response
                                                          error:&error];
    UIImage* image = [[UIImage alloc] initWithData:data];
    completionBlock(image); // <-----
    ...
}

I verified that not calling the completion block with the image, does not lead to the memory growth.

Also, not using the image in the drawing block itself, also avoids the memory growth. So i assume this is indeed related to the image being retained.

- (FICEntityImageDrawingBlock)drawingBlockForImage:(UIImage*)image withFormatName:(NSString*)formatName
{
    FICEntityImageDrawingBlock drawingBlock = ^(CGContextRef contextRef, CGSize contextSize) {
        CGRect contextBounds = CGRectZero;
        contextBounds.size = contextSize;
        CGContextClearRect(contextRef, contextBounds);
        CGContextSetInterpolationQuality(contextRef, kCGInterpolationMedium);
        UIGraphicsPushContext(contextRef);
        [image drawInRect:contextBounds]; // <---- 
        UIGraphicsPopContext();
    };

    return drawingBlock;
}

How can i avoid the image being retained or how can i force it to be released? I tried setting it to nil and adding a @autoreleasepool but that didn't help.

@autoreleasepool {
        NSData * data = [NSURLConnection sendSynchronousRequest:urlRequest
                                              returningResponse:&response
                                                          error:&error];

        UIImage* image = [[UIImage alloc] initWithData:data];
        completionBlock(image);
        image = nil;
        data = nil;

        [[NSURLCache sharedURLCache] removeAllCachedResponses];
    }

FICEntity supporting multiple images

Great work on this library. Unless I'm mistaken, outside of resizing an image it seems unable to support different images being associated with a FICEntity - is this by design?

Taking the documentation example of a Core Data user object implementing the FICEntity protocol, we might have a user object containing both a profile photo and a cover photo URL.

I've been unable to find a way to integrate FIC within such a core data object as (NSString *)sourceImageUUID only allows one sourceImageUUID to be returned. I'm therefore creating multiple associated objects implementing FICEntity which seems excessive.

(NSURL *)sourceImageURLWithFormatName:(NSString *)formatName provides the formatName allowing for an appropriate URL to be returned for the given formatName, in our example either the profile photo of cover photo. Should (NSString *)sourceImageUUID pass in the formatName so a sourceImageURL appropriate UUID can be returned?

Again great work on the library, a brilliant contribution to the community.

Best wishes,
-Jim

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.