Gensoukyou1337
Gensoukyou1337

Reputation: 1527

Glide 4.0.0 fails to load GIFs from URL with a strange size change and DecodePath issues

My code looked like this:

GlideApp.with(c)
    .asGif()
    .load(pathToPicture)
    .into(memePicView);

This netted me the following stacktrace

W/Glide: Load failed for https://img.memecdn.com/japan-strikes-again_webm_3923465.gif with size [-2147483648x-2147483648]
    class com.bumptech.glide.load.engine.GlideException: Failed to load resource
        Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{ContentLengthInputStream->GifDrawable->GifDrawable}, REMOTE
            Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{ContentLengthInputStream->GifDrawable->GifDrawable}

I could access said gif from the browser, and the size of that gif is not [-2147483648x-2147483648]. Was there some setting that I missed, and do I have to implement an okhttp or Volley integrated App Glide Module?

And I do have the Internet permission in my Manifest. In case anyone asks.

I've tried downloading the GIF into the app's internal data directory and loading it from there with Glide. Still no dice with the exact same error, except replace ContentLengthInputStream with FileInputStream.

Upvotes: 3

Views: 2550

Answers (4)

Aliaksei
Aliaksei

Reputation: 3642

To fix this kind of problem with Gif-images loading try to use

options.set(GifOptions.DISABLE_ANIMATION, false)

For example (Kotlin):

GlideApp.with(c)
    .asGif()
    .load(pathToPicture)
    .into(memePicView)

change to:

GlideApp.with(c)
    .asGif().apply {
        options.set(GifOptions.DISABLE_ANIMATION, false)
    }
    .load(pathToPicture)
    .into(memePicView)

Upvotes: 0

Sam Judd
Sam Judd

Reputation: 7387

https://img.memecdn.com/japan-strikes-again_webm_3923465.gif is not a GIF. It looks like a webm, which is a movie format. Not sure why, but lots of websites are using the .gif extension for non-gif files, including animated webp and movie files.

Upvotes: 3

Nguyễn Trung Hiếu
Nguyễn Trung Hiếu

Reputation: 2032

Remove asGif() and It will work!

GlideApp.with(c)
.load(pathToPicture)
.into(memePicView);

Refer: https://futurestud.io/tutorials/glide-displaying-gifs-and-videos

Upvotes: 0

fida1989
fida1989

Reputation: 3249

Try to load the gif with ion library:

Ion.with(imageView)
.placeholder(R.drawable.placeholder_image)
.error(R.drawable.error_image)
.animateLoad(spinAnimation)
.animateIn(fadeInAnimation)
.load("http://example.com/image.png");

Upvotes: 0

Related Questions