One thing I'm noticing while developing my app is ...
# compose-android
m
One thing I'm noticing while developing my app is the incredible amount of lag that occurs while navigating it, is there anything I can do to prevent this from happening?
s
No expert in the area, but I think the most common response you'll get is “have you tried it in release mode with R8 enabled?”.
m
what does that mean? I'm just pressing the run button in Android Studio
c
Then google how to do a release build with R8 enabled 😅
s
A release build is essentially the kind of build that you would ship to your end users. It typically takes some more time to build, as there are more tasks performed to produce one, but it will heavily optimize the resulting code by removing stuff that doesn't need to be there. Conversely, debug builds (which are what you build by default when clicking the Run button in Studio) are the opposite, in that they will not optimize your code, but instead actually add extra stuff into your code to enable you to develop the app more easily. You can read more about Release mode here: https://developer.android.com/studio/publish/preparing
m
Is there a way to run the debug version on the emulator or would I have to copy it over to my phone?
I tried setting it in the Build Variants menu, but now it requires signing, and I don't know which of the generated pk8/pem files it needs, or even where to set it
Also if release mode is the only way to realistically run compose apps, how are you supposed to debug them?
r
Release mode will give you release-level performance, which is not necessary to test/debug applications in general. That said, this is something we’re working on to improve, and you may have noticed that recent versions of Compose brought in a series of optimizations, with more to come.
m
Looks like switching from lazy to regular and enabling K2 massively improves debug performance, so using that for now
t
K2 have no impact, with that said since 1.6 Lazy XXX are insanely slow in debug mode, don't know what changed but while it makes life harder, it allows to trigger a lot easier many node related crashes.
m
According to my experience the main difference is between running on the emulator or on a real device. On my mac/Intel the performance of my app on the emulator is just a catastrophe but the same app runs smoothly on a simple device even in debug mode.
m
I'm experiencing the same performance issues on my physical device unfortunately
a
try replacing lazy column and lazy row with regular column and row because you're not reusing anything anyways. That should remove a bit of overhead. Also, you could use weights to make your code cleaner
c
Looking at the code, try loading the image resource off the main thread. Also, you do not cache it anywhere.
☝🏻 1