Fresco requests same URI several times
Hi ,I recently encountered a problem that Fresco repeat request with same URI.For example,there is a listview, refresh it several times the problem happens, the requests of some pictures are send repeatly.The following is the request I catch.
Can you help me?
Actually I think It's reasonable to load a image for only once ~~~It wastes resource to send several requests for the same image.So I wonder weather there a method to avoid request same image.
You are absolutely right in that this should not happen. We have a logic in place that should prevent that from happening, but there may be a bug. Can you provide some more information please?
- How/where do you initialize Fresco?
- What do you mean by refreshing the listview? Do you mean Adapter.dataSetChanged or something else?
- Can you please provide a verbose logcat:
adb logcat -v threadtime | grep -iE 'LoggingListener|AbstractDraweeController'
I simulated the situation that I had met.
Uri1,Uri2,Uri3 are different images, in my project it may happen that the list may use notifyDataSetChanged() many times at same time.So I simulated the situation ,you will find it will request the same uri several times.

Try the following codes:
public class MainActivity extends Activity {
SimpleDraweeView imageTest,imageTest2,imageTest3;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Fresco.initialize(this);
setContentView(R.layout.activity_main);
imageTest2=(SimpleDraweeView)findViewById(R.id.user_avator1);
imageTest=(SimpleDraweeView)findViewById(R.id.user_avator);
imageTest3=(SimpleDraweeView)findViewById(R.id.user_avator2);
final Uri uri1 = Uri.parse("http://pic7.qiyipic.com/image/20150427/c3/9f/a_100011875_m_601_284_160.jpg");
final Uri uri2 = Uri.parse("http://pic7.qiyipic.com/image/20150213/b2/aa/a_100010483_m_601_284_160.jpg");
final Uri uri3 = Uri.parse("http://pic1.qiyipic.com/image/20150720/76/18/a_100013208_m_601_m5_284_160.jpg");
Button btn=(Button)findViewById(R.id.button);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
for(int i=0;i<40;i++) {
imageTest2.setImageURI(uri1);
imageTest.setImageURI(uri2);
imageTest3.setImageURI(uri3);
imageTest3.setImageURI(uri2);
imageTest2.setImageURI(uri3);
imageTest.setImageURI(uri1);
}
}
});
}
}
Could you tell me the where is logic to avoid repeat request ,not the cache~The premise is that the picture has not yet requested successfully.
This ought to be blocked by the EncodedMemoryCacheMultiplexProducer.
We're cleaning up long-untouched issues so I'm closing this one.
If you think this is still an issue, feel free to comment and we can re-open.
I also encountered this problem. When the image is downloading I close the activity, then reopen it, the image will download twice. Also, in RecyclerView when I scroll the list up and down quickly, some Images will download several times. This is a demo for this bug. https://github.com/binwin20/frescoDemo