bumptech / glide

An image loading and caching library for Android focused on smooth scrolling
https://bumptech.github.io/glide/
Other
34.64k stars 6.12k forks source link

Only call ExifInterface on RAW/JPEG image formats. #3851

Closed ZacSweers closed 4 years ago

ZacSweers commented 5 years ago

This file yields the following error trace from glide, even though it is rendered correctly. This suggests to me that it's either a noisy logger that should be configurable/suppressed or it should have more information as to what the consequences are of this

https://avatars3.githubusercontent.com/u/698437?v=4

2019-08-24 19:00:13.436 31864-32083/io.sweers.catchup.debug W/ExifInterface: Invalid image: ExifInterface got an unsupported image format file(ExifInterface supports JPEG and some RAW image formats only) or a corrupted JPEG file to ExifInterface.
    java.io.IOException: Invalid byte order: ffff8950
        at android.media.ExifInterface.readByteOrder(ExifInterface.java:3121)
        at android.media.ExifInterface.isOrfFormat(ExifInterface.java:2437)
        at android.media.ExifInterface.getMimeType(ExifInterface.java:2315)
        at android.media.ExifInterface.loadAttributes(ExifInterface.java:1753)
        at android.media.ExifInterface.<init>(ExifInterface.java:1447)
        at com.bumptech.glide.load.resource.bitmap.ExifInterfaceImageHeaderParser.getOrientation(ExifInterfaceImageHeaderParser.java:40)
        at com.bumptech.glide.load.ImageHeaderParserUtils.getOrientation(ImageHeaderParserUtils.java:91)
        at com.bumptech.glide.load.resource.bitmap.Downsampler.decodeFromWrappedStreams(Downsampler.java:236)
        at com.bumptech.glide.load.resource.bitmap.Downsampler.decode(Downsampler.java:206)
        at com.bumptech.glide.load.resource.bitmap.Downsampler.decode(Downsampler.java:162)
        at com.bumptech.glide.load.resource.bitmap.ByteBufferBitmapDecoder.decode(ByteBufferBitmapDecoder.java:33)
        at com.bumptech.glide.load.resource.bitmap.ByteBufferBitmapDecoder.decode(ByteBufferBitmapDecoder.java:16)
        at com.bumptech.glide.load.engine.DecodePath.decodeResourceWithList(DecodePath.java:72)
        at com.bumptech.glide.load.engine.DecodePath.decodeResource(DecodePath.java:55)
        at com.bumptech.glide.load.engine.DecodePath.decode(DecodePath.java:45)
        at com.bumptech.glide.load.engine.LoadPath.loadWithExceptionList(LoadPath.java:58)
        at com.bumptech.glide.load.engine.LoadPath.load(LoadPath.java:43)
        at com.bumptech.glide.load.engine.DecodeJob.runLoadPath(DecodeJob.java:515)
        at com.bumptech.glide.load.engine.DecodeJob.decodeFromFetcher(DecodeJob.java:480)
        at com.bumptech.glide.load.engine.DecodeJob.decodeFromData(DecodeJob.java:466)
        at com.bumptech.glide.load.engine.DecodeJob.decodeFromRetrievedData(DecodeJob.java:418)
        at com.bumptech.glide.load.engine.DecodeJob.onDataFetcherReady(DecodeJob.java:387)
        at com.bumptech.glide.load.engine.SourceGenerator.onDataFetcherReady(SourceGenerator.java:135)
        at com.bumptech.glide.load.engine.DataCacheGenerator.onDataReady(DataCacheGenerator.java:95)
        at com.bumptech.glide.load.model.ByteBufferFileLoader$ByteBufferFetcher.loadData(ByteBufferFileLoader.java:74)
        at com.bumptech.glide.load.engine.DataCacheGenerator.startNext(DataCacheGenerator.java:75)
        at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:49)
        at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:309)
        at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:279)
        at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:235)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919)
        at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:446)
ZacSweers commented 5 years ago

This might be something specific to Android Q betas, trying to get clarification

sjudd commented 5 years ago

Probably the same as #3383, unfortunately we can't control what they log.

We might be able to avoid calling the support library for pngs though.

ZacSweers commented 5 years ago

What about possibly using the Exif support library?

krcho commented 5 years ago

I try to use support library exif, but it don't work

I'm using AVD (API 29)

okarakose commented 5 years ago

I am getting the noisy logs as well. Photos are loading normally.

OS API : 28
Exif Library Version : AndroidX 1.1.0-beta01
Glide Version : 4.9.0

Logs are below :

2019-09-02 11:20:58.365 D/Glide: Finished loading Bitmap from REMOTE for https://images.unsplash.com/photo-1565796703342-bd5b133692d0 with size [1080x1920] in 2764.847238 ms
2019-09-02 11:20:59.660 W/ExifInterface: Skip the tag entry since tag number is not defined: 34864
2019-09-02 11:20:59.660 W/ExifInterface: Skip the tag entry since tag number is not defined: 36880
2019-09-02 11:20:59.662 W/ExifInterface: Skip the tag entry since tag number is not defined: 42033
2019-09-02 11:20:59.663 W/ExifInterface: Skip the tag entry since tag number is not defined: 42034
2019-09-02 11:20:59.663 W/ExifInterface: Skip the tag entry since tag number is not defined: 42036
2019-09-02 11:20:59.663 W/ExifInterface: Stop reading file since a wrong offset may cause an infinite loop: 0
2019-09-02 11:20:59.664 W/ExifInterface: Stop reading file since a wrong offset may cause an infinite loop: 0
2019-09-02 11:21:00.536 D/Glide: Finished loading Bitmap from REMOTE for https://images.unsplash.com/photo-1565840620394-13bf50ca76d6 with size [1080x1920] in 4870.6866119999995 ms
2019-09-02 11:21:00.616 D/Glide: Finished loading Bitmap from REMOTE for https://images.unsplash.com/photo-1566786859182-13583eb0e6b9 with size [1080x1920] in 4883.615311 ms
2019-09-02 11:21:02.105 W/ExifInterface: Skip the tag entry since tag number is not defined: 34864
2019-09-02 11:21:02.105 W/ExifInterface: Skip the tag entry since tag number is not defined: 34866
2019-09-02 11:21:02.108 W/ExifInterface: Skip the tag entry since tag number is not defined: 42034
2019-09-02 11:21:02.108 W/ExifInterface: Skip the tag entry since tag number is not defined: 42036
2019-09-02 11:21:02.108 W/ExifInterface: Stop reading file since a wrong offset may cause an infinite loop: 0
2019-09-02 11:21:02.109 W/ExifInterface: Stop reading file since a wrong offset may cause an infinite loop: 0
2019-09-02 11:21:02.849 D/Glide: Finished loading Bitmap from REMOTE for https://images.unsplash.com/photo-1566508416487-343301d6f4e9 with size [1080x1920] in 7099.460102 ms
2019-09-02 11:21:04.730 W/ExifInterface: Skip the tag entry since tag number is not defined: 34864
2019-09-02 11:21:04.733 W/ExifInterface: Skip the tag entry since tag number is not defined: 42033
2019-09-02 11:21:04.733 W/ExifInterface: Skip the tag entry since tag number is not defined: 42034
2019-09-02 11:21:04.733 W/ExifInterface: Skip the tag entry since tag number is not defined: 42035
2019-09-02 11:21:04.733 W/ExifInterface: Skip the tag entry since tag number is not defined: 42036
2019-09-02 11:21:04.734 W/ExifInterface: Skip the tag entry since tag number is not defined: 42037
2019-09-02 11:21:04.734 W/ExifInterface: Stop reading file since a wrong offset may cause an infinite loop: 0
2019-09-02 11:21:04.734 W/ExifInterface: Stop reading file since a wrong offset may cause an infinite loop: 0
2019-09-02 11:21:05.722 D/Glide: Finished loading Bitmap from REMOTE for https://images.unsplash.com/photo-1565608038989-24b797abaa45 with size [1080x1920] in 9924.717236 ms

Any plan to fix this soon ?

c0dehunter commented 5 years ago

Happy to jump in with bug report. Running on Android Q AVD (Pixel 3). Sad to say I am now unable to reproduce this, I guess the image has changed (we re-generate it on server every minute). If it happens again, I will attach it. Here is another one, but it works fine:

image

Log:

2019-09-13 22:38:59.163 7184-7810/com.my.app W/ExifInterface: Invalid image: ExifInterface got an unsupported image format file(ExifInterface supports JPEG and some RAW image formats only) or a corrupted JPEG file to ExifInterface.
    java.io.IOException: Invalid byte order: ffff8950
        at android.media.ExifInterface.readByteOrder(ExifInterface.java:3121)
        at android.media.ExifInterface.isOrfFormat(ExifInterface.java:2437)
        at android.media.ExifInterface.getMimeType(ExifInterface.java:2315)
        at android.media.ExifInterface.loadAttributes(ExifInterface.java:1753)
        at android.media.ExifInterface.<init>(ExifInterface.java:1447)
        at com.bumptech.glide.load.resource.bitmap.ExifInterfaceImageHeaderParser.getOrientation(ExifInterfaceImageHeaderParser.java:40)
        at com.bumptech.glide.load.ImageHeaderParserUtils.getOrientation(ImageHeaderParserUtils.java:91)
        at com.bumptech.glide.load.resource.bitmap.Downsampler.decodeFromWrappedStreams(Downsampler.java:236)
        at com.bumptech.glide.load.resource.bitmap.Downsampler.decode(Downsampler.java:206)
        at com.bumptech.glide.load.resource.bitmap.Downsampler.decode(Downsampler.java:162)
        at com.bumptech.glide.load.resource.bitmap.ByteBufferBitmapDecoder.decode(ByteBufferBitmapDecoder.java:33)
        at com.bumptech.glide.load.resource.bitmap.ByteBufferBitmapDecoder.decode(ByteBufferBitmapDecoder.java:16)
        at com.bumptech.glide.load.engine.DecodePath.decodeResourceWithList(DecodePath.java:72)
        at com.bumptech.glide.load.engine.DecodePath.decodeResource(DecodePath.java:55)
        at com.bumptech.glide.load.engine.DecodePath.decode(DecodePath.java:45)
        at com.bumptech.glide.load.engine.LoadPath.loadWithExceptionList(LoadPath.java:58)
        at com.bumptech.glide.load.engine.LoadPath.load(LoadPath.java:43)
        at com.bumptech.glide.load.engine.DecodeJob.runLoadPath(DecodeJob.java:515)
        at com.bumptech.glide.load.engine.DecodeJob.decodeFromFetcher(DecodeJob.java:480)
        at com.bumptech.glide.load.engine.DecodeJob.decodeFromData(DecodeJob.java:466)
        at com.bumptech.glide.load.engine.DecodeJob.decodeFromRetrievedData(DecodeJob.java:418)
        at com.bumptech.glide.load.engine.DecodeJob.onDataFetcherReady(DecodeJob.java:387)
        at com.bumptech.glide.load.engine.SourceGenerator.onDataFetcherReady(SourceGenerator.java:135)
        at com.bumptech.glide.load.engine.DataCacheGenerator.onDataReady(DataCacheGenerator.java:95)
        at com.bumptech.glide.load.model.ByteBufferFileLoader$ByteBufferFetcher.loadData(ByteBufferFileLoader.java:74)
        at com.bumptech.glide.load.engine.DataCacheGenerator.startNext(DataCacheGenerator.java:75)
        at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:49)
        at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:309)
        at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:279)
        at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:235)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919)
        at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:446)
Dararii commented 5 years ago

same issue here. Is that possibly cause a bug in some devices?

strajky5 commented 5 years ago

Same here Pixel 2XL, Android 10.

joerogers commented 5 years ago

I see a few options:

1) Do not extract EXIF data on png images which for me is the main issue. 2) Update ImageHeaderParserUtils.java to "catch" any exception and continue on to the next header parser with minimal or no logging.

    //noinspection ForLoopReplaceableByForEach to improve perf
    for (int i = 0, size = parsers.size(); i < size; i++) {
      ImageHeaderParser parser = parsers.get(i);
      try {
        int orientation = parser.getOrientation(is, byteArrayPool);
        if (orientation != ImageHeaderParser.UNKNOWN_ORIENTATION) {
          return orientation;
        }
      } catch(Throwable e) {
         // Move to next parser if an exception occurs
         continue;
      } finally {
        is.reset();
      }
    }
   return ImageHeaderParser.UNKNOWN_ORIENTATION;
davelogan commented 5 years ago

I am seeing the same issue. Google Pixel2 XL running Android Q

implementation 'com.github.bumptech.glide:glide:4.9.0'
kapt 'com.github.bumptech.glide:compiler:4.9.0'
eygraber commented 5 years ago

Still happening on 4.10.0

hoanghiephui commented 5 years ago

same issue here

wankey commented 4 years ago

happened on Oneplus 7 pro(Android10)

crossle commented 4 years ago

When release this?

ktl-111 commented 4 years ago

Are you using " new DrawableCrossFadeFactory.Builder(300).setCrossFadeEnabled(true).build()"? If you delete this, there is no problem, I don't know if it is caused by this.

nicusorflorin commented 4 years ago

@sjudd when can we expect this to hit release? thanks

fenghebaiyang commented 4 years ago

same issues on Xiao Mi 8 (On android 10) implementation 'com.github.bumptech.glide:glide:4.9.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'

maheshordex commented 4 years ago

Same issues on Pixel3a Android Q simulator.

leokwsw commented 4 years ago

same issue on Google Pixel 2 On Android 10 implementation 'com.github.bumptech.glide:glide:4.10.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'

anupmcommu commented 4 years ago

same issue... is there any alternative for this problem ?

alexatbooli commented 4 years ago

Well I removed Glide over this issue - didnt really enjoy the logs being chock full of stack traces.

Firsto commented 4 years ago

all images are loaded, but I got a lot of useless text in logcat - can I disable it without changing image library to picasso ????

thizisarun commented 4 years ago

Same Issue for me also. But if i remove Requestoptions then there is no exception log.Why?

Dimon70007 commented 4 years ago

I have changed

 .diskCacheStrategy(DiskCacheStrategy.RESOURCE)

to

 .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)

and got successfully decoded image instead of crash

perracodex commented 4 years ago

Take into account that ExifInterface 1.2.0-beta01 (androidx support library), adds support for WebP and PNG files, so instead of placing a RAW/JPEG exif filtering in Glide, probably would be better to wait for the next ExifInterface stable release.

https://developer.android.com/jetpack/androidx/releases/exifinterface#1.2.0-beta01

luohaohaha commented 4 years ago

same issue on Pixel 2(Android 10) implementation 'com.github.bumptech.glide:glide:4.10.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'

m4xp1 commented 4 years ago

Why issue closed? I still have same problem ((

implementation 'com.github.bumptech.glide:glide:4.10.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'

tarik-git commented 4 years ago
glideRequests.load(URI).into(imageView);

Why has this issue been closed. I still receive these errors on Android 10, and only on Android 10. Not only do i receive these annoying log messages but I load a lot of images and videos, and on Android 10, it is very slow. I tested this on a Pixel 1 device with Android 9, the images and videos were loading fast, when I updated the device to Android 10, with no change to the code the device started writing these logs and loading image and video thumbnails very slow.

baruchn commented 4 years ago

I also receive these errors on Android 10. This issue should definitely be reopened.

c0dehunter commented 4 years ago

Please reopen and fix, it's a major problem with Android 10!

sjudd commented 4 years ago

Glide 4.11 and onwards use the support library, but on android 10 you may still see these logs from other applications or the framework itself attempting to parse exif data

For more information on exif redaction which may cause these logs and/or impact performance, see: https://developer.android.com/training/data-storage/shared/media#location-info-photos.

If anyone sees Glide 4.11 or higher producing these logs, please file a new issue. I'm going to lock this one to reduce the noise.