Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

frequent refresh listview..sometimes cause images flashing #189

Closed
lushan1314 opened this issue Apr 23, 2015 · 23 comments
Closed

frequent refresh listview..sometimes cause images flashing #189

lushan1314 opened this issue Apr 23, 2015 · 23 comments
Assignees

Comments

@lushan1314
Copy link

my adapter getView was simple :

 mSimpleDrawee.setImageURI(Uri.parse(item.img));

frequent call the method of notifyDataSetChanged, sometimes page kept flashing...

It seems caused by frequent load(or decode) pictures.
How to avoid it ? thank you !

@tyronen tyronen added the needs-details This issue or PR is currently not actionable as it misses details (e.g. for reproducing the problem) label Apr 23, 2015
@tyronen
Copy link
Contributor

tyronen commented Apr 24, 2015

Can you upload a video? What format of images are you showing, and are they network, or local?

@lushan1314
Copy link
Author

it is difficult to reproduce... the images from network.

i will upload the video , when it's reproduced again..

thank you

@lushan1314
Copy link
Author

2015050601

i found it again, when i call the mListView.notifyDataSetChanged();,the image kept flashing

please check the gif that i was upload.

thank you!

@tyronen tyronen removed the needs-details This issue or PR is currently not actionable as it misses details (e.g. for reproducing the problem) label May 8, 2015
@tyronen
Copy link
Contributor

tyronen commented May 8, 2015

Can you show us a code snippet?

I also wonder why only one image is affected. What kind of image is it (gif, jpeg, etc)? Is it animated?

@tyronen tyronen added the needs-details This issue or PR is currently not actionable as it misses details (e.g. for reproducing the problem) label May 8, 2015
@raylee4204
Copy link

This happens to me as well.

Here's my snippet of onBindViewHolder in RecyclerView Adapter:

ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(message.getImageUrl()))
                                .setPostprocessor(mTransformation)
                                .setResizeOptions(mResizeOptions)
                                .build();
DraweeController controller = Fresco.newDraweeControllerBuilder()
                                .setOldController(holder.imgAlbumArt.getController())
                                .setImageRequest(request)
                                .build();
holder.imgAlbumArt.setController(controller);

@appdev
Copy link

appdev commented May 12, 2015

lushan1314 Did you solve this problem?

@IanChilds
Copy link
Contributor

@raylee4204 - you will see this because your request includes a postprocessor, and at present postprocessed images are not stored in bitmap cache, so the postprocess step has to take place again which causes a flash.

@lushan1314 - please can you answer @tyronen's latest question so that we can try to help you?

@raylee4204
Copy link

@IanChilds Is there any future plan for postprocessed images to be stored?

@IanChilds
Copy link
Contributor

It's #14 - but I don't know when/if it will get done unfortunately.

@IanChilds IanChilds reopened this May 12, 2015
@lushan1314
Copy link
Author

sorry, i was busy.I just saw your reply.

@tyronen the image is jpeg. my code is simple , in the ListAdapter.getView

   if (StringUtils.isEmpty(user.iconUrl)) {
                    viewHolder.icon.setImageURI(FrescoUtils.getResUri(R.drawable.head_72));
                } else {
                    viewHolder.icon.setImageURI(FrescoUtils.getUri(user.iconUrl));
                }

in my case :
when the user clicks a button in the listview item, this line is selected,the state needs to be changed.
So I changed the list item associated the state of an object , and then call the notifyDataSetChanged(),then this problem happend.

I want to have a possibility: maybe the bitmap cache was deleted. call notifyDataSetChanged() make it reload.

But i did not understand about : the bitmap cache should not be deleted when the image is showing.

finally , i found one way solve it :

That is to find out the current display item view, and then change their status, avoid call setImageURI method again, because the notifyDataSetChanged () - > getView () - > setImageURI ()
something like this:

int first = mListView.getFirstVisiblePosition();
int last = mListView.getLastVisiblePosition();
View convertView;
for (int i = 0; i <= last-first; i++) {
    convertView = mListView.getChildAt(i);
    if (convertView != null) {
        //to do someting about ui change....
    }
}

@lushan1314
Copy link
Author

@tyronen this image is not animated

@IanChilds
Copy link
Contributor

Can you give a uri for the image that failed please?

@lushan1314
Copy link
Author

you mean fresco:failureImage?

@lushan1314
Copy link
Author

@tyronen i just tested ,GIF are happening every time, JPEG happens by chance.

@lushan1314
Copy link
Author

@IanChilds in version 0.4.0, if image's format isn't a GIF, I can't find this problem.

but if the image is a GIF, it's still happened.
you can use a uri for gif image ,and show on a ListView . you will find it.
thank you.

@plamenko plamenko removed the needs-details This issue or PR is currently not actionable as it misses details (e.g. for reproducing the problem) label Jul 8, 2015
@plamenko
Copy link
Contributor

plamenko commented Jul 8, 2015

As @IanChilds explained, the flash may happen if you are re-setting the image to the view and the image is not found in the bitmap cache.
Postprocessed images are not stored in the bitmap cache, but we are working on supporting this as we speak.
Animated images are also not stored in the bitmap cache and therefore they are susceptible to this issue. Up until recently, Fresco didn't distinguish between animated and static GIFs so the issue used to affect the static GIFs as well. This has been fixed and static GIFs should no longer be affected by this issue.
That being said, with the current version of Fresco, you should only experience this issue with animated and postprocessed images.

@lushan1314
Copy link
Author

ok , version 0.5.3?

@tyronen tyronen added the bug label Jul 15, 2015
@plamenko plamenko added needs-details This issue or PR is currently not actionable as it misses details (e.g. for reproducing the problem) and removed bug labels Dec 11, 2015
@plamenko
Copy link
Contributor

This may have been fixed now.

@tianlang
Copy link

楼主现在解决了吗?
我现在还有这种问题。
在5.0或者5.0.2系统上,如果MemoryCacheParams中的maxCacheSize,也就是bitmap缓存大小设置的比较小的话,一旦调用notifyDataSetChanged,listview里面的图片就会闪。
但是同样的bitmap缓存大小设置下,在5.1.1系统上就不会出现这样的问题,猜测跟5.0系统的内存泄露有一些关系,但是fresco设置也有关系,因为只要把bitmap缓存设置大一些就不会闪烁了。
不过5.0系统bitmap缓存设置大一些又容易OOM

@lushan1314
Copy link
Author

闪烁的问题,我目前测试只有gif才会有。因为gif一般是不缓存的好像。你说的问题我没遇到,看上去是一样的,如果缓存很快就满了,很容易发生这种情况。还有一种办法有点恶心了,就是你不要调用notify,可以获取listview的可见区域做修改,并尽量不修改图片。不过不知道是否适合你的情况。缓存策略的话只能自己取舍了

@tianlang
Copy link

能否告知一下 你的fresco配置中setBitmapMemoryCacheParamsSupplier的参数是怎么配置的?

@tyronen tyronen removed the needs-details This issue or PR is currently not actionable as it misses details (e.g. for reproducing the problem) label Jan 5, 2016
@tyronen tyronen closed this as completed Jan 7, 2016
@tmxdyf
Copy link

tmxdyf commented Jul 29, 2016

楼主解决了吗,求赐教!

@lushan1314
Copy link
Author

你是什么�问题呢?这个问题,我试了新版本是没有问题了哦。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants