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

Performance issue in lazy grid #1866

Open
PauliusVal opened this issue Sep 19, 2023 · 16 comments
Open

Performance issue in lazy grid #1866

PauliusVal opened this issue Sep 19, 2023 · 16 comments
Labels
help wanted Issues that are up for grabs + are good candidates for community PRs

Comments

@PauliusVal
Copy link

Description
Compose performance issue in super simple app which just displays network images list using Coil.

We see noticeable jank while scrolling even though:

  • app runs in R8 release mode
  • contains baseline profile for scrolling screen
  • stable Compose parameters used
  • unique and stable item keys applied for grid items

Jank is visible by human eye and also in profiler:
https://github.com/PauliusVal/ComposeGridPerformance/blob/main/images/images_grid_janky_frames_1.png?raw=true

Full app code and more screenshots: https://github.com/PauliusVal/ComposeGridPerformance/tree/main

Version
Coil version: io.coil-kt:coil-compose:2.4.0

@colinrtwhite
Copy link
Member

colinrtwhite commented Sep 19, 2023

Thanks for the repro project. Which device did you run the tests on?

@colinrtwhite colinrtwhite added the help wanted Issues that are up for grabs + are good candidates for community PRs label Sep 19, 2023
@PauliusVal
Copy link
Author

Samsung S21 Ultra, Android 13

@PauliusVal
Copy link
Author

Not sure if that helps, but updated the app with identical grid just with Glide image loading. It has noticeably fewer janky frames in profiler and looks/feels much smoother.

@Mkohm
Copy link

Mkohm commented Sep 22, 2023

Same problem here, seems to use a lot of memory! Up to 2gigs of memory in my app when scrolling in lazy column with images.

@lkhore
Copy link

lkhore commented Nov 6, 2023

Same issue janky frames with grid

@colinrtwhite
Copy link
Member

@Mkohm That sounds like it could be a separate memory leak. Please file an issue (ideally with a way to reproduce)!

@lkhore Did you test in release mode? Compose is often much slower in debug mode.

@serhatkarakoca
Copy link

Same problem in release and debug mode.

@Kuki93
Copy link

Kuki93 commented Dec 15, 2023

Is there any progress on this issue

@matejdro
Copy link

matejdro commented Dec 21, 2023

I've added benchmark and tracing here to make diagnosing this easier: matejdro/ComposeGridPerformance@beb902c

Here is an example trace file (from Pixel 7 Pro): ScrollBenchmark_scrollImageList_iter003_2023-12-21-08-27-41.perfetto-trace.zip

Not sure why the trace is so weird (it shows one big compose event spanning multiple seconds), but you can still drill down and it appears that rememberAsyncPainter is taking considerable time:

image

@hellosagar
Copy link

hellosagar commented Dec 24, 2023

Im noticing a heavy jank in scrolling with LazyGrid as well. In my application compose:lazylist:prefetch:measure is taking around 229.935506 ms 👀

@musooff
Copy link

musooff commented Feb 6, 2024

I am simple loading local images and showing with coil. There is a noticeable lagging (skipping lots of frames) especially in older devices.
During first showing of the LazyVerticalGrid it is almost unusable.
Below is the video to show the lag with HWUI rendering.
And yes, it is in release mode. In debug you can't even scroll.

coil.performance.mov

@felipef0xx
Copy link

Same problem here with Coil's Compose Sample:

Screen_Recording_20240207_165837_Coil.mp4

Coil version: 2.5.0
Device: Galaxy M23 5G

@felipef0xx
Copy link

It looks like it's not just related to LazyGrid.
Changed the Compose Sample to LazyColumn and the problems still happen:

Screen_Recording_20240208_133733_Coil.mp4

@mainrs
Copy link

mainrs commented Feb 16, 2024

Hope I can somehow help with this. I am using LazyColumn and each item has an AsyncImage ("episode item"). Is there anything I can provide: debug logs, source code, ....?

@x3x0z
Copy link

x3x0z commented Apr 14, 2024

I have the same error, I'm using a LazyVerticalGrid with +8k items (I'm also using pagination), after fast scrolling through more than 3k items, the application gets super slow, even the android emulator stops working.

@Cj-Rodriguez101
Copy link

Hope I can somehow help with this. I am using LazyColumn and each item has an AsyncImage ("episode item"). Is there anything I can provide: debug logs, source code, ....?

Does it still happen on 2.6.0?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issues that are up for grabs + are good candidates for community PRs
Projects
None yet
Development

No branches or pull requests