Slow reads from disk cache
Does anybody test the different Adapter in the real environment?Why the fresco is slower than UIL?
Here is my data on Nexus 6 with sample in WIFI:
First run after install:UIL used 1225ms per pic, Fresco 516ms.
First in after reboot:UILused 50ms per piv,fresco 103ms
ReEnter after press back from app:UIL used 0ms, fresco 45ms.
And So on...
SO, in most user case,the fresco is not best in the groups.Do anybody know the reason? Is it release the cache memory when the app going background immediately,and others not?
This is not consistent with results we've found in the sample app. Can you share the URLs you were testing and source snippets?
Sure. I just modfiy the URLs.
{
FLog.w(TAG, "onImageLoaderSelect: %d", index);
if (mCurrentAdapter != null) {
mCurrentAdapter.shutDown();
mCurrentAdapter = null;
System.gc();
}
mCurrentAdapterIndex = index;
mPerfListener = new PerfListener();
switch (index) {
case FRESCO_INDEX:
case FRESCO_OKHTTP_INDEX:
mCurrentAdapter = new FrescoAdapter(
this,
R.id.image_list,
mPerfListener,
index == FRESCO_INDEX ?
ImagePipelineConfigFactory.getImagePipelineConfig(this) :
ImagePipelineConfigFactory.getOkHttpImagePipelineConfig(this));
break;
case GLIDE_INDEX:
mCurrentAdapter = new GlideAdapter(this, R.id.image_list, mPerfListener);
break;
case PICASSO_INDEX:
mCurrentAdapter = new PicassoAdapter(this, R.id.image_list, mPerfListener);
break;
case UIL_INDEX:
mCurrentAdapter = new UilAdapter(this, R.id.image_list, mPerfListener);
break;
case VOLLEY_INDEX:
mCurrentAdapter = mUseDrawee ?
new VolleyDraweeAdapter(this, R.id.image_list, mPerfListener) :
new VolleyAdapter(this, R.id.image_list, mPerfListener);
break;
default:
mCurrentAdapter = null;
return;
}
mImageList.setAdapter(mCurrentAdapter);
mImageUrls = new ArrayList<String>();
mImageUrls.add("http://image.tianjimedia.com/uploadImages/2012/088/10G3888TY0HX_1000x500.jpg");
mImageUrls.add("http://image.tianjimedia.com/uploadImages/2012/088/CW71CYPXQ6PO_1000x500.jpg");
mImageUrls.add("http://image.tianjimedia.com/uploadImages/2012/088/3O4P49PRB99R_1000x500.jpg");
mImageUrls.add("http://image.tianjimedia.com/uploadImages/2012/088/Q172G69LA1RT_1000x500.jpg");
mImageUrls.add("http://image.tianjimedia.com/uploadImages/2012/088/BFPWRM8PBV74_1000x500.jpg");
mImageUrls.add("http://img4q.duitang.com/uploads/item/201503/08/20150308190453_nCZCB.jpeg");
mImageUrls.add("http://cdnq.duitang.com/uploads/item/201503/20/20150320045435_Wh3Ah.jpeg");
mImageUrls.add("http://cdnq.duitang.com/uploads/item/201503/01/20150301223521_hi8Za.jpeg");
mImageUrls.add("http://img5q.duitang.com/uploads/item/201503/03/20150303202714_WXYMB.jpeg");
mImageUrls.add("http://img4q.duitang.com/uploads/item/201502/26/20150226231036_hhPQu.jpeg");
if (mImageUrls != null && !mImageUrls.isEmpty()) {
updateAdapter(mImageUrls);
} else {
reloadUrls();
}
updateStats();
} "
And I have checked the source code,I found that Fresco "cache.clearEvictionQueue()" when "OnAppBackgrounded",but the UIL" mImageLoader.clearMemoryCache()" until shutDown. So when app show from the backgroud, the UIL load image from memory cache used 0ms,and Fresco used xx ms.Can we control the time for clear cache??
I will have a look at those URLs.
I actually would call this a bug in UIL. Although your app appears faster with UIL, it's because it is holding onto memory even while in the background. This takes away memory other apps could be using, and makes them slower. It also increases the chances that Android will terminate your app, especially on low-memory devices.
If Fresco did that, the consequence would be even worse, since Fresco is using ashmem memory which is shared among applications. Using a lot of it while in the background would be bad for the entire system.
Yes. We intentionally clear the memory caches when the app gets backgrounded. This is a proper policy in order to be a good citizen in a larger system. Imagine if all the apps with bunch of images never reclaim their resources. As Tyrone said, the app would likely get killed, which is worse than doing another decode.
yes, the UIL seems got the unjustified benefit:)
Nothing extra to do here - of course reading from disk cache is slower than reading from memory, and we're doing the correct thing in releasing memory when the application is closed. Let's close the issue. .