facebook / fresco

An Android library for managing images and the memory they use.
https://frescolib.org/
MIT License
17.07k stars 3.75k forks source link

some huawei cellphone can not load image successfull #2492

Closed hanbaokun closed 4 years ago

hanbaokun commented 4 years ago

Description

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: 4749 at android.media.ExifInterface.readByteOrder(ExifInterface.java:3191) at android.media.ExifInterface.isOrfFormat(ExifInterface.java:2501) at android.media.ExifInterface.getMimeType(ExifInterface.java:2379) at android.media.ExifInterface.loadAttributes(ExifInterface.java:1801) at android.media.ExifInterface.initForFilename(ExifInterface.java:2361) at android.media.ExifInterface.(ExifInterface.java:1413) at com.facebook.imagepipeline.producers.LocalExifThumbnailProducer.getExifInterface(LocalExifThumbnailProducer.java:131) at com.facebook.imagepipeline.producers.LocalExifThumbnailProducer$1.getResult(LocalExifThumbnailProducer.java:95) at com.facebook.imagepipeline.producers.LocalExifThumbnailProducer$1.getResult(LocalExifThumbnailProducer.java:90) at com.facebook.common.executors.StatefulRunnable.run(StatefulRunnable.java:43) at java.util.concurrent.ThreadPoolExecutor.processTask(ThreadPoolExecutor.java:1187) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at com.facebook.imagepipeline.core.PriorityThreadFactory$1.run(PriorityThreadFactory.java:50) at java.lang.Thread.run(Thread.java:929) 2020-04-24 17:24:38.321 12456-12456/com.lanjingren.ivwen W/FrescoIoBoundEx: type=1400 audit(0.0:10737677): avc: granted { read } for pid=12456 name="2e9fe611be014455bff842049ca26889..gif" dev="sdcardfs" ino=41623 scontext=u:r:untrusted_app_27:s0:c2,c258,c512,c768 tcontext=u:object_r:sdcardfs:s0 tclass=file 2020-04-24 17:24:38.322 12456-13483/com.lanjingren.ivwen 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: 4749 at android.media.ExifInterface.readByteOrder(ExifInterface.java:3191) at android.media.ExifInterface.isOrfFormat(ExifInterface.java:2501) at android.media.ExifInterface.getMimeType(ExifInterface.java:2379) at android.media.ExifInterface.loadAttributes(ExifInterface.java:1801) at android.media.ExifInterface.initForFilename(ExifInterface.java:2361) at android.media.ExifInterface.(ExifInterface.java:1413) at com.facebook.imagepipeline.producers.LocalExifThumbnailProducer.getExifInterface(LocalExifThumbnailProducer.java:131) at com.facebook.imagepipeline.producers.LocalExifThumbnailProducer$1.getResult(LocalExifThumbnailProducer.java:95) at com.facebook.imagepipeline.producers.LocalExifThumbnailProducer$1.getResult(LocalExifThumbnailProducer.java:90) at com.facebook.common.executors.StatefulRunnable.run(StatefulRunnable.java:43) at java.util.concurrent.ThreadPoolExecutor.processTask(ThreadPoolExecutor.java:1187) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at com.facebook.imagepipeline.core.PriorityThreadFactory$1.run(PriorityThreadFactory.java:50) at java.lang.Thread.run(Thread.java:929)

Reproduction

[FILL THIS OUT: How can we reproduce the bug? Provide URLs to relevant images if possible, or a sample project.]

Solution

some huawei cellphone can not load image failed , and all image will load failure.

Additional Information

defHLT commented 4 years ago

Is there a problem with images taken with this device? Or the device can't display images?

hanbaokun commented 4 years ago

When loading pictures, once this error occurs, all pictures cannot be loaded normally

oprisnik commented 4 years ago

Looks like there's either a bug in Android's ExifInterface or these devices are creating corrupt EXIF metadata. The exception is thrown in the Android system here: https://android.googlesource.com/platform/frameworks/base/+/49371ca/media/java/android/media/ExifInterface.java#1379

It might be that this was fixed by the androidx EXIF version. However, we decided not to ship this as part of Fresco since it significantly increased Fresco's APK size footprint. You can try and re-apply the changeset that added this a while ago or manually try and read the image using both ExifInterface classes to see if it makes a difference. More information on what we did: https://github.com/facebook/fresco/issues/2312#issuecomment-517694584

stale[bot] commented 4 years ago

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "bug" or "enhancement" and I will leave it open. Thank you for your contributions.

kmrinmoy07 commented 4 years ago

I was also having a problem with huawei cellphone, some images were not loading. Then I found that those images' file name contains blank white space so I just replaced those white space with %20 using replace(" ", "%20") and everything was solved

oprisnik commented 4 years ago

Looks like this will fix the issue then. Let us know if it doesn't.

FoxTong commented 3 years ago

targetSdk 29 (scoped storage) support?