https://kotlinlang.org logo
#compose
Title
# compose
p

P Valintelis

09/19/2023, 8:54 AM
Hello, yet another Compose performance question. We have some issues in our main project related to images grid performance and we were quite surprised to see same issues 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 Full app code: https://github.com/PauliusVal/ComposeGridPerformance/tree/main Any ideas what is wrong here? Should go directly to Coil developers with this?
1
Profiler output:
m

myanmarking

09/19/2023, 11:01 AM
in my device runs fine
also checked out the code. no recomposition problems
Pixel 6a. Also, i run debug. release should be faster
maybe device specific ? idk
p

P Valintelis

09/19/2023, 11:02 AM
Mine: Samsung S21 Ultra
m

myanmarking

09/19/2023, 11:03 AM
latest compose version ?
i tried very hard to ‘see’ lag with naked eye. none
screencap-2023-09-19T110551.264Z.mp4
p

P Valintelis

09/19/2023, 11:06 AM
Latest Compose (though same issues on older version):
compose-bom:2023.09.00
m

myanmarking

09/19/2023, 11:06 AM
ignore the blue thing. its recomposition debug stuff
can you identify the lag there? it is debug tho
p

P Valintelis

09/19/2023, 11:07 AM
Well, it feels janky in this video.
m

myanmarking

09/19/2023, 11:07 AM
what. no kidding
how do you see junky xD
p

P Valintelis

09/19/2023, 11:07 AM
Can you check profiler?
Just a second, I will send a video with real issue
I agree, smaller janks look +- fine (thoug still not acceptable), but suddenly you get bigger one.
m

myanmarking

09/19/2023, 11:12 AM
ya. a bit i guess
p

P Valintelis

09/19/2023, 11:12 AM
The problem with this gets bigger if you have something more complex than just an image card.
It is somehow hard to see in video, but the whole fling slow down gets choppy.
c

Corey

09/19/2023, 12:37 PM
Did you try with any other image loading library other than Coil? I wonder if it is somehow related to Coil https://github.com/coil-kt/coil/issues/1610 We also use coil in here and we have the same problem, but we just accepted the fate
😢 1
👀 1
p

P Valintelis

09/19/2023, 12:47 PM
I think with Glide it was a bit better, though Glide is still in alpha… Will update that example with Glide as well, to see the difference.
a

ascii

09/19/2023, 1:20 PM
I wonder if it's specific to LazyVerticalGrid only? I only have LazyColumns in my app, and while profiling does occasionally show hitches here and there, it happens with both Coil & Glide. I blamed by poor code structuring for these minor issues, because I'm reading from disk (shared prefs, etc) in a Compose view. Perhaps you've got something similar?
🤔 1
p

P Valintelis

09/20/2023, 7:06 AM
Added Glide to example app, it looks and feels much better. Few janky frames visible in profiler, but not as much as in Coil example. https://kotlinlang.slack.com/archives/CJLTWPH7S/p1695127028304609?thread_ts=1695113646.842899&cid=CJLTWPH7S
👍 1
f

Fredrik Larsen

09/20/2023, 10:14 AM
Same jank issue on the devices I’ve tested with. Samsung S22, Huawei P20 Pro.
@Adam Powell would it be possible to escalate this please?
🐛 For the record a ticket was submitted for this issue https://issuetracker.google.com/issues/301353347