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

Glide 4.4 decodeStream crash #2763

Open
he4330937 opened this issue Dec 27, 2017 · 10 comments
Open

Glide 4.4 decodeStream crash #2763

he4330937 opened this issue Dec 27, 2017 · 10 comments

Comments

@he4330937
Copy link

Hi all

glide version 4.4
Android OS : 4.2.1, 4.2.2

I got below error log:

1 #00 pc 000b1c54 /system/lib/libskia.so [armeabi-v7a]

#1 pc 000b39e8 /system/lib/libskia.so (SkPNGImageEncoder::doEncode(SkWStream*, SkBitmap const&, bool const&, int, int, SkBitmap::Config, png_color_8_struct&)+456) [armeabi-v7a]
#2 pc 000b3da4 /system/lib/libskia.so (SkPNGImageEncoder::onEncode(SkWStream*, SkBitmap const&, int)+328) [armeabi-v7a]
#3 pc 000b5228 /system/lib/libskia.so (SkImageEncoder::encodeStream(SkWStream*, SkBitmap const&, int)+32) [armeabi-v7a]
#4 pc 0006a659 /system/lib/libandroid_runtime.so [armeabi-v7a]
#5 pc 0001e290 /system/lib/libdvm.so (dvmPlatformInvoke+112) [armeabi-v7a]
#6 pc 0004d359 /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+396) [armeabi-v7a]
#7 pc 00038bdd /system/lib/libdvm.so (dvmCheckCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+8) [armeabi-v7a]
#8 pc 000276a0 /system/lib/libdvm.so [armeabi-v7a]
10 #9 pc 0002b57c /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184) [armeabi-v7a]
11 #10 pc 0005fb79 /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+272) [armeabi-v7a]
12 #11 pc 0005fba3 /system/lib/libdvm.so (dvmCallMethod(Thread*, Method const*, Object*, JValue*, ...)+20) [armeabi-v7a]
13 #12 pc 0005471f /system/lib/libdvm.so [armeabi-v7a]
14 #13 pc 0000e3d8 /system/lib/libc.so (__thread_entry+72) [armeabi-v7a]
15 #14 pc 0000dac4 /system/lib/libc.so (pthread_create+160) [armeabi-v7a]
16 java:
17 android.graphics.Bitmap.nativeCompress(Native Method)
18 android.graphics.Bitmap.compress(Bitmap.java:875)
19 com.bumptech.glide.load.resource.bitmap.BitmapEncoder.boolean encode(com.bumptech.glide.load.engine.Resource,java.io.File,com.bumptech.glide.load.Options)(SourceFile:66)
20 com.bumptech.glide.load.resource.bitmap.BitmapEncoder.boolean encode(java.lang.Object,java.io.File,com.bumptech.glide.load.Options)(SourceFile:31)
21 com.bumptech.glide.load.engine.DataCacheWriter.boolean write(java.io.File)(SourceFile:30)
22 com.bumptech.glide.load.engine.cache.DiskLruCacheWrapper.void put(com.bumptech.glide.load.Key,com.bumptech.glide.load.engine.cache.DiskCache$Writer)(SourceFile:134)
23 com.bumptech.glide.load.engine.DecodeJob$DeferredEncodeManager.void encode(com.bumptech.glide.load.engine.DecodeJob$DiskCacheProvider,com.bumptech.glide.load.Options)(SourceFile:652)
24 com.bumptech.glide.load.engine.DecodeJob.void notifyEncodeAndRelease(com.bumptech.glide.load.engine.Resource,com.bumptech.glide.load.DataSource)(SourceFile:440)
25 com.bumptech.glide.load.engine.DecodeJob.void decodeFromRetrievedData()(SourceFile:417)
26 com.bumptech.glide.load.engine.DecodeJob.void onDataFetcherReady(com.bumptech.glide.load.Key,java.lang.Object,com.bumptech.glide.load.data.DataFetcher,com.bumptech.glide.load.DataSource,com.bumptech.glide.load.Key)(SourceFile:380)
27 com.bumptech.glide.load.engine.SourceGenerator.void onDataReady(java.lang.Object)(SourceFile:111)
28 com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.void onDataReady(java.lang.Object)(SourceFile:132)
29 com.bumptech.glide.load.data.LocalUriFetcher.void loadData(com.bumptech.glide.Priority,com.bumptech.glide.load.data.DataFetcher$DataCallback)(SourceFile:51)
30 ##parent##1##parent##
31 ##child## void close(java.lang.Object)##child##
32 com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.void loadData(com.bumptech.glide.Priority,com.bumptech.glide.load.data.DataFetcher$DataCallback)(SourceFile:96)
33 com.bumptech.glide.load.engine.SourceGenerator.boolean startNext()(SourceFile:61)
34 com.bumptech.glide.load.engine.DecodeJob.void runGenerators()(SourceFile:303)
35 com.bumptech.glide.load.engine.DecodeJob.void runWrapped()(SourceFile:273)
36 com.bumptech.glide.load.engine.DecodeJob.void run()(SourceFile:234)
37 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
38 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
39 java.lang.Thread.run(Thread.java:856)
40 com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.void run()(SourceFile:445)

@sjudd
Copy link
Collaborator

sjudd commented Dec 27, 2017

Hi @he4330937,

It looks like you might not have included some important information when you filed this issue. To make sure we have all the information we need to help with your issue. Please take a look at the Issue Template and make sure you've filled out as many sections as possible.

In particular you must include:

  • Glide Version
  • Glide load line
  • Issue details.

I'm marking this issue as requiring more information. Please understand that if you do not provide that information or update the issue within the next 7 days this issue will be automatically closed so that it doesn''t clutter the bug tracker.

Best regards,

~ Your friendly GitIssueBot

PS: I'm just an automated script, not a human being.

@he4330937
Copy link
Author

he4330937 commented Dec 28, 2017

Glide Version: 4.4

Integration libraries:

    annotationProcessor 'com.github.bumptech.glide:compiler:4.4.0'
    compile 'com.github.bumptech.glide:annotations:4.4.0'
    compile 'com.github.bumptech.glide:gifdecoder:4.4.0'
    compile 'com.github.bumptech.glide:disklrucache:4.4.0'
    compile 'com.github.bumptech.glide:glide:4.4.0@aar'

Device/Android Version:
4.2.2 , 4.2.1

Issue details / Repro steps / Use case background:

We found some crash in 4.2.2 and 4.2.1 . Other os version is fine,
We collect the log via network.
We check log, it happens in the image processing.
Use showImage() function to show image.

Glide load line / GlideModule (if any) / list Adapter code (if any):

public final class LiveGlideModule extends AppGlideModule{
    @Override
    public void applyOptions(Context context, GlideBuilder builder) {
        MemorySizeCalculator calculator = new MemorySizeCalculator.Builder(context)
                .setMemoryCacheScreens(1)
                .build();
        builder.setMemoryCache(new LruResourceCache(calculator.getMemoryCacheSize()));
        builder.setBitmapPool(new LruBitmapPool(calculator.getBitmapPoolSize()));
        builder.setDiskCache(new InternalCacheDiskCacheFactory(context, context.getCacheDir().getAbsolutePath(), 50 * 1024 * 1024));
    }

    @Override
    public boolean isManifestParsingEnabled() {
        return false;
    }
}
    public static void showImage(final GlideRequests requestManager, final ImageView imageView,
                                 final String url, final Integer defaultId,
                                 final boolean isMemoryCache, final boolean isDiskCache,
                                 final LoadImageListener l) {
        if (requestManager == null || imageView == null) {
            if (l != null) {
                l.onFail();
            }
            return;
        }

        if (l != null) {
            l.onLoadingStart();
        }

        imageView.post(new Runnable() {
            @Override
            public void run() {
                final Bitmap bitmap = defaultId == null ? null
                        : BitmapUtils.getBitmap(imageView.getContext(), defaultId, imageView.getWidth(), imageView.getHeight());
                final Drawable drawable = new BitmapDrawable(bitmap);

                if (TextUtils.isEmpty(url)) {
                    imageView.setImageDrawable(drawable);
                    return;
                }

                requestManager.load(url)
                        // .skipMemoryCache(isMemoryCache ? false : true)
                        .skipMemoryCache(true)
                        // .diskCacheStrategy(isDiskCache ? DiskCacheStrategy.AUTOMATIC : DiskCacheStrategy.NONE)
                        .diskCacheStrategy(DiskCacheStrategy.RESOURCE)
                        .fitCenter()
                        .placeholder(drawable)
                        .error(drawable)
                        .listener(new RequestListener<Drawable>() {
                            @Override
                            public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
                                if (l != null) {
                                    l.onFail();
                                }
                                return true;
                            }

                            @Override
                            public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
                                boolean result = false;
                                if (l != null) {
                                    result = l.onSuccess();
                                }
                                return result;
                            }
                        }).into(imageView);
            }
        });
        imageView.setVisibility(View.VISIBLE);
    }

Stack trace / LogCat:

1 #00 pc 000b1c54 /system/lib/libskia.so [armeabi-v7a]
2 #1 pc 000b39e8 /system/lib/libskia.so (SkPNGImageEncoder::doEncode(SkWStream*, SkBitmap const&, bool const&, int, int, SkBitmap::Config, png_color_8_struct&)+456) [armeabi-v7a]
3 #2 pc 000b3da4 /system/lib/libskia.so (SkPNGImageEncoder::onEncode(SkWStream*, SkBitmap const&, int)+328) [armeabi-v7a]
4 #3 pc 000b5228 /system/lib/libskia.so (SkImageEncoder::encodeStream(SkWStream*, SkBitmap const&, int)+32) [armeabi-v7a]
5 #4 pc 0006a659 /system/lib/libandroid_runtime.so [armeabi-v7a]
6 #5 pc 0001e290 /system/lib/libdvm.so (dvmPlatformInvoke+112) [armeabi-v7a]
7 #6 pc 0004d359 /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+396) [armeabi-v7a]
8 #7 pc 00038bdd /system/lib/libdvm.so (dvmCheckCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+8) [armeabi-v7a]
9 #8 pc 000276a0 /system/lib/libdvm.so [armeabi-v7a]
10 #9 pc 0002b57c /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184) [armeabi-v7a]
11 #10 pc 0005fb79 /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+272) [armeabi-v7a]
12 #11 pc 0005fba3 /system/lib/libdvm.so (dvmCallMethod(Thread*, Method const*, Object*, JValue*, ...)+20) [armeabi-v7a]
13 #12 pc 0005471f /system/lib/libdvm.so [armeabi-v7a]
14 #13 pc 0000e3d8 /system/lib/libc.so (__thread_entry+72) [armeabi-v7a]
15 #14 pc 0000dac4 /system/lib/libc.so (pthread_create+160) [armeabi-v7a]
16 java:
17 android.graphics.Bitmap.nativeCompress(Native Method)
18 android.graphics.Bitmap.compress(Bitmap.java:875)
19 com.bumptech.glide.load.resource.bitmap.BitmapEncoder.boolean encode(com.bumptech.glide.load.engine.Resource,java.io.File,com.bumptech.glide.load.Options)(SourceFile:66)
20 com.bumptech.glide.load.resource.bitmap.BitmapEncoder.boolean encode(java.lang.Object,java.io.File,com.bumptech.glide.load.Options)(SourceFile:31)
21 com.bumptech.glide.load.engine.DataCacheWriter.boolean write(java.io.File)(SourceFile:30)
22 com.bumptech.glide.load.engine.cache.DiskLruCacheWrapper.void put(com.bumptech.glide.load.Key,com.bumptech.glide.load.engine.cache.DiskCache$Writer)(SourceFile:134)
23 com.bumptech.glide.load.engine.DecodeJob$DeferredEncodeManager.void encode(com.bumptech.glide.load.engine.DecodeJob$DiskCacheProvider,com.bumptech.glide.load.Options)(SourceFile:652)
24 com.bumptech.glide.load.engine.DecodeJob.void notifyEncodeAndRelease(com.bumptech.glide.load.engine.Resource,com.bumptech.glide.load.DataSource)(SourceFile:440)
25 com.bumptech.glide.load.engine.DecodeJob.void decodeFromRetrievedData()(SourceFile:417)
26 com.bumptech.glide.load.engine.DecodeJob.void onDataFetcherReady(com.bumptech.glide.load.Key,java.lang.Object,com.bumptech.glide.load.data.DataFetcher,com.bumptech.glide.load.DataSource,com.bumptech.glide.load.Key)(SourceFile:380)
27 com.bumptech.glide.load.engine.SourceGenerator.void onDataReady(java.lang.Object)(SourceFile:111)
28 com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.void onDataReady(java.lang.Object)(SourceFile:132)
29 com.bumptech.glide.load.data.LocalUriFetcher.void loadData(com.bumptech.glide.Priority,com.bumptech.glide.load.data.DataFetcher$DataCallback)(SourceFile:51)
30 ##parent##1##parent##
31 ##child## void close(java.lang.Object)##child##
32 com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.void loadData(com.bumptech.glide.Priority,com.bumptech.glide.load.data.DataFetcher$DataCallback)(SourceFile:96)
33 com.bumptech.glide.load.engine.SourceGenerator.boolean startNext()(SourceFile:61)
34 com.bumptech.glide.load.engine.DecodeJob.void runGenerators()(SourceFile:303)
35 com.bumptech.glide.load.engine.DecodeJob.void runWrapped()(SourceFile:273)
36 com.bumptech.glide.load.engine.DecodeJob.void run()(SourceFile:234)
37 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
38 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
39 java.lang.Thread.run(Thread.java:856)
40 com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.void run()(SourceFile:445)

@sjudd
Copy link
Collaborator

sjudd commented Dec 28, 2017

Are you able to attach a sample app that reproduces the issue, a failing test case, or an example image that fails to compress?

@he4330937
Copy link
Author

We got log via network, The bug only reproduce some 4.2.2 and 4.2.1 Other os is fine.

We can not found machine of appear issue because we got the log via network.

App run in TV, All glide call via function showImage(). You can find it above comments

@sjudd
Copy link
Collaborator

sjudd commented Dec 29, 2017

Is this a specific set of TV devices only? Or all devices run on 4.2.2 and 4.2.1? If it's specific to a device or a couple of devices can you provide the models and manufacturers?

@he4330937
Copy link
Author

he4330937 commented Dec 31, 2017

Hi sjudd

Thank for your comments.
Only some special TV(OS 4.2.2 , 4.2.1) appear the issue. Other TV(OS 4.2.2 , 4.2.1) is fine
I get special devices information via network log , information below:

TV list below:

Hisense VIDAA_TV
OS:Android 4.2.2,level 17
ROM:Hisense/LED50K680X3DU
CPU:armeabi-v7a

Toshiba TV

OS:Android 4.2.1,level 17
ROM:Toshiba/l4300
CPU:armeabi-v7a

TCL TV

OS:Android 4.2.1,level 17
ROM:realtek/rtd299x_tv030
CPU:armeabi-v7a

Toshiba TS42

OS:Android 4.2.1,level 17
ROM:Toshiba/l4300
CPU:armeabi-v7a

Skyworth TV 9R15 E710U

OS:Android 4.2.1,level 17
ROM:Skyworth/rtd299x_tv010_4k
CPU:armeabi-v7a

Toshiba TV E42LX9101

OS:Android 4.2.1,level 17
ROM:Toshiba/l4300
CPU:armeabi-v7a

Hisense TV led50xt900x3du

OS:Android 4.2.2,level 17
ROM:Hisense/led50xt900x3du
CPU:armeabi-v7a

@sjudd
Copy link
Collaborator

sjudd commented Dec 31, 2017

Do you have any idea whether there are any distinguishing features about the images? Are they maybe ARGB_8888 bitmaps with transparent pixels? It looks like the PNG encoder is the one crashing? Do you have any of these devices around that you might be able to test on?

We could do something as drastic as disabling the encoder on those devices with that API level if we think some substantial percentage of images are affected. You could also do the same in your app outside of Glide.

A less drastic equivalent would be disabling PNG encoding on those devices/API levels which would cause transparent pixels to show up as black if caching is enabled. That's not the end of the world if PNG encoding in general is broken or if your application doesn't typically display transparent images.

@he4330937
Copy link
Author

I check my code. I found use ARGB_8888 png with transparent pixels. but I has not devices.

How to disable the encoder ?

We need caching enable and display transparent images, So can you give me some advise?

@sjudd
Copy link
Collaborator

sjudd commented Jan 8, 2018

You can use a custom DiskCacheStrategy that's similar to DiskCacheStrategy.DATA but that only writes remote data to cache. If you only load remote data in your application you can use DiskCacheStrategy.DATA directly.

That will let you cache the unmodified image, but not the output from any transformations.

Beyond that our only choice would be to modify Glide to write transparent images to cache without transparency, which will just make the transparent pixels black when you load them again (not a great idea if you're intentionally loading transparent images). It's hard for us to work around a framework bug like this unfortunately.

@stale
Copy link

stale bot commented Jan 15, 2018

This issue has been automatically marked as stale because it has not had activity in the last seven days. It will be closed if no further activity occurs within the next seven days. Thank you for your contributions.

@stale stale bot added the stale label Jan 15, 2018
@sjudd sjudd added enhancement and removed stale labels Jan 16, 2018
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

2 participants