question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ResizeOptions is not working in Fresco 1.7.1?

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jyh149129commented, Dec 26, 2017

me too

1reaction
AlexCJWcommented, Dec 25, 2017

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Solved: Resizing project in Fresco - Adobe Support Community ...
Perfect timing. Its now available in Fresco. In the project, hit the gear icon and by the file size, there should be a...
Read more >
Fresco custom image decoder resize options are not applied
I believe that resizing is done before decoding (i.e. the image is transcoded to a smaller JPEG) - and only JPEG is supported...
Read more >
com.facebook.imagepipeline.request.ImageRequestBuilder ...
The underlying image loading mechanism of the Fresco library ... ResizeOptions; import com.facebook.imagepipeline.common. ... This is not * an image.
Read more >
Resizing | Fresco
Resizing does not modify the original file, it just resizes an encoded image in memory, prior to being decoded. To resize pass a...
Read more >
Android 壁画调整大小选项, 壁画机器人, Android 壁画初始化, 图片 ...
ResizeOptions is not working in Fresco 1.7.1 ? · Issue #2000 ,. Fresco 多图加载之ResizeOptions 分类: 技术| 标签: Android Fresco | 作者:兜兜夏更新 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found