hi guys, I have a performance scrolling issue in d...
# compose
k
hi guys, I have a performance scrolling issue in debug build on using LazyColumn. I see only way we can improve through in release build + R8 but not for debug build. I am asking debug build because my team members only test the application in debug build and I was convinced my teammates to use jetpack compose. If debug build was not improve I have to move back to xml view. Any feedback will be great for improving the debug build. Thanks
I see only problem in samsung devices. It working fine on pixel, one plus etc
s
Well, debug builds run slower due to the absence of JIT compiler optimizations and additional checks added by the Android Virtual Machine for debugging purposes. These characteristics don't reflect real-world app performance. Hence, evaluating performance should focus on Release builds + R8, which optimizes the code for end-users. Pixel and OnePlus devices may run the debug build smoothly due to their strong hardware performance which can offset inefficiencies present in Debug builds. For performance guidance, refer to the official Jetpack Compose performance documentation: https://developer.android.com/jetpack/compose/performance
Traditional Android Views may seem smoother in Debug builds because they're part of the Android framework, which is Ahead-Of-Time (AOT) compiled. This means they are pre-compiled to machine language during the system installation, benefiting from optimizations at the device level. On the other hand, Jetpack Compose, being newer and not as deeply integrated, has more overhead in Debug mode. However, in Release mode, unnecessary operations are removed, making its performance similar to traditional Android Views.
k
So it's not possible we can do it in debug build. I have already read this performance link. Thanks for explaining me in great detail.
s
Indeed, there's not a lot we can do on the client side to speed up Debug builds. Future Android versions may help, as they aim to improve runtime performance, which could potentially make Debug code execution faster. But fundamentally, Debug builds will always prioritize debugging assistance over performance.
k
okk sure, I'll keep in mind for all these steps
t
Why you can not provide release builds for testing?
It would be a shame when you just stop using compose only because it is a little bit slower in debug builds. Also often it is possible to optimize the composables inside of a LazyList and get much better performance also in debug builds.
k
In the application, user can purchase item online. In release build we can mock purchase items history. That's why we cannot test in release build.
How can we improve the lazylist items?
t
You could also mock history in release builds if you use flavors to generate different builds for different environments.
Optimizing the views is not so easy. E.g. i found out that calculating the width for text fields is very expensive. But it really depends on what you want to display. But also in legacy layout you had to optimize this things. So in my experience Compose is not slower than legacy layout when you do it right.
k
Thanks for the heads up. I'll take a look now
t
Maybe you could provide some compose code of the list items. Than maybe someone could help you to opimize it.
k
Sure, I'll try to send the code
s
If you are running apps from Android Studio, you can try disabling live literals It is known to cause some performance issues
k
Yeah I tried to disable it but nothing works on Samsung devices.
t
Is it a very old device on which the performance problems happen? Can you tell us a little bit what kind of composables you are using in the list cells? E.g.: I did had performance porblems when i show images in the list which do have high resolutions. I solved this by loading the images only scaled down to the correct size. This improved the performance alot.
k
It's not an old device. If you check the Samsung S series it will cause the problem. If I changed from LazyColumn to column it works without any problem
In LazyColumn if I only show text it will cause a scroll issue.