luberda-molinet / FFImageLoading

Image loading, caching & transforming library for Xamarin and Windows
MIT License
1.42k stars 377 forks source link

GIF running slower than expected #915

Closed Patapits closed 6 years ago

Patapits commented 6 years ago

Description

I'm developping my first application with Xamarin.Forms and I use FFImageLoading to handle all my images. I wanted to add some loading GIF to my application, but the result is an animated image that ran slower than on my computer or in a web browser (this one, for instance). I checked the source code to find out why, and it seems like the problem is this line :

https://github.com/luberda-molinet/FFImageLoading/blob/4e6dfd61ab855f01b859343780642242aae8a20c/source/FFImageLoading.Common/Helpers/GifHelperBase.cs#L551

I edited the source code to replace it with this line :

delay = ReadShort() * 10; // delay in milliseconds

And it seems to work without any problem. Is there a reason for using Max when parsing GIF metadata ?

Steps to Reproduce

Changing this line :

https://github.com/luberda-molinet/FFImageLoading/blob/4e6dfd61ab855f01b859343780642242aae8a20c/samples/ImageLoading.Forms.Sample/Shared/Pages/SimpleGifPageModel.cs#L10

With :

ImageUrl = "https://loading.io/spinners/coolors/lg.palette-rotating-ring-loader.gif";

And running the project FFImageLoading.Forms.Sample.Droid

Expected Behavior

The animation to run at it's defined framerate.

Actual Behavior

The animation is running with a Delay of 100ms between each frame (instead of 30ms I think).

Basic Information

daniel-luberda commented 6 years ago

Yes, it's set for performance reasons. Most of mobile (and even some desktop too) browsers have that limit set to 10ms.

However you found a bug, mistakenly it was set to 100ms instead 10ms, fixing it now. Thanks!