GIF App Development – Challenges & Tips

In past years, GIFs have managed to become quite popular. These GIFs are usually a perfect way to respond to a funny message you have received or to express some other kind of emotion thru a message. They now pervade everything from popular culture to ad campaigns. For the next-gen of designers and developers, knowing your way around motion graphics and having a good knowledge of the basics of creating a GIF is important. In this article, we’ll discuss GIFs app development on the Android platform. It’s worth knowing what challenges you can expect during GIF app development, and how to handle them.

GIF App Development – Challenges & Tips

Why Android doesn’t support GIFs natively?

Since the beginning, GIF app support on Android was never perfect, up to Android 8 the system itself used to support only non-animated GIFs displaying and without encoding support.

Starting from Android 9, Image Decoder exists and this can produce GIF Image Drawables. However, these classes are only part of the platform and aren’t backported to AndroidX Jetpack, now (June 2020), only about 40 percent of users can benefit from them.

Why GIF support is so complicated on Android?

Initially, it is much more problematic to develop displaying an animated image, than the static image. Next, encoding is more complicated than decoding so we have difficulty in both.

Static vs animations images

The main differences between static images are PNG or JPG files, and animations are GIF files, but GIFs can also be not animated.
Static image decoding usually taking inputs from a local file or image URL and producing output like a bitmap 2D array of pixels. After, everything is up to the UI layer, and the decoder does not require to care about that. Note that we are considering the simple case now displaying an image as is.

Animation can be defined as an order of static images

The decoding process contains multiple aforementioned steps. But there are more factors to consider. Initially, we require some kind of a ticker or clock that is responsible for advancing the time means that switching to subsequent frames.

Such a ticker needs to be aware of the UI lifecycle. Especially it needs to be disposed of when UI is no longer alive for instance user pressed the back button or simply navigate to another app. Handling the Android UI lifecycle properly is a significant challenge for developers to build it. In Android applications, a lot of bugs and crashes are caused by leaks which are effects of improper lifecycle handling. Especially the Movie class used recently for GIF decoding also used to leak. After 60 days another one was exposed.

Encoding vs decoding

GIF encoding process is much more complicated than decoding. There are two main reasons. Image data in the GIF file is separated into multiple frames. But, they are not always the same as physical film frames. Let’s take a look at the below animation:

1. The most effective way of encoding is to store only differences of subsequent frames:

GIF App Development – Challenges & Tips

2. Of course, nothing prohibits from saving the full-sized second frame like this:

GIF App Development – Challenges & Tips

3. However, doing so will cause the complete GIF file size will be much

GIF App Development – Challenges & Tips

Note, that GIF files used in real-time usually contain dozens of frames, larger than one in this simple example. Extracting differences between subsequent frames is not a small problem. The computer and mobile displays, image formats GIF, JPG, PNG, etc, use 24-bit color depth. That means about 16 million colors.

Even a single GIF frame may only consist of up to 256 different colors. As you can remember from the previous paragraphs. So, let’s look to pack 16 million possibilities into 256 places. Well, it is pretty hard to do that effectively, but many techniques have been created, they are collectively called dithering. Encoding is a complicated process, and it needs to work on Android devices with reasonable performance.

How to deal with difficulties in GIF app development?

GIF app development for Android is not easy and creating more problems, is there any way to solve them all? Well, we will need to discover some partial solutions which can be further assembled. Now GIF decoding is handled by third-party libraries like Glide, Coil. Android-gif-drawable is more complicated operations involving such as rendering. But GIF encoding on Android will need additional development and familiarity with NDK.

As you can see, create animated GIFs is much harder than displaying them.

  • GIF app development for Android needs additional time for research and testing.
  • When choosing a development team that will develop your GIF maker app for Android, make sure they are familiar with Android NDK.
  • As these types of projects are not a piece of cake, it’s worth working with a team that already has experience in creating similar applications.
  • A solution recommended today, may become obsolete and deprecated for development and future maintenance.