glide
glide copied to clipboard
Compose: rememberGlidePreloadingData not preload, but use higher memory.
We use rememberGlidePreloadingData for preload, but we found that it didn't work properly and that memory usage was high.
val preloadingData = rememberGlidePreloadingData(
data = imageList,
preloadImageSize = Size(Target.SIZE_ORIGINAL.toFloat(), Target.SIZE_ORIGINAL.toFloat()),
numberOfItemsToPreload = numberOfItemsToPreload
) { item, requestBuilder ->
// Must call load() to trigger preloading
println("Preload ${item.url}")
requestBuilder.load(item.url)
}
LazyColumn....{
items(preloadingData.size) { index ->
....
- Preload not work properly
Because default value
numberOfItemsToPreload: Int = DEFAULT_ITEMS_TO_PRELOADis 10, we expect to load 10 times ahead. Event println("Preload ${item.url}") is call multiple times, the actual number of network calls is only once. (I use charles proxy to detect it.) So i think preload not work properly.
Preload xxxx1
Preload xxxx2
Preload xxxx3
Preload xxxx4
Preload xxxx5
Preload xxxx6
...
is printed. but network request whether it is the first load or the scroll process, only one is loaded at a time.
- memory usage is high. When i use preload code (not work preload), the memory usage is much higher than that does not use preload code. preload code will increase 60MB memory usage.
But non-preload code will just increase < 30MB。
We use 1.0.0-beta01
And use OkHttp3
Device: Emulator & Android 13.