Skip to content

Commit 934b614

Browse files
Fabio Carballofacebook-github-bot
Fabio Carballo
authored andcommitted
Add events for RenderTreeMountStart and RenderTreeMountEnd.
Summary: This will enable us to see all mount related events happening between the start and end of a render Tree mount. Reviewed By: LukeDefeo Differential Revision: D51805336 fbshipit-source-id: f4e676d171eace7fa61ca08b032bb287653ddce1
1 parent 1abd428 commit 934b614

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

litho-core/src/main/java/com/facebook/litho/BaseMountingView.java

+1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public BaseMountingView(ComponentContext context, @Nullable AttributeSet attrs)
9797
mMountState.setEnsureParentMounted(true);
9898
mViewAttributeFlags = LithoMountData.getViewAttributeFlags(this);
9999
}
100+
100101
/**
101102
* Sets the width that the BaseMountingView should take on the next measure pass and then requests
102103
* a layout. This should be called from animation-driving code on each frame to animate the size

litho-rendercore/src/main/java/com/facebook/rendercore/MountState.java

+23
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import static com.facebook.rendercore.debug.DebugEventAttribute.Description;
2121
import static com.facebook.rendercore.debug.DebugEventAttribute.HashCode;
2222
import static com.facebook.rendercore.debug.DebugEventAttribute.Key;
23+
import static com.facebook.rendercore.debug.DebugEventAttribute.NumMountableOutputs;
2324
import static com.facebook.rendercore.debug.DebugEventAttribute.RenderUnitId;
2425
import static com.facebook.rendercore.debug.DebugEventAttribute.RootHostHashCode;
2526
import static com.facebook.rendercore.debug.DebugEventDispatcher.beginTrace;
@@ -34,6 +35,7 @@
3435
import androidx.collection.LongSparseArray;
3536
import androidx.core.util.Preconditions;
3637
import com.facebook.rendercore.debug.DebugEvent;
38+
import com.facebook.rendercore.debug.DebugEventDispatcher;
3739
import com.facebook.rendercore.extensions.ExtensionState;
3840
import com.facebook.rendercore.extensions.MountExtension;
3941
import com.facebook.rendercore.extensions.RenderCoreExtension;
@@ -43,6 +45,7 @@
4345
import java.util.ArrayList;
4446
import java.util.HashMap;
4547
import java.util.List;
48+
import kotlin.Unit;
4649

4750
public class MountState implements MountDelegateTarget {
4851

@@ -127,13 +130,24 @@ public void mount(RenderTree renderTree) {
127130
if (traceIdentifier != null) {
128131
HashMap<String, Object> attributes = new HashMap<>();
129132
attributes.put(RootHostHashCode, mRootHost.hashCode());
133+
attributes.put(NumMountableOutputs, renderTree.getMountableOutputCount());
130134

131135
beginTrace(
132136
traceIdentifier,
133137
DebugEvent.RenderTreeMounted,
134138
String.valueOf(renderTree.getRenderStateId()),
135139
attributes);
136140
}
141+
142+
DebugEventDispatcher.dispatch(
143+
DebugEvent.RenderTreeMountStart,
144+
() -> String.valueOf(renderTree.getRenderStateId()),
145+
attrs -> {
146+
attrs.put(RootHostHashCode, mRootHost.hashCode());
147+
attrs.put(NumMountableOutputs, renderTree.getMountableOutputCount());
148+
return Unit.INSTANCE;
149+
});
150+
137151
try {
138152

139153
if (mIsMounting) {
@@ -229,6 +243,15 @@ public void mount(RenderTree renderTree) {
229243
endTrace(traceIdentifier);
230244
}
231245
mIsMounting = false;
246+
247+
DebugEventDispatcher.dispatch(
248+
DebugEvent.RenderTreeMountEnd,
249+
() -> String.valueOf(renderTree.getRenderStateId()),
250+
attrs -> {
251+
attrs.put(RootHostHashCode, mRootHost.hashCode());
252+
attrs.put(NumMountableOutputs, renderTree.getMountableOutputCount());
253+
return Unit.INSTANCE;
254+
});
232255
}
233256
}
234257

litho-rendercore/src/main/java/com/facebook/rendercore/debug/DebugEvents.kt

+3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ sealed class DebugEvent(
4545
const val ViewOnLayout = "RenderCore.View.OnLayout"
4646
const val IncrementalMountStart = "RenderCore.IncrementalMount.Start"
4747
const val IncrementalMountEnd = "RenderCore.IncrementalMount.End"
48+
const val RenderTreeMountStart = "RenderCore.RenderTreeMount.Start"
49+
const val RenderTreeMountEnd = "RenderCore.RenderTreeMount.End"
4850
}
4951

5052
/** Returns the value of attribute with [name]. */
@@ -97,6 +99,7 @@ object DebugEventAttribute {
9799
const val Key = "key"
98100
const val VisibleRect = "visibleRect"
99101
const val BoundsVisible = "areBoundsVisible"
102+
const val NumMountableOutputs = "numMountableOutputs"
100103
}
101104

102105
/** Base class for marker events */

0 commit comments

Comments
 (0)