Skip to content

Commit 903fcbc

Browse files
authored
Properly handle recycling of RecomposeHighlighterModifier (#510)
* Properly handle recycling of RecomposeHighlighterModifier After migrating to be Node based, it's possible the Modifier node can be reused. For example, when scrolling in a LazyColumn the nodes of items scrolled off the viewport may be recycled and used with items scrolling into the viewport. When this occurs, the composition count needs to be reset. Otherwise, it may look like the item scrolling into the viewport has recomposed more than it actually has. * Fix code style
1 parent 70285ac commit 903fcbc

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

compose/recomposehighlighter/src/main/java/com/example/android/compose/recomposehighlighter/RecomposeHighlighter.kt

+5
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ private class RecomposeHighlighterModifier : Modifier.Node(), DrawModifierNode {
8989

9090
override val shouldAutoInvalidate: Boolean = false
9191

92+
override fun onReset() {
93+
totalCompositions = 0
94+
timerJob?.cancel()
95+
}
96+
9297
override fun onDetach() {
9398
timerJob?.cancel()
9499
}

0 commit comments

Comments
 (0)