ResizeOptions is not working in Fresco 1.7.1?
See original GitHub issueDescription
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:
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:
The ResizeOptions is working normally. SimpleDraweeView can show pictures.
Just a guess
I noticed in the page: 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:
- Created 6 years ago
- Reactions:2
- Comments:9 (3 by maintainers)
Top GitHub Comments
me too
I met this issue, too. I have to roll back fresco in my project to 1.5.0.