From d12cdf332507dffe84af3b0b59c30239d7fec97e Mon Sep 17 00:00:00 2001 From: Michal Zielinski Date: Wed, 15 May 2024 04:49:53 -0700 Subject: [PATCH] Add action that resets recomposition counts Summary: As per title - this diff adds a custom action which allows for resetting recomposition counts. Reviewed By: luluwu2032 Differential Revision: D57371575 fbshipit-source-id: 81608bd6e6430c6dd28421c385746b98dee9e6d8 --- .../plugins/jetpackcompose/UIDebuggerComposeSupport.kt | 3 +++ .../descriptors/AbstractComposeViewDescriptor.kt | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/android/plugins/jetpack-compose/src/main/java/com/facebook/flipper/plugins/jetpackcompose/UIDebuggerComposeSupport.kt b/android/plugins/jetpack-compose/src/main/java/com/facebook/flipper/plugins/jetpackcompose/UIDebuggerComposeSupport.kt index 27ce60fcddd..01774031fe8 100644 --- a/android/plugins/jetpack-compose/src/main/java/com/facebook/flipper/plugins/jetpackcompose/UIDebuggerComposeSupport.kt +++ b/android/plugins/jetpack-compose/src/main/java/com/facebook/flipper/plugins/jetpackcompose/UIDebuggerComposeSupport.kt @@ -60,6 +60,9 @@ object UIDebuggerComposeSupport { AbstractComposeViewDescriptor.layoutInspector.hideSystemNodes = newValue newValue } + unitAction("Reset Recomposition Counts", ActionIcon.Antd("CloseSquareOutlined")) { + AbstractComposeViewDescriptor.resetRecompositionCounts() + } } } } diff --git a/android/plugins/jetpack-compose/src/main/java/com/facebook/flipper/plugins/jetpackcompose/descriptors/AbstractComposeViewDescriptor.kt b/android/plugins/jetpack-compose/src/main/java/com/facebook/flipper/plugins/jetpackcompose/descriptors/AbstractComposeViewDescriptor.kt index ea442aa8f88..2c8e41800fd 100644 --- a/android/plugins/jetpack-compose/src/main/java/com/facebook/flipper/plugins/jetpackcompose/descriptors/AbstractComposeViewDescriptor.kt +++ b/android/plugins/jetpack-compose/src/main/java/com/facebook/flipper/plugins/jetpackcompose/descriptors/AbstractComposeViewDescriptor.kt @@ -34,6 +34,10 @@ object AbstractComposeViewDescriptor : ChainedDescriptor() } } + fun resetRecompositionCounts() { + recompositionHandler.changeCollectionMode(startCollecting = true, keepCounts = false) + } + override fun onGetName(node: AbstractComposeView): String = node.javaClass.simpleName private fun transform(