flipboard / flanimatedimage Goto Github PK
View Code? Open in Web Editor NEWPerformant animated GIF engine for iOS
License: MIT License
Performant animated GIF engine for iOS
License: MIT License
Hi @raphaelschaad !
I'm trying to retrieve all the images of a gif, howerver this only works when the size of the gif is less than 1.5 mb. Is that normal ?
If yes, do you another way to retrieve all the images of a gif ?
Thank you :)
See comment in code when setting up the run loop mode for the CADisplayLink
as a starting point: https://github.com/Flipboard/FLAnimatedImage/blob/master/FLAnimatedImageDemo/FLAnimatedImage/FLAnimatedImageView.m#L84
Merging -setAnimatedImage: and -setImage: into a single method makes the API easier to adopt.
Crashed: com.apple.main-thread
EXC_BAD_ACCESS KERN_INVALID_ADDRESS at 0xbf00bdf0
getMethodNoSuper_nolock(objc_class_, objc_selector_) + 23
CFRelease + 560
_CGImagePlusFinalize + 120
CFRelease + 466
CFRelease + 466
_CGImageSourceFinalize + 134
CFRelease + 466
FLAnimatedImage.m line 316
-[FLAnimatedImage dealloc]
objc_object::sidetable_release(bool) + 174
FLAnimatedImageView.m line 62
-[FLAnimatedImageView setAnimatedImage:]
Hey guys,
first of all great library! I have the scenario where I want to be able to animate a GIF only once but I don't want to modify the GIF because on other places I do want the infinitive loop.
I found the loopCount
property on FLAnimatedImage
which when I modify the readonly
flag and set it to 1 gives me exactly the outcome I want.
Is it possible to make it writable without me having to fork it?
Swift is Apple's new programming language.
Hi,
I'm getting the following error while building.
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_DDLog", referenced from:
objc-class-ref in FLAnimatedImage.o
objc-class-ref in FLAnimatedImageView.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I'm sure that the solution is easy but, for the life of me, can't figure out the solution.
Any help is welcome!
Thanks!
Here at Medium we are using FLAnimatedImage
for a project and we've seeing crashers that you might be experiencing as well.
This is the stack:
Thread : Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x37c8b8e0 _objc_trap() + 18446744073709552000
1 libobjc.A.dylib 0x37c8b945 _objc_inform
2 libobjc.A.dylib 0x37c9a3c7 weak_register_no_lock + 182
3 libobjc.A.dylib 0x37c9a6ff objc_storeWeak + 110
4 ooooooo 0x00229297 +[FLWeakProxy weakProxyForObject:]
5 ooooooo 0x00229549 -[FLAnimatedImageView displayLink]
6 ooooooo 0x002298c7 -[FLAnimatedImageView stopAnimating]
7 UIKit 0x2fd5db09 -[UIImageView dealloc] + 64
8 ooooooo 0x00229651 -[FLAnimatedImageView dealloc]
9 ooooooo 0x0016d05d -[MDImageView dealloc]
10 libdispatch.dylib 0x3817381f _dispatch_client_callout
11 libdispatch.dylib 0x3817a49f _dispatch_main_queue_callback_4CF$VARIANT$mp
12 CoreFoundation 0x2d50b8f1 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 8
13 CoreFoundation 0x2d50a1c5 __CFRunLoopRun + 1300
14 CoreFoundation 0x2d474f0f CFRunLoopRunSpecific + 522
15 CoreFoundation 0x2d474cf3 CFRunLoopRunInMode + 106
16 GraphicsServices 0x32396663 GSEventRunModal
17 UIKit 0x2fdc016d UIApplicationMain + 1136
18 ooooooo 0x000bdef3 main (main.m:20)
I suspect that the call that UIImageView's dealloc to stopAnimating is unexpected. What ends up happening is that, on stopAnimating, displayLink tries to be recreated. I don't fully understand what this implies and results in a crash, but maybe there's a way to stop this from happening.
Also I am happy to contribute on a fix to this, but I'd rather have pointers from the authors of the library as to what you think it's the best approach to fix this.
Thanks!
Ok, first I have my Gif in storyboard and I have the IBOutlet like this in my view:
@IBOutlet weak var imageGIF: FLAnimatedImageView!
But i'm receiving an error of NSUnknownKeyException: this class is not key value coding-compilant for the key imageGIF.
And second, how can I play any GIF in Swift? I'm kinda stuck in this for like a week.
Enables the framework to be included in App Extensions. Everything still builds just fine.
Any FLAnimatedImageView instances that are placed in a collection view cell's content view seem go black on receiving a touch. On recreating the cell (via scrolling the cell out-of and back into view again), it no longer goes black on receiving a touch. I am adding the FLAnimatedImageView to the cell's contentView using IB, for what its worth.
FLAnimatedImage fully supports iOS 5 and 6 but the demo player doesn't, because of simple UI and sample project customization that needs to get done before lowering the deployment target.
Maybe a .playground file can be complementary to the demo project.
More of a feature request than issue, but it would be great if someone with the know how would create a mono wrapper for this to decrease the barrier to entry even further.
It seems that got deprecated.
Can play remote gif through url or not? Thanks
Current image caches generally return objects of a single type, like UIImage or NSImage. It's hard to plug FLAnimatedImage into existing caches because objects of different classes will have to be returned and type checked.
It's a bit of work, but inheriting from UIImage and overriding all the default initializers would also make the API easier to adopt, though this could be done without subclassing.
Verbose: Rounding frame 5's
delayTime from 0.000000 up to default 0.100000 (minimum supported: 0.020000).
When I create a project that contains both FLAnimatedImage 1.0.3 and CocoaLumberjack 2.0.0-beta3, I get the following linker error:
Undefined symbols for architecture x86_64:
"_ddLogLevel", referenced from:
-[FLAnimatedImageView displayDidRefresh:] in libPods-testapp-FLAnimatedImage.a(FLAnimatedImageView.o)
+[FLAnimatedImage initialize] in libPods-testapp-FLAnimatedImage.a(FLAnimatedImage.o)
-[FLAnimatedImage init] in libPods-testapp-FLAnimatedImage.a(FLAnimatedImage.o)
-[FLAnimatedImage initWithAnimatedGIFData:] in libPods-testapp-FLAnimatedImage.a(FLAnimatedImage.o)
-[FLAnimatedImage imageLazilyCachedAtIndex:] in libPods-testapp-FLAnimatedImage.a(FLAnimatedImage.o)
-[FLAnimatedImage addFrameIndexesToCache:] in libPods-testapp-FLAnimatedImage.a(FLAnimatedImage.o)
___42-[FLAnimatedImage addFrameIndexesToCache:]_block_invoke_2 in libPods-testapp-FLAnimatedImage.a(FLAnimatedImage.o)
...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I'm also seeing it with CocoaLumberjack 1.9.x. I can replicate this by creating an empty project with just those two pods added.
Seeing this in our app, seems like the debug log could be inside of the debug conditional block?
In:
2015-06-09 13:52:15:996 MyApp[58268:607] Waiting for frame 1 for animated image: <FLAnimatedImage: 0x7fb201d701a0> size={640, 1136} frameCount=48
2015-06-09 13:52:16:012 MyApp[58268:607] Waiting for frame 1 for animated image: <FLAnimatedImage: 0x7fb201d701a0> size={640, 1136} frameCount=48
2015-06-09 13:52:16:112 MyApp[58268:607] Waiting for frame 2 for animated image: <FLAnimatedImage: 0x7fb201d701a0> size={640, 1136} frameCount=48
2015-06-09 13:52:16:213 MyApp[58268:607] Waiting for frame 3 for animated image: <FLAnimatedImage: 0x7fb201d701a0> size={640, 1136} frameCount=48
2015-06-09 13:52:16:312 MyApp[58268:607] Waiting for frame 4 for animated image: <FLAnimatedImage: 0x7fb201d701a0> size={640, 1136} frameCount=48
2015-06-09 13:52:16:396 MyApp[58268:607] Waiting for frame 5 for animated image: <FLAnimatedImage: 0x7fb201d701a0> size={640, 1136} frameCount=48
2015-06-09 13:52:16:495 MyApp[58268:607] Waiting for frame 6 for animated image: <FLAnimatedImage: 0x7fb201d701a0> size={640, 1136} frameCount=48
2015-06-09 13:52:16:596 MyApp[58268:607] Waiting for frame 7 for animated image: <FLAnimatedImage: 0x7fb201d701a0> size={640, 1136} frameCount=48
2015-06-09 13:52:16:696 MyApp[58268:607] Waiting for frame 8 for animated image: <FLAnimatedImage: 0x7fb201d701a0> size={640, 1136} frameCount=48
2015-06-09 13:52:16:796 MyApp[58268:607] Waiting for frame 9 for animated image: <FLAnimatedImage: 0x7fb201d701a0> size={640, 1136} frameCount=48
2015-06-09 13:52:16:879 MyApp[58268:607] Waiting for frame 10 for animated image: <FLAnimatedImage: 0x7fb201d701a0> size={640, 1136} frameCount=48
2015-06-09 13:52:16:979 MyApp[58268:607] Waiting for frame 11 for animated image: <FLAnimatedImage: 0x7fb201d701a0> size={640, 1136} frameCount=48
2015-06-09 13:52:17:093 MyApp[58268:607] Waiting for frame 12 for animated image: <FLAnimatedImage: 0x7fb201d701a0> size={640, 1136} frameCount=48
2015-06-09 13:52:17:106 MyApp[58268:607] Waiting for frame 12 for animated image: <FLAnimatedImage: 0x7fb201d701a0> size={640, 1136} frameCount=48
2015-06-09 13:52:17:196 MyApp[58268:607] Waiting for frame 13 for animated image: <FLAnimatedImage: 0x7fb201d701a0> size={640, 1136} frameCount=48
2015-06-09 13:52:17:296 MyApp[58268:607] Waiting for frame 14 for animated image: <FLAnimatedImage: 0x7fb201d701a0> size={640, 1136} frameCount=48
2015-06-09 13:52:17:379 MyApp[58268:607] Waiting for frame 15 for animated image: <FLAnimatedImage: 0x7fb201d701a0> size={640, 1136} frameCount=48
2015-06-09 13:52:17:479 MyApp[58268:607] Waiting for frame 16 for animated image: <FLAnimatedImage: 0x7fb201d701a0> size={640, 1136} frameCount=48
2015-06-09 13:52:17:579 MyApp[58268:607] Waiting for frame 17 for animated image: <FLAnimatedImage: 0x7fb201d701a0> size={640, 1136} frameCount=48
2015-06-09 13:52:18:520 MyApp[58268:607] Waiting for frame 18 for animated image: <FLAnimatedImage: 0x7fb201d701a0> size={640, 1136} frameCount=48
2015-06-09 13:52:18:620 MyApp[58268:607] Waiting for frame 19 for animated image: <FLAnimatedImage: 0x7fb201d701a0> size={640, 1136} frameCount=48
2015-06-09 13:52:18:704 MyApp[58268:607] Waiting for frame 20 for animated image: <FLAnimatedImage: 0x7fb201d701a0> size={640, 1136} frameCount=48
2015-06-09 13:52:18:804 MyApp[58268:607] Waiting for frame 21 for animated image: <FLAnimatedImage: 0x7fb201d701a0> size={640, 1136} frameCount=48
2015-06-09 13:52:18:904 MyApp[58268:607] Waiting for frame 22 for animated image: <FLAnimatedImage: 0x7fb201d701a0> size={640, 1136} frameCount=48
See this branch: https://github.com/tijoinc/FLAnimatedImage/tree/mutiple-views-same-image
If you create multiple instances of FLAnimatedImageView
that refer to the same instance of FLAnimatedImage
loading stutters and stops.
The image loading methods within FLAnimatedImage
are intended to only be loading frames for a single image view at a time, would be good to loosen this. The best approach I can think of is to move the image loading/preloading logic into FLAnimatedImageView
itself and have FLAnimatedImage
simply serve up frames as requested.
A stopgap solution is to make FLAnimatedImage
conform to NSCopying
and give the copy
attribute to FLAnimatedImageView
's animatedImage
property.
I'm trying to use FLAnimatedImage to show 84 gif in collection view. But i can't do this my app perfect work in simulator but doesn't work on real device. I had next code:
const int NUMBER_OF_GIFS = 84;
@Property (strong, nonatomic) FLAnimatedImage *gifImage;
for (int i = 0; i < NUMBER_OF_GIFS; i++) {
self.gifImage = [[FLAnimatedImage alloc] initWithAnimatedGIFData:[NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%i", i] ofType:@"gif"]]];
[self.gifsArray addObject:self.gifImage];
self.gifImage = nil;
}
Allow for frames to be displayed and played as the GIF file is still being fetched from the network.
See this first prototype of it: geoffmacd@e87569d
WatchKit has its own way of playing animations/image sequences/animated GIFs (https://developer.apple.com/library/prerelease/ios/documentation/WatchKit/Reference/WKInterfaceImage_class/index.html#//apple_ref/occ/instm/WKInterfaceImage/startAnimatingWithImagesInRange:duration:repeatCount:) but it could be useful to leave the correct parsing of GIF data up to a library. Thoughts?
I know that this is probably unrelated to FLAnimatedImage, but I thought you might be able to help me out. I'm downloading gifs from the network, and they have a large file size, so I just want them to be plain old UIImage that take up minimum RAM.
What's happening though is that I'm getting _UIAnimatedImage
in the imageview which are presumably being animated by the system (I'm using an FLAnimatedImageView). This baloons up memory usage(>500MB), causing my app to crash.
Do you have any pointers as to how to disable either the creation of _UIAnimatedImage
or stopping the animation? Any methods I can set a break point on to track this? Thanks. (FWIW, SDWebImage is responsible for creating UIImages out of network data.)
Happy to provide more info.
And gracefully fall back, if not.
Related discussion: CocoaPods/CocoaPods#598
Is there a way to reset an animation back to frame 0 programmatically? Or better yet a way to load the image in a non-animated state?
Is there a way to change Gif Speed?
For example, change value of UISlider , gif speed changes.
I tried to change animationDuration.FLAnimatedImageView, but did not work well.
I create a breakpoint in FLAnimatedImage in
Looked through the project and comments where I thought I'd find something, but I've been unable to find anything that explains why the GIFs are paused during an animation. This is the only flaw with the class as far as I can tell, everything else works perfectly.
FLAnimatedImage supports iOS 6+ but the demo player is at 7+ because of some adjustments that need to happen before lowering the deployment target.
See previous (closed) issue: #7
This is a great tool for apps that heavily use GIF's but CPU use is high when caching is limited to a few frames. This is due to the decoding of the images on demand which is performed by the CPU as I understand. It'd be great it if we could use the GPU instead. Have you looked into this?
Is there anyway to detect when the animation has ended AFTER it has gone to the end and THEN gone backwards back to the start?
Sometime a GIF image not play till the end. I don't sure what is the cause of this problem. Is there any way I can detect corrupted/incomplted GIF file?
If my gif have a clear background how can I make FLAnimatedImage to load it?
I'm using this:
convenience init(gifResource: String) { let imagePath = NSBundle.mainBundle().pathForResource(gifResource, ofType: "gif") self.init(animatedGIFData: NSData(contentsOfFile: imagePath!)) }
It doesn't seem to support the minimum delayTime. That's probably due to float and double comparison, even though wrapped in NSNumber.
Verbose: Rounding frame 183's `delayTime` from 0.020000 up to default 0.100000 (minimum supported: 0.020000).
We could support reverse playback on the view-level. The API could be:
@property (nonatomic, assign) BOOL shouldPlayReverse; // Can be changed during playback; default is NO
(Compare AVPlayerItem's canPlayReverse
API.)
The data provider (image) would have know about it and reverse all it's internal caching logic too. To know about it, we could extend the method -imageLazilyCachedAtIndex:
to include a BOOL.
Maybe it's also time to add a tighter coupling/delegate from image -> to view so the data provider has a better understanding of the view(s) that are displaying its frames. This could be an approach to fix Multiple image views referencing the same image cause loading to malfunction #33 too.
We used to have properties like
@property (nonatomic, strong) NSURL *debugOriginalURL;
...
etc. to track certain debugging data.
I'm thinking just one NSDictionary like
@property (nonatomic, strong) NSDictionary *debug_info;
and leave it up to the "client classes" (e.g. image loading operations) to define keys and store/query the value, should do it.
Is there a way to jump to a specific frame of a GIF? This would be a huge help when trying to sync two views with the same GIF.
I'm using the FLAnimatedImage and it doesn't seem like the gif is getting animated. I'm using a local gif like so:
FLAnimatedImage *image =
[[FLAnimatedImage alloc] initWithAnimatedGIFData:[NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:filename ofType:@"gif"]]];
self.testImageView.animatedImage = image;
No issue whatsoever on iOS 8 but I can't get the GIF to animate on iOS7. I tried with startAnimating but that does not seem to help (plus it seems like it's not necessary).
Hey Guys, I'll be working on giving you guys some unit tests at the test jam today.
We use CocoaLumberjack in Medium's app and we declare ddLogLevel
as:
extern int ddLogLevel;
The project now fails with the following error:
/workspace/Pods/Headers/Public/FLAnimatedImage/FLAnimatedImage.h:115:22: redefinition of 'ddLogLevel' with a different type: 'const int' vs 'int'
extern const int ddLogLevel;
What do you think?
Hi,
I am using FLAnimatedImage in my game.
It is really nice.
But when i place this gif over SpriteKit's SKScene , unfortunately speed of my gif was decreased.
Same "FLAnimatedImage" object give different effect when it place over UIVIEW & it place over SKScene.
When it place over UIVIEW it gives normal effect but when it placed over SKScene it becomes very slew.
Any suggestions will be appreciated.
Currently both headers, FLAnimatedImage.h
and FLAnimatedImageView.h
need to be imported. It seems it would make sense to just make it one.
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.