fresco icon indicating copy to clipboard operation
fresco copied to clipboard

ResizeOptions is not working in Fresco 1.7.1?

Open MidoriInu1 opened this issue 8 years ago • 9 comments

Description

Excuse me. I can not confirm this is a bug, but when I update Fresco version to 1.7.1, ResizeOptions is not working, but it works normally in version 1.5.0. Please help me to test this function. thx.

Reproduction

This is my code:
public static void loadImgByFile(CommonImageView imageView, String path) {
        if (imageView != null && !TextUtils.isEmpty(path)) {
            File file = new File(path);
            //if size too large then resize
            if (file.exists()) {
                BitmapFactory.Options options = new BitmapFactory.Options();
                options.inJustDecodeBounds = true;
                BitmapFactory.decodeFile(path, options);
                int imageHeight = options.outHeight;
                int imageWidth = options.outWidth;
                int maxSize = getGLESTextureMaxSize();
                Log.e("texture---test---->", "imageHeight=" + imageHeight
                        + "    imageWidth=" + imageWidth
                        + "    maxSize=" + maxSize
                );
                if (maxSize <= imageHeight || maxSize <= imageWidth) {
                    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.fromFile(file))
                            .setResizeOptions(new ResizeOptions(maxSize/2, maxSize/2,maxSize))
                            .build();

                    DraweeController controller = Fresco.newDraweeControllerBuilder()
                            .setImageRequest(request)
                            .setOldController(imageView.getController())
                            .build();
                    imageView.setController(controller);
                    Log.e("texture---test---->", "controller=" + controller);
                    return;
                }
            }
            imageView.setImageURI(Uri.parse("file://" + path));
        }
    }
private static int OPENGL_MAX_SIZE = 0;
    private static int getGLESTextureMaxSize() {
        if (OPENGL_MAX_SIZE != 0) {
            return OPENGL_MAX_SIZE;
        }
        EGL10 egl = (EGL10) EGLContext.getEGL();
        EGLDisplay dpy = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
        int[] vers = new int[2];
        egl.eglInitialize(dpy, vers);
        int[] configAttr = {
                EGL10.EGL_COLOR_BUFFER_TYPE, EGL10.EGL_RGB_BUFFER,
                EGL10.EGL_LEVEL, 0,
                EGL10.EGL_SURFACE_TYPE, EGL10.EGL_PBUFFER_BIT,
                EGL10.EGL_NONE
        };
        EGLConfig[] configs = new EGLConfig[1];
        int[] numConfig = new int[1];
        egl.eglChooseConfig(dpy, configAttr, configs, 1, numConfig);
        if (numConfig[0] == 0) {// TROUBLE! No config found.
        }
        EGLConfig config = configs[0];
        int[] surfAttr = {
                EGL10.EGL_WIDTH, 64,
                EGL10.EGL_HEIGHT, 64,
                EGL10.EGL_NONE
        };
        EGLSurface surf = egl.eglCreatePbufferSurface(dpy, config, surfAttr);
        final int EGL_CONTEXT_CLIENT_VERSION = 0x3098; // missing in EGL10
        int[] ctxAttrib = {
                EGL_CONTEXT_CLIENT_VERSION, 1,
                EGL10.EGL_NONE
        };
        EGLContext ctx = egl.eglCreateContext(dpy, config, EGL10.EGL_NO_CONTEXT, ctxAttrib);
        egl.eglMakeCurrent(dpy, surf, surf, ctx);
        int[] maxSize = new int[1];
        GLES10.glGetIntegerv(GLES10.GL_MAX_TEXTURE_SIZE, maxSize, 0);
        egl.eglMakeCurrent(dpy, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE,
                EGL10.EGL_NO_CONTEXT);
        egl.eglDestroySurface(dpy, surf);
        egl.eglDestroyContext(dpy, ctx);
        egl.eglTerminate(dpy);
        OPENGL_MAX_SIZE = maxSize[0];
        return OPENGL_MAX_SIZE;
    }
When i run them in Fresco 1.7.1 ,the Logcat showing:

image

The ResizeOptions is not working. SimpleDraweeView shows blank. I think it is because that OpenGLRenderer can't load the jpeg image, when the height or width of the jpeg image is too large. DraweeController should have loaded the ResizeOptions which I set, but it uploaded the original image to OpenGLRenderer instead.

When i run them in Fresco 1.5.0 ,the Logcat showing:

image The ResizeOptions is working normally. SimpleDraweeView can show pictures.

Just a guess

I noticed in the page: image Region decoding support is added in this version, this commit(bd249fa) changed ArtDecoder. I can not confirm the problem because of this commit.

Some device parameters

  • Device Model: HUAWEI P9 (HUAWEI EVA-AL00)
  • Platform: Android 7.0
  • API level: 24
  • Screen resolution: 1080*1920
  • CPU: Hisilicon Kirin 955
  • RAM: 3.0 GB

MidoriInu1 avatar Dec 20 '17 10:12 MidoriInu1

Thanks for reporting this issue. Maybe, @oprisnik can check if this issue caused by region decoding.

dmitry-voronkevich avatar Dec 20 '17 11:12 dmitry-voronkevich

Hi @MidoriInu1

Thanks for submitting the bug report. I tried to reproduce this in the Showcase app using our normal test images, but no luck.

Would it be possible for you to share one of your test images so that we can try it out? Thanks!

erikandre avatar Dec 21 '17 14:12 erikandre

Hi @erikandre I uploaded a zip file containing three of the test images. images.zip Please download and unzip the file, then put the images into SD card, and call setImageURI(Uri.fromFile(file)).

Those images are test cases of my project, to test corner situations. I can reproduce the issue with those images in Fresco 1.7.1.

Hope this post may help, thx!

MidoriInu1 avatar Dec 23 '17 13:12 MidoriInu1

I met this issue, too. I have to roll back fresco in my project to 1.5.0.

AlexCJW avatar Dec 25 '17 05:12 AlexCJW

me too

jyh149129 avatar Dec 26 '17 11:12 jyh149129

me too, my device is huawei mate 8

eaggle avatar Dec 28 '17 11:12 eaggle

I've just tested with the current master version and the Showcase app correctly resizes JPEG images. However, you're right @MidoriInu1, PNG downsampling is broken. I should have a fix shortly. Thanks for reporting!

oprisnik avatar Dec 28 '17 14:12 oprisnik

webp have the same problem

eaggle avatar Dec 28 '17 15:12 eaggle

The fix is now available, see e2c464efbc9214d1a00aa416d3d9cfb26c0298da. Also fixes the issue for WebP.

oprisnik avatar Dec 28 '17 15:12 oprisnik