-
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
Some images simply do not download (Black image) - Android #738
Comments
Hi there, thanks for reporting. Please follow the instructions and answer the questions below to help us diagnose further. (Alternatively you can provide GitHub mini project that reproduces this issue). Try enabling internal logging to see what's going on in the logs. When you say no What does your What are the installed Android versions for each of these devices? Since you say it works on one phone, but not on an other, I rule out the possiblity that the view is invisible when you try to load, which may lead to no actual load happening and no callbacks called. What happens if (instead of @Override public void applyOptions(Context context, GlideBuilder builder) {
builder.setMemoryCache(new MemoryCacheAdapter());
} |
Hi, Yes, the onResourceReady was called. I saw the Bitmap resource and it was a valid bitmap, like the others that were downloaded. Same size, etc. My imageDecoder was:
I did like this because the other way(with meta-data android:name="com.inthecheesefactory.lab.glidepicasso.GlideConfiguration") brought me the black image with more frequency. My Android versions are 4.1.2(Razr), 5.1(Moto x) and 5.1.1(Nexus 4). With skipMemoryCache(true) works, because Glide download again when the black image occur, but i don't want with this approach. I will try the resource.compress() to see if the black image appear on the sdcard. Best, |
Hi, DrawableTypeRequest<String> request = Glide.with(context)
.load(NetworkUtils.DEAL_IMAGE_URL + pictures.get(position));
//BitmapRequestBuilder<String, Bitmap> request = Glide.with(context)
// .load(NetworkUtils.DEAL_IMAGE_URL + pictures.get(position))
// .asBitmap()
// .imageDecoder(GlideUtils.getBitmapDecoder(context));
if( width > 0 && height3x4 > 0 ) {
request.override(width, height3x4).fitCenter();
}
request.placeholder(R.drawable.no_picture).into(imgGallery); And works. No more black image. But the default configuration is RGB_565, right? Because of this a did this configuration of imageDecoder to get ARGB_8888. But, no matter how i will configure this approach (via meta-data or imageDecoder()) brought me some black image. Best, |
So, to sum up (please confirm if this is correct): if you use 8888 on a Moto X (5.1) you get a black bitmap, but this doesn't happen on Nexus 4 (5.1.1) nor on Razr (4.1.2); or if memory cache is skipped. Bitmap contents are yet unconfirmed (with This is a duplicate of #599, but that wasn't fixed due to no repro. More questions (sorry, it's not a trivial issue):
Skipping memory cache shouldn't result in a download, only a disk cache hit.
Of course, that's understandable, but trying those cases helps us figure out what the problem might be. |
I tried to reproduce it like this, in a list: Glide
.with(imageView.getContext())
.load(getItem(position))
.asBitmap()
.imageDecoder(new StreamBitmapDecoder(imageView.getContext(), DecodeFormat.PREFER_ARGB_8888))
.override(400, 300)
.fitCenter()
.placeholder(android.R.drawable.ic_menu_revert)
.into(imageView)
; Based on your description it should've loaded a black image, but it didn't. The problem is that I have a Galaxy S4 (4.4.2). Can you please check if this code will reproduce your issue on your Moto X? So we'll have a known short repro. @sjudd do you have any ideas? See my prev comment for a summary. It looks like a pooling issue. |
Hi, I tried like you said but still brought me the black image. I'm testing in 3g. Maybe some network issue? Any idea? Well, with this approach i'm satisfied. I will use BitmapImageViewTarget() and about scaleType i will use on ImageView itself. Best, |
Thanks for confirming that the code I gave you reproduces the problem. Hopefully we can reproduce it on some device in the future and debug what's going on. I'm glad you found a workaround yourself! |
@TWiStErRob I can reproduce the problem with the Gallery sample app on the master branch. |
When the bitmappool is disabled (by always returning a new bitmap from the pool) the issues still reproduces. |
@mullender please try with |
I have added both adapters and the issue remains, which means the memory cache and the bitmappool can be ruled out. |
Hmm, so it's not reuse then. Can you try to enable logging: https://github.com/bumptech/glide/wiki/Debugging-and-Error-Handling#more-logging maybe there's a hint there. I understand it's "different for different clean runs", but can you try to load the same or similar image through |
I narrowed it down to the fitCenter transformation (and probably also the other transformations): |
hack :) |
This looks very similar: |
…image) - Android
@TWiStErRob I created a fix, that resolves the issue. See the PR. The fix has two parts:
|
Perf impact of adding a lock to:
result without lock (decoding 1K images), super fast scrolling
result WITH lock (decoding 1K images), super fast scrolling
This doesn't seem acceptable to enable unconditionally, especially since we only have a single device affected (that we know about) |
…on (affects only Moto X 2nd gen on api 22) this addresses a threading bug on this specific device, the bug manifests itself by displaying black images instead of resized images.
…on (affects only Moto X 2nd gen on api 22) this addresses a threading bug on this specific device, the bug manifests itself by displaying black images instead of resized images.
…on (affects only Moto X 2nd gen on api 22) this addresses a threading bug on this specific device, the bug manifests itself by displaying black images instead of resized images.
…on (affects only Moto X 2nd gen on api 22) this addresses a threading bug on this specific device, the bug manifests itself by displaying black images instead of resized images.
fix for issue #738 Some images simply do not download (Black image) -…
Perhaps this bug is related to this question? |
Yep, looks like the same issue, but no solution there either. @mullender's workaround seems the best option sadly. |
Not sure if entirely related to the issue, but every time I try to load the image and I get that black canvas, this is popping up on my logcat:
|
Running into this same issue as well on a Samsung GP-p7510 running Android 4.0.4 - API 15. |
It might be better if we added a condition for your device as well at 59f3d9c#diff-bcf1e10e8c7c676afd4d4cb151781112R44 (feel free to PR) @RikNorakomi If you really want to try, I would imagine it went down like this: // Glide.....bitmapTransform(new HackyBlacky(new CenterCrop(context)))....;
class HackyBlacky implements Transformation<Bitmap> {
private final Transformation<Bitmap> realTransform;
public HackyBlacky(Transformation<Bitmap> realTransform) { this.realTransform = realTransform; }
@Override public String getId() { return realTransform.getId(); }
@Override public Resource<Bitmap> transform(Resource<Bitmap> resource, int outWidth, int outHeight) {
Resource<Bitmap> original = realTransform.transform(resource, outWidth, outHeight);
if (!isBlack(original.get())) {
return original;
}
Resource<Bitmap> secondTry = realTransform.transform(resource, outWidth, outHeight);
if (!isBlack(secondTry.get())) {
// retry worked, let's use that
original.recycle();
return secondTry;
}
// oh well, both black, we're unlucky; or the image is really black
secondTry.recycle();
return original;
}
private static boolean isBlack(Bitmap check) {
Random rnd = new Random();
for (int i = 0; i < 10; i++) {
int x = rnd.nextInt(check.getWidth());
int y = rnd.nextInt(check.getHeight());
if (check.getPixel(x, y) != Color.BLACK) {
return false;
}
}
return true;
}
} |
Have this issue on Moto G. |
@KatrinYakimova I think you have a false-positive fix: if I read it correctly, you used Since you removed the transformation step from your Glide request, there's no chance of having the canvas synchronization issue. I guess you got that code from #738 (comment) which also said:
|
I'm going to mark this closed, if more new models come up, we can add them to the lock whitelist as well. |
This issue still happens on Moto X 2nd Gen as per version 4.1.1. It can be fixed as a workaround by adding |
@rsousabluebeck what is the model version from Build.MODEL? There's a manual blacklist of device models that can't be transformed which we can update if we get the right string. |
More progress towards bumptech#738. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=170938515
Also applies to |
More progress towards bumptech#738
Wow, that was fast! I could only verify with the |
Just for general information: I'm dealing with an incarnation of this bug that is independent on transformations, so the And I have an affected device (an |
With the growth of the list, we could probably switch: |
Yeah a set is somewhat better, but I agree it's not a big deal. @strooooke mind sending a pull request with the affected models? |
Yet more progress on bumptech#738. Observations aren't confined to API level 22 anymore.
I want to point out one more thing for the upcoming person. I ran the code with glide on the emulator with Gapps not installed and images were not loading and then I bumped into this thread. Then I update the GApps and the images start fetching. So future people, please check on the emulator that you are running the code with Gapps running on it. |
Hi,
In some devices (Moto X) do not download correctly, like the screenshot attached.
When i skipMemoryCache(true) it works, because Glide download the image again.
I already use asBitmap() with imageDecoder() and the problem still occur.
But, in my other device (Nexus 4) this problem doesn't occur. Glide works perfectly
I tried to config listener() to log Exceptions but never called onException() method. In other words, no Exceptions occurs. Its weird.
Best,
Thiago Luis.
The text was updated successfully, but these errors were encountered: