Hi, I'm Alex (short for Alexander).
- Blog: kean.blog
- Built Nuke, Pulse, and other popular frameworks and tools
- Developed the initial CreateAPI version which is now maintained by @cookpad
Contacts
- Mastodon: @[email protected]
Image loading, processing, caching and preheating
License: MIT License
Hi, I'm Alex (short for Alexander).
Contacts
DFImageManagerErrorUnkown
, which should be created each time the request fails for unknown reason (reason was not provided by image fetcher or image processor)My app loads a new image every couple of seconds, and I would like to preload into cache a couple of images in advance. I'm worried this might over use the memory.
Does DFImageManager supports a manual way to empty the cache?
You've created a very useful and powerful lib. Thank you!
hello
i am in the process of porting to DFImageManager from SDWebImage :) - one of the main reason, the GIF support.
right now i have a few collectionviews (inside uitabbarcontroller) each with a bunch of cells (mtl.image is DFImageView).
doing something like
[mtl.image prepareForReuse];
[mtl.image setAllowsAnimations:NO];
[mtl.image setImageWithResource:[NSURL URLWithString:obj.imageUrl]];
loading the same datasource, into two tabs (collection views) - sometimes does not load images in one collectionview, and in the other it does (mainly on GIFS), i have no clue where to start debugging, any hints?
regards
helmut
Changes to completion block:
Completion block should follow simple rules:
Other changes:
These changes would allow for better compiler checks, better discoverability of APIs and better performance.
Improve DFImageManager synchronization implementation:
DFImageTask
should change state synchronously on the callers threadDFImageManager
invalidation should be thread safeDepends on #34
DFImageViewDelegate
protocol should work as a standard Cocoa protocol. It should not be implemented by DFImageView
itself and it should not be used to set the image on the image view. It should only notify clients.didCompleteRequest:withImage:info:
method to DFImageView
-resume
method to DFImageTask
, tasks should not start automatically. This change would enable some new use cases-imageTaskWithRequest:completion:
and -imageTaskWithResource:completion:
methods to DFImageManaging
protocol-requestImageForRequest:completion:
and -requestImageForResource:completion:
methods deprecatedInvestigate NSProgress, might not be worth the effort.
DFImageManager should have a single responsibility of providing a great API for managing image requests (and that's a lot of work). Users should be able to easily plug-in everything else. That's the way the GIF support was implemented in version 0.1 - as a subspec that integrated FLAnimatedImage. That's how the networking should be implemented - as a subspec that integrates AFNetworking with all its goodness. AFNetworking should be a primary option for networking, but DFImageManager will still have it's basic, extensible networking implementation.
DFImageManagerKit+UI.h
[self.imageViewIcon df_setImageWithResource:[NSURL URLWithString:data.imageUrl]];
Crashes here:
- (DFImageTask *)imageTaskForRequest:(DFImageRequest *)request completion:(DFImageRequestCompletion)completion {
id<DFImageManaging> manager = DFManagerForRequest(request);
if (!manager) {
[NSException raise:NSInvalidArgumentException format:@"There are no managers that can handle the request %@", request];
}
return [manager imageTaskForRequest:request completion:completion];
}
Not really a bug, as I passed nil instead of NSURL, but still I think crashing is not the best choice.
DFImageRequestID
to DFImageTask
(similar to Nuke)_DFImageTask
interfaces like state
, request
, error
, completionHandler
etcDFImageInfoRequestIDKey
to DFImageInfoTaskKey
Based on this discussion
is it possible to supply a 100 images may be which the app keeps fetching and storing in the cache even when the app goes to background?
Change DFImageFetching -startOperation:... method return type to custom protocol, because:
Use FLAnimatedImage.
Preferably wait for version 2.0, when they make FLAnimatedImage into a UIImage subclass (branch is in active development). Otherwise do it using DF classes.
This currently will not build if included in a dynamic framework via CocoaPods. The issue appears to be with importing FLAnimatedImage in DFImageView.h. It throws an error on line 27 with "'FLAnimatedImage.h' file not found."
DFImageRequestOptions could contain an option GIFFirstFrameOnly
which downloads only the first GIF frame
for situation, if you want to have a play button on GIF and display the first frame placeholder
(optional, in the progressHandler you could retrive the first frame once available)
-pause
method to DFImageTask
DFImageManager
should be able to put tasks back into suspended stateDFImageFetching
protocol. Waiting for #29could you plz add a tap event to the image,
and if we can view them and share them it will be great
DFImageProcessing add shouldProcessImage:forRequest: method that would allow DFImageManager to skip processing operation entirely
Aspect fit doesn't appear to be working properly when setting a DFImageView's image using setImageWithRequest: and the request's contentMode set to DFImageContentModeAspectFit. Mine are doing a fill instead.
Move some functionality out of DFImageManager. Create a separate class to control image loading that should:
Add - (void)getImageTasksWithCompletion:(void (^)(NSArray *tasks, NSArray *preheatingTasks))completion;
to DFImageManaging
protocol.
This is how it works right now:
- (void)startPreheatingImagesForRequests:(nonnull NSArray *)requests {
for (DFImageRequest *request in requests) {
[DFManagerForRequest(request) startPreheatingImagesForRequests:@[request]];
}
}
Composite image manager should use a dispatch table instead.
DFImageManager
's memory cache fast path should be completely transparent to the clients:
requestImageForRequest:completion:
and requestImageForResource:completion:
should always return requestIDrequestID
should be added to the info dictionary in the completion blockDFCachedImage
to DFCachedImageResponse
which should store now only response image, but response metadata tooI'm using a DFImageView with a default image in a UICollectionViewCell, then calling setImageWithResource: to fetch a remote image. Is the new image transition suppose to animate? I'm assuming that's what the allowsAnimations property is for, which says default is YES. But the image change is very abrupt.
DFImageManager
internal tasks should hold strong references to the image manager.invalidateAndCancel
method to DFImageManaging
protocol that would cancel all existing image tasks registered with image manager. New tasks may not be created.df_isWebPData
method to WebP
subspecI'm using a DFImageView in a UICollectionViewCell and calling the setImageWithResource: method. The caching seems to work as long as my app is open, but every time I restart the app it downloads the images again remotely. Is there some additional configuration needed to make the cache persist across app launches?
See lightweight generics
for Objective-C
Completely redesign DFCompositeImageTask
(previous DFImageFetchTask
)
DFCompositeImageTask
with image tasks (instances of DFImageTask
class), not requestsDFImageFetchTask
to DFCompositeImageTask
, since we now have DFImageTask
DFImageFetchContext
, use new DFImageTask
properties instead; Remove contextForRequest:
methodstartTime
and elapsedTime
from DFCompositeImageTask
DFCompositeImageTask
by unit testsFor some unexplainable reason this line got into commit 76b1576. And it results in a significant performance hit, especially on older devices.
More of a question than a bug, but are GIFs supported for PHAssets or just remote resources loaded via url? I ended up inspecting the UTI in the info dictionary and then loading the GIF as data with the standard -[PHImageManager requestImageDataForAsset:options:resultHandler:]. Thanks and nice framework ... can't believe I hadn't seen it till now.
Add WebP support in a separate subspec.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.