Member-only story

How to Debug Jetpack Compose Recomposition with Logging?

What is the best way to debug Jetpack Compose recomposition? Breakpoints in debugger, standard logging (i.e. Log.d) or do we need custom logging?

Vincent Tsen
4 min readMar 17, 2023

Recomposition in Jetpack Compose is a complex topic. It is complex because sometimes you have no idea why a certain function is recomposed, which is not what you expected based on your knowledge. Thus, you need to debug it.

Breakpoints in Debugger

Using breakpoints in a debugger first comes to my mind to debug recomposition. However, there are a few limitations to this approach.

  • It doesn’t tell you recomposition scope information(i.e. $currentRecomposeScope- see below)
  • It doesn’t keep track of how many recompositions have been occurred

Standard Logging

So to debug with logging, you use Log.d. It looks like this

Log.d("DebugRecomposition", "RecompositionExample() function scope")

But it missed one important piece of information, which doesn’t tell the current recompose scope information. This information is important because different composable functions can still have the same…

--

--

No responses yet