Seeing a spike in time taken to call onFinalImageSet()
We are looking for a new image loading library to integrate into our app at Tumblr! I have been doing some tests with image loading with Fresco and have found some confusing numbers. When scrolling on a screen with posts of photo images, it seems like there are periodical "spikes" in the amount of time it takes to get the call to onFinalImageSet(). Do you know what could be causing these spikes in time taken?
Here are the times in nanoseconds per photo in the list to get the callback to onFinalImageSet() when scrolling:
12549844
88509685904
13293959
11237708
14732448
13187292
12714844
12402031
13750104
12819687
14428698
12699844
9623230
1586630313
12780364
9818229
8786926
10568542
13741719
12802866
12341875
12699322
15979010
11973958
13902761
10626875
9464844
1355040312
14773124
10577083
10939010
11904063
21926875
7778854
11411719
12646719
45118853
11554532
20886145
1437753594
13613385
9802083
7539947
6797344
10542864
10319427
23519167
17808230
17171302
24407031
16223438
13141927
7538229
7435365
Note: This spike in time seems to be notable by causing a subtle "stutter" in the scrolling experience
I assume you use controll listener to watch the bitmap status. I assume you scroll your screen before all the visible images finish download. Otherwise it won't have the spikes thing you talk about. Is it the case? And also what is the size of your images?
I assume you use controll listener to watch the bitmap status.
Yes. I'm using:
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setImageRequest(request)
.setControllerListener(new ControllerListener<ImageInfo>() {
@Override
public void onFinalImageSet(String s, @Nullable ImageInfo imageInfo, @Nullable Animatable animatable) {
// Time Logging code here ...
}
...
})
.build();
I assume you scroll your screen before all the visible images finish download
Those numbers reflect scrolling around a list of images that I have previously downloaded, so they are being loaded from cache. Test as follows:
- Scroll down the list, let all the images download.
- Scroll all the way to the top and see the images being loaded from cache. None of these images should have to be reloaded again.
And also what is the size of your images?
Image sizes range from 30KB - 500KB in this test.
For those downloaded images, they could be stored in bitmap cache, or disk cache. I suspect the "spikes" you mention are the time spent in caching disk. Can you check that? http://frescolib.org/docs/caching.html#_
Or even might not in cache at all if it's running out of space. Then it's fetching from network again. Please see if this is the case for you.