DEV Community

Mohit Rajput
Mohit Rajput

Posted on

Debugging Recompositions in Jetpack Compose

If you've ever wondered, "Why is my composable recomposing so many times?" — you're not alone 😅

Jetpack Compose makes UI building elegant, but understanding when and why recomposition happens can get tricky.

Recently, I came across an awesome open-source library 👉 Rebugger — and it's a total game-changer!


🔍 What Rebugger Does

Rebugger helps you visualise recompositions in real-time by showing which parameters triggered a recomposition and how often it happens — right inside your UI or logcat.

No need to guess anymore — you see exactly what changed and why Compose decided to recompose.


🧠 How to Use

Just wrap your composable with the Rebugger composable, providing the variables you want to track in the trackMap:

Rebugger(trackMap = mapOf(
    "state" to statekot, // Replace with your actual state/variable
    "user" to user,       // Replace with your actual state/variable
    "products" to products // Replace with your actual state/variable
)) {
    // Your Composable Content goes here
}
Enter fullscreen mode Exit fullscreen mode

And you'll instantly see recomposition info in logcat.

This is perfect for performance tuning and code reviews.


⚡ Why It’s Useful

  • Identify unnecessary recompositions instantly.
  • Optimize your Compose code for better performance.
  • Great tool for learning Compose internals and debugging UI behavior.

Big thanks 🙌 to @theapache64 for creating this tool — I wish I had it when I started migrating to Compose!

If you’re working with Jetpack Compose, this one is absolutely worth adding to your dev toolbox. 🧰

Try it out here: https://github.com/theapache64/rebugger


💬 Let's Discuss

Have you used any other tools or tricks to debug recomposition?

Would love to hear your favourites below 👇

#Android #JetpackCompose #Recomposition #Performance #AndroidDev #Kotlin #MobileDevelopment

Top comments (0)