Compose: rememberGlidePreloadingData not preload, but use higher memory.
- Dominant language
- Java
- Stars
- 35k
- Forks
- 6.2k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 8
Description
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 ->
....
```
1. Preload not work properly
Because default value `numberOfItemsToPreload: Int = DEFAULT_ITEMS_TO_PRELOAD` is 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.
2. 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](https://mvnrepository.com/artifact/com.github.bumptech.glide/compose/1.0.0-beta01)
And use OkHttp3
Device: Emulator & Android 13.
Contributor guide
Assessment
This issue has not been assessed yet.