Glide: fail to load redirect URLS

Created on 22 Feb 2017  路  9Comments  路  Source: bumptech/glide

When using trying to retrieve a Facebook profile picture for instance:

https://graph.facebook.com/100001114770491/picture?type=large

wich redirects to:
https://scontent.xx.fbcdn.net/v/t1.0-1/p200x200/207079_182469695133522_4696277_n.jpg?oh=5bc9d03c506f3af51e59d0169e141e3b&oe=5944ACBA

this falls back into the error placeholder (maybe because it doesn't end with a known extension? )

final String imageUrl = teammate.getImageURL();
Glide.with(context)
                            .load(teammate.getImageURL())
                            .skipMemoryCache(true)
                            .diskCacheStrategy(DiskCacheStrategy.NONE)
                            .placeholder(R.drawable.ic_launcher)
                            .error(R.drawable.ic_launcher)
                            .into(ivFirstFriend);  

whereas doing the exact same thing with Picasso it does work:

Picasso.with(context)
                            .load(imageUrl)
                            .placeholder(R.drawable.ic_launcher)
                            .memoryPolicy(MemoryPolicy.NO_CACHE,MemoryPolicy.NO_STORE)
                            .into(ivFirstFriend);

Currently using:
compile 'com.github.bumptech.glide:glide:3.7.0'

I tested this on a Nexus 5, One Plus One and Nexus 6P

Stack trace / LogCat:

02-22 13:49:08.265 1539-1539/? W/Binder_A: type=1400 audit(0.0:3362): avc: denied { ioctl } for path="socket:[627446]" dev="sockfs" ino=627446 ioctlcmd=7704 scontext=u:r:system_server:s0 tcontext=u:r:system_server:s0 tclass=unix_stream_socket permissive=0
02-22 13:49:08.265 1539-1539/? W/Binder_A: type=1400 audit(0.0:3363): avc: denied { ioctl } for path="socket:[627446]" dev="sockfs" ino=627446 ioctlcmd=7704 scontext=u:r:system_server:s0 tcontext=u:r:system_server:s0 tclass=unix_stream_socket permissive=0
02-22 13:49:08.295 2820-2820/? W/Binder_E: type=1400 audit(0.0:3364): avc: denied { ioctl } for path="socket:[585207]" dev="sockfs" ino=585207 ioctlcmd=7704 scontext=u:r:system_server:s0 tcontext=u:r:system_server:s0 tclass=unix_stream_socket permissive=0
02-22 13:49:08.295 2820-2820/? W/Binder_E: type=1400 audit(0.0:3365): avc: denied { ioctl } for path="socket:[585207]" dev="sockfs" ino=585207 ioctlcmd=7704 scontext=u:r:system_server:s0 tcontext=u:r:system_server:s0 tclass=unix_stream_socket permissive=0


02-22 13:52:42.487 29561-29561/com.kamikazelab.tecategames.tecate_promo01 D/GLIDE: onResourceReady(com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable@256403a, https://graph.facebook.com/100001114770491/picture?type=large, Target for: de.hdodenhof.circleimageview.CircleImageView{d2734eb V.ED..... ........ 33,0-327,297 #7f0e00b1 app:id/iv_friend_one}, false, true)
02-22 13:52:42.496 29561-29561/com.kamikazelab.tecategames.tecate_promo01 D/GLIDE: onResourceReady(com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable@4935248, https://graph.facebook.com/100001114770491/picture?type=large, Target for: de.hdodenhof.circleimageview.CircleImageView{17c28e1 V.ED..... ........ 33,0-327,297 #7f0e00b4 app:id/iv_friend_three}, false, true)
02-22 13:52:42.504 29561-29561/com.kamikazelab.tecategames.tecate_promo01 D/GLIDE: onResourceReady(com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable@5582606, https://graph.facebook.com/100001114770491/picture?type=large, Target for: de.hdodenhof.circleimageview.CircleImageView{c234c7 V.ED..... ........ 33,0-327,297 #7f0e00ae app:id/iv_friend_two}, false, true)

non-library question

Most helpful comment

@ChauhanAbhishek yes, my IOs developer is able to show this type of url in views in SWIFT:

https://github.com/onevcat/Kingfisher

so I suppose that something has to change in Glide... I have opened a new issue.

All 9 comments

Your use case should be as simple as:

String profilePhotoUrl = "https://graph.facebook.com/100001114770491/picture?type=large";
Glide.with(context)
.load(profilePhotoUrl)
.into(avatar);

Library version:
compile 'com.github.bumptech.glide:glide:3.7.0'

Device: Moto G3
SO: Android 6.0
screenshot_20170222-145100

ok so after reviewing the code above and trying again with this code:

Glide.with(context)
                            .load(imageUrl)
                            .skipMemoryCache(true)
                            .diskCacheStrategy(DiskCacheStrategy.NONE)
                            .error(R.drawable.ic_launcher)
                            .into(ivFirstFriend);

it worked. So it seems that the real issue its the placeholder so using .placeholder(R.drawable.ic_launcher) makes the library to either place the image and then replace for the placeholder or to never assign the image.

Glide works perfectly in this case, the culprit is CircleImageView, see https://github.com/bumptech/glide#compatibility

What you were actually seeing was not the .error drawable, but the .placeholder. Notice that you used the same for both. Glide started the load and set the placeholder into the image view, then the image arrived and Glide started the default .crossFade() between placeholder and loaded image. This happens via TransitionDrawable. Upon CircleImageView receiving this animated drawable it eagerly rasterizes it losing the actual drawable. When you don't set a placeholder/thumbnail there's nothing to cross-fade so it works. .dontAnimate() with a .placeholder() will have the same effect on success of loading, but will look different to the user.

Coud you test with https://graph.facebook.com/1131031506918961/picture?type=large ? this link redirect to file not image.

Was working yesterday . Not working since today . Did something change from FB End. One thing is that before browser was opening image right there on page and now it is asking me to download it without opening on the page first

@thaihuynhxyz @ChauhanAbhishek yes... it was working till today. Something has changed in FB end. So now Glide can't load this graph pictures... Picasso can't too. I need some help!
Browsers now download directly the image insted of showing it on the page....

But my friend on IOS is using sdwebimage library and is able to successfully show profile image in the view .

@ChauhanAbhishek yes, my IOs developer is able to show this type of url in views in SWIFT:

https://github.com/onevcat/Kingfisher

so I suppose that something has to change in Glide... I have opened a new issue.

I have developed a library named RedirectGlide which helps to load indirect urls using Glide. I hope it helps you.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ersen-osman picture ersen-osman  路  3Comments

StefMa picture StefMa  路  3Comments

Ncit picture Ncit  路  3Comments

Morteza-Rastgoo picture Morteza-Rastgoo  路  3Comments

r4m1n picture r4m1n  路  3Comments