Search code examples
androidkotlinandroid-jetpack-composeandroid-jetpack

App made with JetPack Compose is hanging beyond expectation


I am new to JetPack Compose. I am leanring Compose and was following https://developer.android.com/jetpack/compose/tutorial


But when I ran the application in my android device, the app was extremely slow. Simple things like expanding long message and changing color of message is taking so much time.

I have googled the problem and found:

  1. https://www.reddit.com/r/androiddev/comments/oatiur/why_simple_app_with_jetpack_compose_is_5x_times/
  2. https://github.com/android/compose-samples/issues/21
  3. https://jetc.dev/slack/2021-03-14-why-so-slow.html
  4. Jetpack Compose Performance Issue that only occurs in multi module project


But none of these were helpful to me.

If there is any confusion, please tell in the comments.


Solution

  • I experienced the same thing. What is currently happening is:-

    1.) App Startup is kinda slow
    2.) App is glitchy upon start

    The good news is:-

    1.) The glitches only happen for the first few times you run the animation,
    2.) The glitches seem to disappear from every element after you break one of the elements in.

    The bad news is of course, you have to repeat the above steps upon EVERY startup. I have heard that running the production builds instead of the debug variants boosts up the performance significantly. As of now, there's nothing you can do about it. It will only break in as Compose develops. You can check the official Compose Samples too. They are as glitchy as your apps.

    All you can really do at this point is wait.

    EDITS BASED ON THE COMMENTS BELOW:-

    1.) By The glitches seem to disappear from every element after you break one of the elements in., I mean that if you have a lot of animated content, like maybe two LazyColumns, and a few others, then upon swiping the Column back and forth a few times (breaking it in), the lag will be gone from the other columns, as well as the animated content. Element there meant element of the screen, so individual LazyColumns are each elements.

    2.) To get the production build, all you need to do is click on the release tab in the left edge of the screen in studio, then select release from the dropdown list instead of debug. 'Production' was substituted by me for 'release', but it's one and the same thing you see.