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

Unsupported marker type 0x4f throwed when TranscodeJpeg #1903

Open voiddog opened 7 years ago

voiddog commented 7 years ago

Description

I catch an exception when decode a large jpeg image (taken with Samsung Galaxy S8+), here is the exception:

java.lang.RuntimeException: Unsupported marker type 0x4f
     at com.facebook.imagepipeline.nativecode.JpegTranscoder.nativeTranscodeJpeg(Native Method)
     at com.facebook.imagepipeline.nativecode.JpegTranscoder.transcodeJpeg(JpegTranscoder.java:66)
     at com.facebook.imagepipeline.producers.ResizeAndRotateProducer$TransformingConsumer.doTransform(ResizeAndRotateProducer.java:198)
:    at com.facebook.imagepipeline.producers.ResizeAndRotateProducer$TransformingConsumer.access$000(ResizeAndRotateProducer.java:85)
     at com.facebook.imagepipeline.producers.ResizeAndRotateProducer$TransformingConsumer$1.run(ResizeAndRotateProducer.java:102)
     at com.facebook.imagepipeline.producers.JobScheduler.doJob(JobScheduler.java:207)
     at com.facebook.imagepipeline.producers.JobScheduler.access$000(JobScheduler.java:27)
     at com.facebook.imagepipeline.producers.JobScheduler$1.run(JobScheduler.java:78)

Reproduction

  1. download the photo file: click to download 67.2MB
  2. enable setDownsampleEnabled(true) (if not, works fine)
  3. show image with SimpleDrawee
    ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(imgUri))
                .setResizeOptions(new ResizeOptions(200, 200))
                .setRotationOptions(RotationOptions.autoRotate())
                .build();
    img.setController(Fresco.newDraweeControllerBuilder().setImageRequest(imageRequest)
                .setOldController(img.getController()).build());

Additional Information

erikandre commented 7 years ago

@voiddog The attached image is more than 23000 pixels wide. As a workaround I would suggest reducing the size to something more manageable.

voiddog commented 7 years ago

I scanned the picture from the album, so I can not control the size of the picture.

There is another problem: After the above error is triggered, it is easy to cause sharedmem_gpumem_alloc: mmap failed errno 12 Out of memory. Every time I start a web will have this error.