-
Notifications
You must be signed in to change notification settings - Fork 6.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sometimes doesn't load the image into the view on first call #395
Comments
One possibility is that your view either doesn't undergo layout, or ends up with 0 width or 0 height. Glide tries to wait until you have a valid width and height before starting image loads so we know how to resize the image. Try using |
I've had this issue too a lot recently too. My imageviews have a predefined size (90dp x 90dp, not using wrap_content). If I back out of the listview and reload it or scroll up and down as mentioned by @eicm, the images sometimes load correctly. I've double checked the image links and there's no issue with them either. Note: I'm using the viewholder pattern in my adapter to load images into my listview. Here's my adapter code: ArrayList<Item> ItemArrayList;
if (view == null) {
LayoutInflater inflater = (LayoutInflater) viewGroup.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
row = inflater.inflate(R.layout.item_row, viewGroup, false);
holder = new ItemHolder(row);
row.setTag(holder);
}
else {
row = view;
holder = (ItemHolder) row.getTag();
}
Glide.with(viewGroup.getContext()).load(ItemArrayList.get(position).getItemImage()).transform(new GlideCircleTransform(c)).error(R.drawable.mm_avatar).into(holder.itemImage); |
Quick update. After enabling adb debugging as mentioned in the docs, I am getting the following error message on failed image loads:
Any ideas how to go about solving this? |
@vaxus that sounds like you're returning a bitmap to the bitmap pool or recycling it twice. Do you still see the error if you remove your Transformation from your load call? |
@sam setting a fixed size seems to solve the problem, though I need to
|
@sjudd I removed the transformation from the load call and it still gives me: I also tried using override to set a fixed size but the error persists. |
Interesting, can you provide a stack trace? I don't see anything else obviously wrong here. I may need a sample app to look into this further... Interesting that just using the thumbnail path is faster than loadFromMediaStore. Do you have media store thumbs for those files? If not, loadFromMediaStore will fall back to the file path. It's possible that when you don't have thumbs the queries for the thumb file path take long enough to significantly slow down the load. |
I noticed my target size has bigger width and length compared to the |
The other thing that I noticed is that the orientation is not taken into |
@eicm It's possible different devices behavior differently w/r/t thumbnail orientation. The code path for media store thumbs and full size images is actually the same. The only difference is that for media store thumbs, we load data from the thumb file path rather than the original image file path. As a result, if the thumb contains exif data or is encoded with the correct orientation, we should provide a correctly rotated image. What device/version of Android do you see incorrectly rotated thumbs on? |
I'm experiencing it on all devices I have: nexus 10 4.4, nexus 9 5.0.1, |
I looked into this, it turns out MediaStore.Images.Thumbnails neither produces correctly oriented images nor includes the original exif orientation tag in the thumbnail. For now you can work around this by using I'll try and think of sane way to pass through the original orientation... |
I'm unable to provide a sample app unfortunately. I tried to use Picasso just to see if I would experience similar behaviour and it seemed to work ok. I'm not getting the errors during loads. Very strange :/ |
@vaxus Can you file a new issue for the IllegalStateException? |
I'm going to close this issue since I think we addressed the original problem (images aren't loading). I filed a separate issue for the media store thumbnail rotation issue (#400) and we should file another for the IllegalStateException. |
I have the same issues.When I load image in the listView header,the first time ,Glide not set image to imageView.when I refresh the ui,it is normal.why ? thanks. |
@aLoyalStudent please open a new issue and fill in the details! |
In a PagerAdapter instantiateItem() I make the following call:
Sometimes on the first call it doesn't set the image to the given imageView, but as I scroll far enough and come back it loads the image from cache for that given position which shows that the image has been cached on the first call.
What would be the reasons for not setting the image in the imageView in the first call.
The text was updated successfully, but these errors were encountered: