Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compose: rememberGlidePreloadingData not preload, but use higher memory. #5399

Open
cuichanghao opened this issue Apr 15, 2024 · 0 comments
Open

Comments

@cuichanghao
Copy link

cuichanghao commented Apr 15, 2024

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 cuichanghao changed the title rememberGlidePreloadingData not preload, but use higher memory. Compose: rememberGlidePreloadingData not preload, but use higher memory. Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant