glide icon indicating copy to clipboard operation
glide copied to clipboard

Compose: rememberGlidePreloadingData not preload, but use higher memory.

Open cuichanghao opened this issue 1 year ago • 0 comments

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.

  1. 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.

ee45a50a-02f3-452c-8309-4b9e1f14605f

But non-preload code will just increase < 30MB。

We use 1.0.0-beta01

And use OkHttp3

Device: Emulator & Android 13.

cuichanghao avatar Apr 15 '24 08:04 cuichanghao