1

I am developing an app using Jetpack Compose.

The algorithmic parts of this application were acting slow and hence I started profiling the app.

The function which is consuming most of the time, according to the profiler, is isLiveLiteralsEnabled() which is part of the Compose runtime. And this is getting called in the most innocuous places, such as integer additions within nested loops.

As I understand it, the compose compiler plugin is instrumenting the code for some reason.

What is this reason? And how do I disable / workaround it?

3
  • 2
    Live literals is something new added to Android Studio as part of its composable preview system. Do you see the slowdowns if you do not have preview composables or the preview pane open? Mar 7, 2021 at 15:49
  • 1
    @CommonsWare Thanks for the pointer. However, removing the Previews and the tooling library was not enough. As per deaddroid's answer one has to toggle a setting in AS.
    – HRJ
    Mar 7, 2021 at 18:34
  • 2
    Another possibility might be the @NoLiveLiterals annotation, though I have not tried this yet. Mar 14, 2021 at 16:54

2 Answers 2

2

You can disable those by clicking on bottom-right icon in the android studio.

enter image description here

1
  • Time moves on and in later versions of AS (Giraffe) there is no such icon in the bottom right of the screen. There may be text at the top of the code screen about it, which can be clicked, or there is now an entry in the settings dialog, under Editor->Live Edit
    – Markers
    Jun 16 at 11:08
1

The answer by deaddroid is on the mark, so I have accepted it.

While I waited for an answer, I did a workaround, which I am sharing here in case someone doesn't want to remember to toggle the Live literals setting off, like me.

I moved all the performance critical piece of the code into a separate module (pure Java/Kotlin library). Since the compose plugin isn't enabled in this module, there is no instrumentation being done on it. And the performance of my code went up by 10x!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.