Skip to content

Commit 07ef985

Browse files
Daniel Famakinfacebook-github-bot
Daniel Famakin
authored andcommitted
ensure E2EDumpsysHelper can work with nested Litho trees
Summary: Nested trees use `LithoRenderTreeView` (a subclass of `BaseMountingView`) to mount the layout state. However, our dumpsys helpers (which are used by the E2E framework and Flipper) make assumptions that the mounting view is always a `LithoView`. Unfortunately, this does not work. The nested tree experiment ended up breaking this assumption as well as a lot of tests that suddenly couldn't dump the view/component hierarchy correctly This diff changes the dumpsys helper(s) to use `BaseMountingView` instead which covers all mounting views used in the Litho framework Reviewed By: adityasharat Differential Revision: D54789839 fbshipit-source-id: ef18bd4b87cdd7a5cee58f9720438bf521b2a4ee
1 parent c24464b commit 07ef985

File tree

1 file changed

+6
-27
lines changed

1 file changed

+6
-27
lines changed

android/plugins/litho/src/main/java/com/facebook/flipper/plugins/uidebugger/litho/descriptors/DebugComponentDescriptor.kt

+6-27
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import com.facebook.flipper.plugins.uidebugger.model.MetadataId
3030
import com.facebook.flipper.plugins.uidebugger.util.Deferred
3131
import com.facebook.flipper.plugins.uidebugger.util.MaybeDeferred
3232
import com.facebook.litho.Component
33-
import com.facebook.litho.ComponentTree
3433
import com.facebook.litho.DebugComponent
3534
import com.facebook.litho.DebugLayoutNodeEditor
3635
import com.facebook.litho.StateContainer
@@ -279,23 +278,23 @@ class DebugComponentDescriptor(val register: DescriptorRegister) : NodeDescripto
279278
}
280279

281280
val mountState = lithoView.mountDelegateTarget
282-
val componentTree = lithoView.componentTree ?: return mountingData
281+
val layoutState = lithoView.currentLayoutState ?: return mountingData
283282

284283
val component = node.component
285284

286285
if (component.mountType != Component.MountType.NONE) {
287-
val renderUnit = DebugComponent.getRenderUnit(node, componentTree)
286+
val renderUnit = DebugComponent.getRenderUnit(node, layoutState)
288287
if (renderUnit != null) {
289288
val renderUnitId = renderUnit.id
290289
val isMounted = mountState.getContentById(renderUnitId) != null
291290
mountingData[isMountedAttributeId] = InspectableValue.Boolean(isMounted)
292-
isExcludedFromIncrementalMount(node, componentTree)?.let {
293-
mountingData[excludeFromIncrementalMountAttributeId] = InspectableValue.Boolean(it)
294-
}
291+
mountingData[excludeFromIncrementalMountAttributeId] =
292+
InspectableValue.Boolean(
293+
DebugComponent.isExcludedFromIncrementalMount(node, layoutState))
295294
}
296295
}
297296

298-
val visibilityOutput = DebugComponent.getVisibilityOutput(node, componentTree)
297+
val visibilityOutput = DebugComponent.getVisibilityOutput(node, layoutState)
299298
if (visibilityOutput != null) {
300299
val isVisible = DebugComponent.isVisible(node, lithoView)
301300
mountingData[isVisibleAttributeId] = InspectableValue.Boolean(isVisible)
@@ -304,26 +303,6 @@ class DebugComponentDescriptor(val register: DescriptorRegister) : NodeDescripto
304303
return mountingData
305304
}
306305

307-
private fun isExcludedFromIncrementalMount(
308-
node: DebugComponent,
309-
componentTree: ComponentTree
310-
): Boolean? {
311-
return try {
312-
// TODO: T174494880 Remove reflection approach once litho-oss releases new version. When
313-
// ready, just replace by DebugComponent.isExcludedFromIncrementalMount(node, componentTree)
314-
val debugComponentClass = DebugComponent::class.java
315-
val isExcludedFromIncrementalMountMethod =
316-
debugComponentClass.getDeclaredMethod(
317-
"isExcludedFromIncrementalMount",
318-
DebugComponent::class.java,
319-
ComponentTree::class.java)
320-
isExcludedFromIncrementalMountMethod.invoke(null, node, componentTree) as? Boolean
321-
} catch (exception: Exception) {
322-
// Reflection is really brittle and we don't want to break the UI Debugger in that case.
323-
null
324-
}
325-
}
326-
327306
class OverrideData(
328307
val metadataPath: List<Metadata>,
329308
val value: FlipperDynamic,

0 commit comments

Comments
 (0)