Skip to content
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

Can't load image with URL from sample with "SkImageDecoder::Factory returned null" #379

Closed
akadatsky opened this issue Mar 26, 2015 · 3 comments

Comments

@akadatsky
Copy link

Glide Version/Integration library (if any): 3.5.2
Device/Android Version: Samsung galaxy s2 / 4.1.2, htc one x / 4.2.2, samsung galaxy s3 mini i 8190 / 4.1.2
Issue details/Repro steps:

Image not appeares

Glide load line:

Glide.with(MyActivity.this).load("http://goo.gl/h8qOq7").into(imageView);

Stack trace:

SkImageDecoder::Factory returned null

I created the siple sample to test library - https://github.com/akadatsky/photoApp
I added to manifest:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" 
<uses-permission android:name="android.permission.INTERNET"

I added the latest Glide library - 3.5.2, and the latest Support-v4 library.

I added ImageView like this:

<ImageView
    android:id="@+id/image"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>

And the simle button with click listener, with code from samle:

 findViewById(R.id.url).setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        Glide.with(MyActivity.this).load("http://goo.gl/h8qOq7").into(imageView);
    }
});

The code works wine on Simulator and Nexus 4 with android 5.0.1 but does not work on next devices:
Samsung galaxy s2 / 4.1.2, Htc One X / 4.2.2, Samsung galaxy s3 mini i 8190 / 4.1.2

It show in logs just: "SkImageDecoder::Factory returned null"

I have tried to add error handling in such way:

RequestListener<String, GlideDrawable> listener = new RequestListener<String, GlideDrawable>() {
    @Override
    public boolean onException(Exception e, String s, Target<GlideDrawable> target, boolean b) {
        Log.i(TAG, "Exception: " + filePath, e);
        Log.i(TAG, "String: " + s);
        return false;
    }

    @Override
    public boolean onResourceReady(GlideDrawable glideDrawable, String s, Target<GlideDrawable> target, boolean b, boolean b1) {
        Log.i(TAG, "String: " + s);
        return false;
    }
};
Glide.with(MyActivity.this).load(filePath).listener(listener).placeholder(R.drawable.ic_launcher).into(imageView);

In this case onException() method is called and Exception e == null.

I have tested on different wifi and mobile network, and few different devices, but can't understand where is the problem.

How to fix this issue?

UPD. After some more test I noticed that do not loaded image from sampe "http://goo.gl/h8qOq7", but some other Images like "http://pp.vk.me/c618123/v618123715/17b15/LebZByMTBTA.jpg" work.

Also I noticed, that in case image "http://goo.gl/h8qOq7" directory /data/data/package_name/cache is empty.

UPD2. I noticed that url "http://goo.gl/h8qOq7" redirect to "https://lh6.ggpht.com/9SZhHdv4URtBzRmXpnWxZcYhkgTQurFuuQ8OR7WZ3R7fyTmha77dYkVvcuqMu3DLvMQ=w300-rw"
if I remove this "=w300-rw" in the end ot URL it becomes work.
So it works for url "https://lh6.ggpht.com/9SZhHdv4URtBzRmXpnWxZcYhkgTQurFuuQ8OR7WZ3R7fyTmha77dYkVvcuqMu3DLvMQ"

@TWiStErRob
Copy link
Collaborator

Thanks for the report, I'm not sure we can do anything about this though.

That goo.gl link is pointing to an url which results in a webp file, if you remove the end (it's enough to remove the w), you will get a png file (if you remove =w300-r, the image will not be 300px wide).
The other pp.vk.me url is a jpg file clearly, so that's old and supported.

So your original image is transparent, just open it in Chrome, you'll see it has no background. If you check the Core Media Formats page, there you can see

WebP Decoder: (Lossless, Transparency, Android 4.2.1+)

which means that transparent webp support was added in 4.2.1, so it should work on One X, are you sure it happened on that phone too?

Even though it was added in 4.2.1, and should be supported, there may be problems pre-Lollipop, see #372.

The cache was empty, because the default is .diskCacheStrategy(RESULT) meaning that the transformed image (the one resized/cropped/etc for your ImageView) will be saved to cache, but there was no Bitmap to transform, because Android failed to load it.

@akadatsky
Copy link
Author

Thanks, it's clear.
I believe it's better to change URL in this page - https://github.com/bumptech/glide, to avoid such misunderstanding in future.

I'll research this issue on One X more carefully.

@sjudd
Copy link
Collaborator

sjudd commented Mar 26, 2015

Thanks for reporting this, I agree, we should point to an image format that is better supported.

@sjudd sjudd closed this as completed in b3a98a4 Mar 27, 2015
sjudd added a commit to sjudd/glide that referenced this issue Mar 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants