Flipboard / FLAnimatedImage

Performant animated GIF engine for iOS
MIT License
7.94k stars 1.22k forks source link

Gif play is slow, when the duration is more than 5 second #179

Open pdpraful opened 7 years ago

pdpraful commented 7 years ago

I am using this library to play gifs. When the duration of gifs is more than 6 seconds, the animation play is delayed to 10 seconds of overhead (i.e total time is 16 seconds to call the loop completion block). I am getting a frame rate of 60FPS from GPU. But, the CPU is high @ >70%. screen shot 2017-04-26 at 8 54 47 pm

kyam915 commented 7 years ago

I solved it by using UIWebView.

let webView = UIWebView(frame: CGRect(x: 0, y: 0, width: Design.screenWidth, height: Design.screenWidth))
webView.isUserInteractionEnabled = false
webView.backgroundColor = .clear
webView.isOpaque = false
webView.load(data, mimeType: "image/gif", textEncodingName: "utf-8", baseURL: NSURL() as URL)
self.view.addSubview(webView)
N7Alpha commented 6 years ago

If you're using @kyam915 workaround you'll also probably want to set this on the web view, so the gif is contained within the bounds of the view.

webView.scalesPageToFit = true